[rtems commit] dosfs: Directories should have a file size of 0

Sebastian Huber sebh at rtems.org
Tue Feb 28 08:44:09 UTC 2017


Module:    rtems
Branch:    master
Commit:    267de79ad27469a2ff7816043e76eecc99ffe38d
Changeset: http://git.rtems.org/rtems/commit/?id=267de79ad27469a2ff7816043e76eecc99ffe38d

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Feb 27 10:40:49 2017 +0100

dosfs: Directories should have a file size of 0

Close #2755.

---

 cpukit/libfs/src/dosfs/msdos_misc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_misc.c b/cpukit/libfs/src/dosfs/msdos_misc.c
index bd65850..464c981 100644
--- a/cpukit/libfs/src/dosfs/msdos_misc.c
+++ b/cpukit/libfs/src/dosfs/msdos_misc.c
@@ -820,7 +820,12 @@ fat_file_write_file_size(
     sec += (fat_fd->dir_pos.sname.ofs >> fs_info->vol.sec_log2);
     byte = (fat_fd->dir_pos.sname.ofs & (fs_info->vol.bps - 1));
 
-    le_new_length = CT_LE_L((fat_fd->fat_file_size));
+    if (fat_fd->fat_file_type == FAT_DIRECTORY) {
+      le_new_length = CT_LE_L(0);
+    } else {
+      le_new_length = CT_LE_L(fat_fd->fat_file_size);
+    }
+
     ret = fat_sector_write(fs_info, sec, byte + MSDOS_FILE_SIZE_OFFSET, 4,
                            (char *)(&le_new_length));
     if ( ret < 0 )




More information about the vc mailing list