From: Lawrence S. <ljs...@us...> - 2020-07-07 04:15:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e98b6ab7e69a1328b2e99462d9414cdf0781220f (commit) via 3c28fd833df07e180f98e0955c600570e2f60d90 (commit) via 4a44115cc7db03bad2f83ba65cb037cc8ad92510 (commit) via a4fa4c9b24758d604e5c1cc4fc2246de23584466 (commit) from 921ec7f7e51d878cad495308506e08657ea11748 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e98b6ab7e69a1328b2e99462d9414cdf0781220f Merge: 921ec7f 3c28fd8 Author: Lawrence Sebald <ljs...@us...> Date: Tue Jul 7 00:13:46 2020 -0400 Merge pull request #44 from tsowell/libkosfat-fixes Libkosfat fixes commit 3c28fd833df07e180f98e0955c600570e2f60d90 Author: Thomas Sowell <to...@sh...> Date: Mon Jul 6 18:14:00 2020 -0800 libkosfat: Fix issue erasing long name entries fat_erase_dentry tries to move on to the next cluster after it finishes deleting a long name which causes an EIO. commit 4a44115cc7db03bad2f83ba65cb037cc8ad92510 Author: Thomas Sowell <to...@sh...> Date: Mon Jul 6 18:11:12 2020 -0800 libkosfat: Don't try to erase chain of empty files fat_erase_chain will loop forever if called with cluster=0 commit a4fa4c9b24758d604e5c1cc4fc2246de23584466 Author: Thomas Sowell <to...@sh...> Date: Mon Jun 1 14:32:35 2020 -0800 libkosfat: Fix cluster from fat_find_dentry ----------------------------------------------------------------------- Summary of changes: addons/libkosfat/directory.c | 64 +++++++++++++++++++++++--------------------- addons/libkosfat/fs_fat.c | 15 ++++++----- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/addons/libkosfat/directory.c b/addons/libkosfat/directory.c index e71ec74..7625f06 100644 --- a/addons/libkosfat/directory.c +++ b/addons/libkosfat/directory.c @@ -594,7 +594,6 @@ int fat_find_dentry(fat_fs_t *fs, const char *fn, fat_dentry_t *rv, } tok = strtok_r(NULL, "/", &tmp); - cl = cur.cluster_low | (cur.cluster_high << 16); } /* One last check... If the filename the user passed in ends with a '/' @@ -698,39 +697,44 @@ int fat_erase_dentry(fat_fs_t *fs, uint32_t cl, uint32_t off, uint32_t lcl, ent->name[0] = FAT_ENTRY_FREE; } - /* Move onto the next cluster. */ - if(!(lcl & 0x80000000)) { - lcl = fat_read_fat(fs, lcl, &err); - if(lcl == 0xFFFFFFFF) { - dbglog(DBG_ERROR, "Invalid FAT value hit while reading long" - " name entry for deletion at cluster %" PRIu32 - ", offset %" PRIu32 "\n", lcl, i << 5); - return -err; - } - - /* This shouldn't happen either... */ - if(fat_is_eof(fs, lcl)) { - dbglog(DBG_ERROR, "End of directory hit while reading long " - "name entry for deletion at cluster %" PRIu32 - ", offset %" PRIu32 "\n", lcl, i << 5); - return -EIO; - } + if(!done) { + /* Move onto the next cluster. */ + if(!(lcl & 0x80000000)) { + lcl = fat_read_fat(fs, lcl, &err); + if(lcl == 0xFFFFFFFF) { + dbglog(DBG_ERROR, "Invalid FAT value hit while " + "reading long name entry for deletion at " + "cluster %" PRIu32 ", offset %" PRIu32 "\n", + lcl, i << 5); + return -err; + } - i = 0; - } - else { - ++lcl; - max2 -= max; + /* This shouldn't happen either... */ + if(fat_is_eof(fs, lcl)) { + dbglog(DBG_ERROR, "End of directory hit while " + "reading long name entry for deletion at " + "cluster %" PRIu32 ", offset %" PRIu32 "\n", + lcl, i << 5); + return -EIO; + } - if(max2 <= 0) { - dbglog(DBG_ERROR, "End of directory hit while reading long " - "name entry for deletion at cluster %" PRIu32 - ", offset %" PRIu32 "\n", lcl, i << 5); - return -EIO; + i = 0; } + else { + ++lcl; + max2 -= max; + + if(max2 <= 0) { + dbglog(DBG_ERROR, "End of directory hit while " + "reading long name entry for deletion at " + "cluster %" PRIu32 ", offset %" PRIu32 "\n", + lcl, i << 5); + return -EIO; + } - i = 0; - } + i = 0; + } + } } } diff --git a/addons/libkosfat/fs_fat.c b/addons/libkosfat/fs_fat.c index f6815b9..6c63bd8 100644 --- a/addons/libkosfat/fs_fat.c +++ b/addons/libkosfat/fs_fat.c @@ -1012,13 +1012,16 @@ static int fs_fat_unlink(vfs_handler_t *vfs, const char *fn) { return -1; } - /* First clean up the clusters of the file... */ + /* First clean up the clusters of the file... (if any) */ cluster = ent.cluster_low | (ent.cluster_high << 16); - if((err = fat_erase_chain(fs->fs, cluster))) { - /* Uh oh... This is really bad... */ - dbglog(DBG_ERROR, "fs_fat: Error erasing FAT chain for file %s\n", fn); - irv = -1; - errno = -err; + if(cluster != FAT_FREE_CLUSTER) { + if((err = fat_erase_chain(fs->fs, cluster))) { + /* Uh oh... This is really bad... */ + dbglog(DBG_ERROR, "fs_fat: Error erasing FAT chain for file %s\n", + fn); + irv = -1; + errno = -err; + } } /* Next, erase the directory entry (and long name, if applicable). */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |