]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Revert "fs/fat: fix case for FAT shortnames"
authorVipul Kumar <vipul.kumar@xilinx.com>
Wed, 5 Sep 2018 10:02:21 +0000 (15:32 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 5 Sep 2018 12:08:07 +0000 (14:08 +0200)
This reverts commit 21a24c3bf35bac83d66ce4a48eb0c7dd8a7227cb.

Noticed when comparing our output to linux.  There are some lcase bits
which control whether filename and/or extension should be downcase'd.

Signed-off-by: Vipul Kumar <vipul.kumar@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
fs/fat/fat.c
fs/fat/fat_write.c
include/fat.h

index d16883fa10d4af14be4391c33944dbc7d2a65c13..56386ed79bfcddf727d97e5255e4c32b0fbc0692 100644 (file)
@@ -29,13 +29,11 @@ static const int vfat_enabled = 0;
 #endif
 
 /*
- * Convert a string to lowercase.  Converts at most 'len' characters,
- * 'len' may be larger than the length of 'str' if 'str' is NULL
- * terminated.
+ * Convert a string to lowercase.
  */
-static void downcase(char *str, size_t len)
+static void downcase(char *str)
 {
-       while (*str != '\0' && len--) {
+       while (*str != '\0') {
                *str = tolower(*str);
                str++;
        }
@@ -133,13 +131,10 @@ static void get_name(dir_entry *dirent, char *s_name)
        ptr = s_name;
        while (*ptr && *ptr != ' ')
                ptr++;
-       if (dirent->lcase & CASE_LOWER_BASE)
-               downcase(s_name, (unsigned)(ptr - s_name));
        if (dirent->ext[0] && dirent->ext[0] != ' ') {
-               *ptr++ = '.';
+               *ptr = '.';
+               ptr++;
                memcpy(ptr, dirent->ext, 3);
-               if (dirent->lcase & CASE_LOWER_EXT)
-                       downcase(ptr, 3);
                ptr[3] = '\0';
                while (*ptr && *ptr != ' ')
                        ptr++;
@@ -149,6 +144,7 @@ static void get_name(dir_entry *dirent, char *s_name)
                *s_name = '\0';
        else if (*s_name == aRING)
                *s_name = DELETED_FLAG;
+       downcase(s_name);
 }
 
 static int flush_dirty_fat_buffer(fsdata *mydata);
index 9d2e0ed74c8c7ced6e42759c5f0e39de5349d828..c2151e385cdd33d6325a4fe954824ad3c87368a1 100644 (file)
@@ -345,7 +345,7 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster,
                *l_name = '\0';
        else if (*l_name == aRING)
                *l_name = DELETED_FLAG;
-       downcase(l_name, INT_MAX);
+       downcase(l_name);
 
        /* Return the real directory entry */
        *retdent = realdent;
@@ -979,7 +979,7 @@ static int do_fat_write(const char *filename, void *buffer, loff_t size,
 
        memcpy(l_filename, filename, name_len);
        l_filename[name_len] = 0; /* terminate the string */
-       downcase(l_filename, INT_MAX);
+       downcase(l_filename);
 
        startsect = mydata->rootdir_sect;
        retdent = find_directory_entry(mydata, startsect,
index bdeda95e6debebad99523451efdcc14f584d7e44..c41dfdebe10a9ef680dfdec54de46c38754f62a0 100644 (file)
@@ -128,14 +128,10 @@ typedef struct volume_info
        /* Boot sign comes last, 2 bytes */
 } volume_info;
 
-/* see dir_entry::lcase: */
-#define CASE_LOWER_BASE        8       /* base (name) is lower case */
-#define CASE_LOWER_EXT 16      /* extension is lower case */
-
 typedef struct dir_entry {
        char    name[8],ext[3]; /* Name and extension */
        __u8    attr;           /* Attribute bits */
-       __u8    lcase;          /* Case for name and ext (CASE_LOWER_x) */
+       __u8    lcase;          /* Case for base and extension */
        __u8    ctime_ms;       /* Creation time, milliseconds */
        __u16   ctime;          /* Creation time */
        __u16   cdate;          /* Creation date */