R0.13b patch 2
Jul 8, 2018 Creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. This problem was reported at the User Forum.
This commit is contained in:
+5
-5
@@ -4841,6 +4841,7 @@ FRESULT f_mkdir (
|
|||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
DIR dj;
|
DIR dj;
|
||||||
|
FFOBJID sobj;
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
DWORD dcl, pcl, tm;
|
DWORD dcl, pcl, tm;
|
||||||
@@ -4858,13 +4859,12 @@ FRESULT f_mkdir (
|
|||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
}
|
}
|
||||||
if (res == FR_NO_FILE) { /* Can create a new directory */
|
if (res == FR_NO_FILE) { /* Can create a new directory */
|
||||||
dcl = create_chain(&dj.obj, 0); /* Allocate a cluster for the new directory table */
|
sobj.fs = fs; /* New object id to create a new chain */
|
||||||
dj.obj.objsize = (DWORD)fs->csize * SS(fs);
|
dcl = create_chain(&sobj, 0); /* Allocate a cluster for the new directory */
|
||||||
res = FR_OK;
|
res = FR_OK;
|
||||||
if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */
|
if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */
|
||||||
if (dcl == 1) res = FR_INT_ERR;
|
if (dcl == 1) res = FR_INT_ERR;
|
||||||
if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR;
|
if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR;
|
||||||
if (res == FR_OK) res = sync_window(fs); /* Flush FAT */
|
|
||||||
tm = GET_FATTIME();
|
tm = GET_FATTIME();
|
||||||
if (res == FR_OK) { /* Initialize the new directory table */
|
if (res == FR_OK) { /* Initialize the new directory table */
|
||||||
res = dir_clear(fs, dcl); /* Clean up the new table */
|
res = dir_clear(fs, dcl); /* Clean up the new table */
|
||||||
@@ -4889,8 +4889,8 @@ FRESULT f_mkdir (
|
|||||||
if (fs->fs_type == FS_EXFAT) { /* Initialize directory entry block */
|
if (fs->fs_type == FS_EXFAT) { /* Initialize directory entry block */
|
||||||
st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Created time */
|
st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Created time */
|
||||||
st_dword(fs->dirbuf + XDIR_FstClus, dcl); /* Table start cluster */
|
st_dword(fs->dirbuf + XDIR_FstClus, dcl); /* Table start cluster */
|
||||||
st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)dj.obj.objsize); /* File size needs to be valid */
|
st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)fs->csize * SS(fs)); /* File size needs to be valid */
|
||||||
st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)dj.obj.objsize);
|
st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)fs->csize * SS(fs));
|
||||||
fs->dirbuf[XDIR_GenFlags] = 3; /* Initialize the object flag */
|
fs->dirbuf[XDIR_GenFlags] = 3; /* Initialize the object flag */
|
||||||
fs->dirbuf[XDIR_Attr] = AM_DIR; /* Attribute */
|
fs->dirbuf[XDIR_Attr] = AM_DIR; /* Attribute */
|
||||||
res = store_xdir(&dj);
|
res = store_xdir(&dj);
|
||||||
|
|||||||
Reference in New Issue
Block a user