From 26b885870f5c67d704cfa40a65a6379db7c2182f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 29 Dec 2003 23:46:05 -0800 Subject: [PATCH] [PATCH] FAT: empty path by fat_striptail_len returns the -ENOENT From: OGAWA Hirofumi If path length became zero by fat_striptail_len(), this returns the -ENOENT as empty path. --- fs/vfat/namei.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index dd928874c2974..7085ac36c9d71 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c @@ -739,18 +739,22 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname, { struct msdos_dir_slot *dir_slots; loff_t offset; - int slots, slot; - int res; + int res, slots, slot; + unsigned int len; struct msdos_dir_entry *dummy_de; struct buffer_head *dummy_bh; loff_t dummy_i_pos; - dir_slots = (struct msdos_dir_slot *) + len = vfat_striptail_len(qname); + if (len == 0) + return -ENOENT; + + dir_slots = kmalloc(sizeof(struct msdos_dir_slot) * MSDOS_SLOTS, GFP_KERNEL); if (dir_slots == NULL) return -ENOMEM; - res = vfat_build_slots(dir, qname->name, vfat_striptail_len(qname), + res = vfat_build_slots(dir, qname->name, len, dir_slots, &slots, is_dir); if (res < 0) goto cleanup; @@ -801,11 +805,16 @@ static int vfat_find(struct inode *dir,struct qstr* qname, { struct super_block *sb = dir->i_sb; loff_t offset; + unsigned int len; int res; - res = fat_search_long(dir, qname->name, vfat_striptail_len(qname), - (MSDOS_SB(sb)->options.name_check != 's'), - &offset,&sinfo->longname_offset); + len = vfat_striptail_len(qname); + if (len == 0) + return -ENOENT; + + res = fat_search_long(dir, qname->name, len, + (MSDOS_SB(sb)->options.name_check != 's'), + &offset, &sinfo->longname_offset); if (res>0) { sinfo->long_slots = res-1; if (fat_get_entry(dir,&offset,last_bh,last_de,&sinfo->i_pos)>=0) -- 2.53.0