]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fat: Return better error codes from vfat_valid_longname()
authorHirofumi Ogawa <hirofumi@mail.parknet.co.jp>
Fri, 21 Jan 2005 00:12:30 +0000 (16:12 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 21 Jan 2005 00:12:30 +0000 (16:12 -0800)
From Rene Scharfe <rene.scharfe@lsrfire.ath.cx>

Fix error code.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/vfat/namei.c

index a3b34edc3f4fbea190de8b49a17b92fe0a115574..c492db87a0a3fa2fd8def96ae4c5dd1667ee884b 100644 (file)
@@ -189,10 +189,10 @@ static inline int vfat_is_used_badchars(const wchar_t *s, int len)
 
 static int vfat_valid_longname(const unsigned char *name, unsigned int len)
 {
-       if (len && name[len-1] == ' ')
-               return 0;
+       if (name[len - 1] == ' ')
+               return -EINVAL;
        if (len >= 256)
-               return 0;
+               return -ENAMETOOLONG;
 
        /* MS-DOS "device special files" */
        if (len == 3 || (len > 3 && name[3] == '.')) {  /* basename == 3 */
@@ -200,18 +200,18 @@ static int vfat_valid_longname(const unsigned char *name, unsigned int len)
                    !strnicmp(name, "con", 3) ||
                    !strnicmp(name, "nul", 3) ||
                    !strnicmp(name, "prn", 3))
-                       return 0;
+                       return -EINVAL;
        }
        if (len == 4 || (len > 4 && name[4] == '.')) {  /* basename == 4 */
                /* "com1", "com2", ... */
                if ('1' <= name[3] && name[3] <= '9') {
                        if (!strnicmp(name, "com", 3) ||
                            !strnicmp(name, "lpt", 3))
-                               return 0;
+                               return -EINVAL;
                }
        }
 
-       return 1;
+       return 0;
 }
 
 static int vfat_find_form(struct inode *dir, unsigned char *name)
@@ -614,8 +614,9 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
        loff_t offset;
 
        *slots = 0;
-       if (!vfat_valid_longname(name, len))
-               return -EINVAL;
+       res = vfat_valid_longname(name, len);
+       if (res)
+               return res;
 
        if(!(page = __get_free_page(GFP_KERNEL)))
                return -ENOMEM;