[PATCH 4/13] FAT: Return better error codes fromvfat_valid_longname()

From: OGAWA Hirofumi
Date: Mon Jan 17 2005 - 12:49:08 EST



Fix error code.

From Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx>

Signed-off-by: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
---

fs/vfat/namei.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)

diff -puN fs/vfat/namei.c~fat_nametoolong fs/vfat/namei.c
--- linux-2.6.10/fs/vfat/namei.c~fat_nametoolong 2005-01-08 09:07:53.000000000 +0900
+++ linux-2.6.10-hirofumi/fs/vfat/namei.c 2005-01-08 09:07:53.000000000 +0900
@@ -192,10 +192,10 @@ static inline int vfat_is_used_badchars(

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 */
@@ -203,18 +203,18 @@ static int vfat_valid_longname(const uns
!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)
@@ -617,8 +617,9 @@ static int vfat_build_slots(struct inode
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;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/