fs: fat: fix wrong casting to unsigned value of sect_to_cluster()
A message that is not in the archive (sent off-list or not yet received): CGME20180604114556epcas1p373ba4abe43a2441abc99c8c17a757aec@epcas1p3.samsung.com
PATCH 1/1 fs: fat: fix wrong casting to unsigned value of sect_to_cluster()
After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value of sect_to_cluster() is not proper by casting from signed value to unsigned value. Fix the wrong casting of sect_to_cluster().
--- include/fat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/fat.h +1 -1
@@ -180,7 +180,7 @@ static inline u32 clust_to_sect(fsdata *fsdata, u32 clust)return fsdata->data_begin + clust * fsdata->clust_size; } -static inline u32 sect_to_clust (fsdata *fsdata,u32 sect) +static inline u32 sect_to_clust (fsdata *fsdata,int sect) {return (sect - fsdata->data_begin) / fsdata->clust_size; }
Signature · 1 line
1.7.9.5
PATCH 1/1 fs: fat: fix wrong casting to unsigned value of sect_to_cluster()
Quoted 11 lines · Seung-Woo Kim
After the commit
265edc03d5a1("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value ofsect_to_cluster()is not proper by casting from signed value to unsigned value. Fix the wrong casting ofsect_to_cluster().Reported-by Jaehoon Chung <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>--- include/fat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Can you please also update test/fs-test.sh with a testcase for this? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180604/93cef429/attachment.sig>
PATCH 1/1 fs: fat: fix wrong casting to unsigned value of sect_to_cluster()
Hello,
Quoted 8 lines · Tom Rini
Quoted 6 lines · Seung-Woo Kim
After the commit
265edc03d5a1("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value ofsect_to_cluster()is not proper by casting from signed value to unsigned value. Fix the wrong casting ofsect_to_cluster().
Quoted 9 lines
Quoted 5 lines
Reported-by Jaehoon Chung <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>--- include/fat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Can you please also update
test/fs-test.shwith a testcase for this? Thanks!
The simple test way is doing fat-write more than 20 files with long file name to FAT16 image.
For example, in my armv7 odroid-xu3 target with empty fat16 root, writing like following:
fatwrite mmc 0 13000000 01000000000000000000 4
fatwrite mmc 0 13000000 02000000000000000000 4
..
fatwrite mmc 0 13000000 21000000000000000000 4
and then 22th writing was failed like following:
ODROID-XU3 # fatwrite mmc 0 13000000 22000000000000000000 4 writing 22000000000000000000
Error: Invalid FAT entry: 0x3ffffffa
Invalid FAT entry
Error: Invalid FAT entry: 0x3ffffffa
I tested same thing with sandbox u-boot on x86, there was no error like armv7. So, I am not sure it is helpful to add testcase for this.
Best Regards,
- Seung-Woo Kim
Signature · 3 lines
Seung-Woo Kim Samsung Research --
PATCH 1/1 fs: fat: fix wrong casting to unsigned value of sect_to_cluster()
In reply to Seung-Woo KimHi Seung-Woo,
Quoted 17 lines
After the commit
265edc03d5a1("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value ofsect_to_cluster()is not proper by casting from signed value to unsigned value. Fix the wrong casting ofsect_to_cluster().Reported-by Jaehoon Chung <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>--- include/fat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/fat.h +0
-0
include/fat.h static inline u32 clust_to_sect(fsdata *fsdata, · line 186
Quoted 8 lines
include/fat.h +1
-1@@ -180,7 +180,7 @@ static inline u32 clust_to_sect(fsdata *fsdata, u32 clust) return fsdata->data_begin + clust * fsdata->clust_size; } -static inline u32 sect_to_clust (fsdata *fsdata,u32 sect) +static inline u32 sect_to_clust (fsdata *fsdata,int sect) {return (sect - fsdata->data_begin) / fsdata->clust_size; }
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180612/620bc4ed/attachment.sig>
Quoted 9 lines · Seung-Woo Kim
After the commit
265edc03d5a1("fs/fat: Clean up open-coded sector <-> cluster conversions"), it is hung up writing new file to FAT16 disk with more than 19 files in armv7. It is because result value ofsect_to_cluster()is not proper by casting from signed value to unsigned value. Fix the wrong casting ofsect_to_cluster().Reported-by Jaehoon Chung <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>Reviewed-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180613/bebff14d/attachment.sig>