Commit 26b88587 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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.
parent 86b94f84
...@@ -739,18 +739,22 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname, ...@@ -739,18 +739,22 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname,
{ {
struct msdos_dir_slot *dir_slots; struct msdos_dir_slot *dir_slots;
loff_t offset; loff_t offset;
int slots, slot; int res, slots, slot;
int res; unsigned int len;
struct msdos_dir_entry *dummy_de; struct msdos_dir_entry *dummy_de;
struct buffer_head *dummy_bh; struct buffer_head *dummy_bh;
loff_t dummy_i_pos; 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); kmalloc(sizeof(struct msdos_dir_slot) * MSDOS_SLOTS, GFP_KERNEL);
if (dir_slots == NULL) if (dir_slots == NULL)
return -ENOMEM; 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); dir_slots, &slots, is_dir);
if (res < 0) if (res < 0)
goto cleanup; goto cleanup;
...@@ -801,11 +805,16 @@ static int vfat_find(struct inode *dir,struct qstr* qname, ...@@ -801,11 +805,16 @@ static int vfat_find(struct inode *dir,struct qstr* qname,
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
loff_t offset; loff_t offset;
unsigned int len;
int res; int res;
res = fat_search_long(dir, qname->name, vfat_striptail_len(qname), len = vfat_striptail_len(qname);
(MSDOS_SB(sb)->options.name_check != 's'), if (len == 0)
&offset,&sinfo->longname_offset); return -ENOENT;
res = fat_search_long(dir, qname->name, len,
(MSDOS_SB(sb)->options.name_check != 's'),
&offset, &sinfo->longname_offset);
if (res>0) { if (res>0) {
sinfo->long_slots = res-1; sinfo->long_slots = res-1;
if (fat_get_entry(dir,&offset,last_bh,last_de,&sinfo->i_pos)>=0) if (fat_get_entry(dir,&offset,last_bh,last_de,&sinfo->i_pos)>=0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment