mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-08 18:58:34 -05:00
FatFs: Apply patch ff12a_p5.diff.
Fixed one chunk of this patch in an earlier commit.
This commit is contained in:
parent
81517b3f4d
commit
60cc9b7faa
@ -5303,7 +5303,7 @@ FRESULT f_mkfs (
|
|||||||
|
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fmt == FS_EXFAT) { /* Create an exFAT volume */
|
if (fmt == FS_EXFAT) { /* Create an exFAT volume */
|
||||||
DWORD sum, szb_bit, szb_case;
|
DWORD szb_bit, szb_case, sum, nb, cl;
|
||||||
WCHAR ch, si;
|
WCHAR ch, si;
|
||||||
UINT j, st;
|
UINT j, st;
|
||||||
BYTE b;
|
BYTE b;
|
||||||
@ -5368,32 +5368,37 @@ FRESULT f_mkfs (
|
|||||||
tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case clusters */
|
tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case clusters */
|
||||||
|
|
||||||
/* Initialize the allocation bitmap */
|
/* Initialize the allocation bitmap */
|
||||||
mem_set(buf, 0, szb_buf); /* Set in-use flags of bitmap, up-case and root dir */
|
|
||||||
for (i = 0, n = tbl[0] + tbl[1] + tbl[2]; n >= 8; buf[i++] = 0xFF, n -= 8) ;
|
|
||||||
for (b = 1; n; buf[i] |= b, b <<= 1, n--) ;
|
|
||||||
sect = b_data; n = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of the sectors */
|
sect = b_data; n = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of the sectors */
|
||||||
do { /* Fill allocation bitmap sectors */
|
nb = tbl[0] + tbl[1] + tbl[2]; /* Number of clusters in-use by system */
|
||||||
ns = (n > sz_buf) ? sz_buf : n;
|
do {
|
||||||
|
mem_set(buf, 0, szb_buf);
|
||||||
|
for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ;
|
||||||
|
for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ;
|
||||||
|
ns = (n > sz_buf) ? sz_buf : n; /* Write the buffered data */
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns;
|
sect += ns; n -= ns;
|
||||||
mem_set(buf, 0, ss);
|
} while (n);
|
||||||
} while (n -= ns);
|
|
||||||
|
|
||||||
/* Initialize the FAT */
|
/* Initialize the FAT */
|
||||||
st_qword(buf, 0xFFFFFFFFFFFFFFF8); /* Entry 0 and 1 */
|
|
||||||
for (j = 0, i = 2; j < 3; j++) { /* Set entries of bitmap, up-case and root dir */
|
|
||||||
for (n = tbl[j]; n; n--) {
|
|
||||||
st_dword(buf + i * 4, (n >= 2) ? i + 1 : 0xFFFFFFFF);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sect = b_fat; n = sz_fat; /* Start of FAT and number of the sectors */
|
sect = b_fat; n = sz_fat; /* Start of FAT and number of the sectors */
|
||||||
do { /* Fill FAT sectors */
|
j = nb = cl = 0;
|
||||||
ns = (n > sz_buf) ? sz_buf : n;
|
do {
|
||||||
|
mem_set(buf, 0, szb_buf); i = 0;
|
||||||
|
if (cl == 0) { /* Set entry 0 and 1 */
|
||||||
|
st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++;
|
||||||
|
st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++;
|
||||||
|
}
|
||||||
|
do { /* Create chains of bitmap, up-case and root dir */
|
||||||
|
while (nb && i < szb_buf) { /* Create a chain */
|
||||||
|
st_dword(buf + i, (nb > 1) ? cl + 1 : 0xFFFFFFFF);
|
||||||
|
i += 4; cl++; nb--;
|
||||||
|
}
|
||||||
|
if (!nb && j < 3) nb = tbl[j++]; /* Next chain */
|
||||||
|
} while (nb && i < szb_buf);
|
||||||
|
ns = (n > sz_buf) ? sz_buf : n; /* Write the buffered data */
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns;
|
sect += ns; n -= ns;
|
||||||
mem_set(buf, 0, ss);
|
} while (n);
|
||||||
} while (n -= ns);
|
|
||||||
|
|
||||||
/* Initialize the root directory */
|
/* Initialize the root directory */
|
||||||
mem_set(buf, 0, ss);
|
mem_set(buf, 0, ss);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user