diff options
-rw-r--r-- | fs/fat/fat_write.c | 2 | ||||
-rw-r--r-- | include/fat.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index cef138e..90d6ab6 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -882,7 +882,7 @@ static dir_entry *find_directory_entry(fsdata *mydata, int startsect, } curclust = get_fatent_value(mydata, dir_curclust); - if ((curclust >= 0xffffff8) || (curclust >= 0xfff8)) { + if (IS_LAST_CLUST(curclust, mydata->fatsize)) { empty_dentptr = dentptr; return NULL; } diff --git a/include/fat.h b/include/fat.h index 65da733..81d9790 100644 --- a/include/fat.h +++ b/include/fat.h @@ -84,6 +84,9 @@ #define START(dent) (FAT2CPU16((dent)->start) \ + (mydata->fatsize != 32 ? 0 : \ (FAT2CPU16((dent)->starthi) << 16))) +#define IS_LAST_CLUST(x, fatsize) ((x) >= ((fatsize) != 32 ? \ + ((fatsize) != 16 ? 0xff8 : 0xfff8) : \ + 0xffffff8)) #define CHECK_CLUST(x, fatsize) ((x) <= 1 || \ (x) >= ((fatsize) != 32 ? \ ((fatsize) != 16 ? 0xff0 : 0xfff0) : \ |