Skip to content

Commit 725a825

Browse files
committed
Update FatFs
1 parent b81f59d commit 725a825

2 files changed

Lines changed: 34 additions & 26 deletions

File tree

  • haxloader/source/fatfs
  • source/fatfs

haxloader/source/fatfs/ff.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,8 @@ FRESULT load_obj_dir (
20502050
dp->obj.fs = obj->fs;
20512051
dp->obj.sclust = obj->c_scl;
20522052
dp->obj.stat = (BYTE)obj->c_size;
2053-
dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2053+
dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2054+
dp->obj.n_frag = 0;
20542055
dp->blk_ofs = obj->c_ofs;
20552056

20562057
res = dir_sdi(dp, dp->blk_ofs); /* Goto object's entry block */
@@ -2326,19 +2327,22 @@ FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many S
23262327
if (res != FR_OK) return res;
23272328
dp->blk_ofs = dp->dptr - SZDIRE * (nent - 1); /* Set the allocated entry block offset */
23282329

2329-
if (dp->obj.sclust != 0 && (dp->obj.stat & 4)) { /* Has the sub-directory been stretched? */
2330-
dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2331-
res = fill_first_frag(&dp->obj); /* Fill first fragment on the FAT if needed */
2332-
if (res != FR_OK) return res;
2333-
res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed */
2334-
if (res != FR_OK) return res;
2335-
res = load_obj_dir(&dj, &dp->obj); /* Load the object status */
2336-
if (res != FR_OK) return res;
2337-
st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */
2338-
st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2339-
fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1;
2340-
res = store_xdir(&dj); /* Store the object status */
2330+
if (dp->obj.stat & 4) { /* Has the directory been stretched? */
2331+
dp->obj.stat &= ~4;
2332+
res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
23412333
if (res != FR_OK) return res;
2334+
res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if needed */
2335+
if (res != FR_OK) return res;
2336+
if (dp->obj.sclust != 0) { /* Is it a sub directory? */
2337+
res = load_obj_dir(&dj, &dp->obj); /* Load the object status */
2338+
if (res != FR_OK) return res;
2339+
dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2340+
st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */
2341+
st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2342+
fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1;
2343+
res = store_xdir(&dj); /* Store the object status */
2344+
if (res != FR_OK) return res;
2345+
}
23422346
}
23432347

23442348
create_xdir(fs->dirbuf, fs->lfnbuf); /* Create on-memory directory block to be written later */

source/fatfs/ff.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,8 @@ FRESULT load_obj_dir (
20502050
dp->obj.fs = obj->fs;
20512051
dp->obj.sclust = obj->c_scl;
20522052
dp->obj.stat = (BYTE)obj->c_size;
2053-
dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2053+
dp->obj.objsize = obj->c_size & 0xFFFFFF00;
2054+
dp->obj.n_frag = 0;
20542055
dp->blk_ofs = obj->c_ofs;
20552056

20562057
res = dir_sdi(dp, dp->blk_ofs); /* Goto object's entry block */
@@ -2326,19 +2327,22 @@ FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many S
23262327
if (res != FR_OK) return res;
23272328
dp->blk_ofs = dp->dptr - SZDIRE * (nent - 1); /* Set the allocated entry block offset */
23282329

2329-
if (dp->obj.sclust != 0 && (dp->obj.stat & 4)) { /* Has the sub-directory been stretched? */
2330-
dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2331-
res = fill_first_frag(&dp->obj); /* Fill first fragment on the FAT if needed */
2332-
if (res != FR_OK) return res;
2333-
res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed */
2334-
if (res != FR_OK) return res;
2335-
res = load_obj_dir(&dj, &dp->obj); /* Load the object status */
2336-
if (res != FR_OK) return res;
2337-
st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */
2338-
st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2339-
fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1;
2340-
res = store_xdir(&dj); /* Store the object status */
2330+
if (dp->obj.stat & 4) { /* Has the directory been stretched? */
2331+
dp->obj.stat &= ~4;
2332+
res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
23412333
if (res != FR_OK) return res;
2334+
res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if needed */
2335+
if (res != FR_OK) return res;
2336+
if (dp->obj.sclust != 0) { /* Is it a sub directory? */
2337+
res = load_obj_dir(&dj, &dp->obj); /* Load the object status */
2338+
if (res != FR_OK) return res;
2339+
dp->obj.objsize += (DWORD)fs->csize * SS(fs); /* Increase the directory size by cluster size */
2340+
st_qword(fs->dirbuf + XDIR_FileSize, dp->obj.objsize); /* Update the allocation status */
2341+
st_qword(fs->dirbuf + XDIR_ValidFileSize, dp->obj.objsize);
2342+
fs->dirbuf[XDIR_GenFlags] = dp->obj.stat | 1;
2343+
res = store_xdir(&dj); /* Store the object status */
2344+
if (res != FR_OK) return res;
2345+
}
23422346
}
23432347

23442348
create_xdir(fs->dirbuf, fs->lfnbuf); /* Create on-memory directory block to be written later */

0 commit comments

Comments
 (0)