diff options
author | Frank Li <Frank.Li@nxp.com> | 2018-12-14 13:28:56 -0600 |
---|---|---|
committer | Frank Li <Frank.Li@nxp.com> | 2018-12-14 13:36:14 -0600 |
commit | 6392ca2f3402afc8d68d2ce1b7fd53eb0fc7d4ca (patch) | |
tree | 887d52a16e868cfa2f4fac96763806d9347b9802 /fs | |
parent | 4568f4a4c853ff9d952cfb5ec7c38c479de697d2 (diff) |
MLK-20594-1 fix fat write create file failure when fat12/16
Error: Invalid FAT entry: 0x3ffffffa
create file
when Long file name cross root dir cluster boundry, this issue
happen.
get_long_file_name have not consider fat12/16 case, which rootdir
locate before data area. and try to get next clust directly. Only
FAT32's root dir is located in data area
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fat/fat_write.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 2b753df282..5d22121709 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -299,11 +299,20 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster, if ((__u8 *)slotptr >= buflimit) { if (curclust == 0) return -1; - curclust = get_fatent(mydata, dir_curclust); - if (CHECK_CLUST(curclust, mydata->fatsize)) { - debug("curclust: 0x%x\n", curclust); - printf("Invalid FAT entry\n"); - return -1; + + if (mydata->fatsize == 32 ) { + curclust = get_fatent(mydata, dir_curclust); + if (CHECK_CLUST(curclust, mydata->fatsize)) { + debug("curclust: 0x%x\n", curclust); + printf("Invalid FAT entry\n"); + return -1; + } + } else { + /* + * In FAT16/12, the root dir is locate before data area + * curclust may negative number + */ + curclust++; } dir_curclust = curclust; |