From: OGAWA Hirofumi , From Rene Scharfe Fix error code. Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton --- 25-akpm/fs/vfat/namei.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff -puN fs/vfat/namei.c~fat-return-better-error-codes-from fs/vfat/namei.c --- 25/fs/vfat/namei.c~fat-return-better-error-codes-from Tue Jan 18 14:53:39 2005 +++ 25-akpm/fs/vfat/namei.c Tue Jan 18 14:53:39 2005 @@ -189,10 +189,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 */ @@ -200,18 +200,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) @@ -614,8 +614,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; _