diff options
| author | Andrew Morton <akpm@osdl.org> | 2003-12-29 23:46:05 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-12-29 23:46:05 -0800 |
| commit | 26b885870f5c67d704cfa40a65a6379db7c2182f (patch) | |
| tree | efddf228c6b37d423d71d45649a756e8c920066c | |
| parent | 86b94f842fe3886c96ae7a3201d5cfc04dea6b53 (diff) | |
[PATCH] FAT: empty path by fat_striptail_len returns the -ENOENT
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
If path length became zero by fat_striptail_len(), this returns the -ENOENT
as empty path.
| -rw-r--r-- | fs/vfat/namei.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index dd928874c297..7085ac36c9d7 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) |
