Commit 8085a453 authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] fat: Lindent fs/vfat/namei.c

Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ae0caa23
...@@ -25,33 +25,6 @@ ...@@ -25,33 +25,6 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/namei.h> #include <linux/namei.h>
static int vfat_hashi(struct dentry *parent, struct qstr *qstr);
static int vfat_hash(struct dentry *parent, struct qstr *qstr);
static int vfat_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b);
static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b);
static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd);
static struct dentry_operations vfat_dentry_ops[4] = {
{
.d_hash = vfat_hashi,
.d_compare = vfat_cmpi,
},
{
.d_revalidate = vfat_revalidate,
.d_hash = vfat_hashi,
.d_compare = vfat_cmpi,
},
{
.d_hash = vfat_hash,
.d_compare = vfat_cmp,
},
{
.d_revalidate = vfat_revalidate,
.d_hash = vfat_hash,
.d_compare = vfat_cmp,
}
};
static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd) static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd)
{ {
int ret = 1; int ret = 1;
...@@ -78,9 +51,8 @@ static unsigned int vfat_striptail_len(struct qstr *qstr) ...@@ -78,9 +51,8 @@ static unsigned int vfat_striptail_len(struct qstr *qstr)
{ {
unsigned int len = qstr->len; unsigned int len = qstr->len;
while (len && qstr->name[len-1] == '.') while (len && qstr->name[len - 1] == '.')
len--; len--;
return len; return len;
} }
...@@ -93,7 +65,6 @@ static unsigned int vfat_striptail_len(struct qstr *qstr) ...@@ -93,7 +65,6 @@ static unsigned int vfat_striptail_len(struct qstr *qstr)
static int vfat_hash(struct dentry *dentry, struct qstr *qstr) static int vfat_hash(struct dentry *dentry, struct qstr *qstr)
{ {
qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr)); qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr));
return 0; return 0;
} }
...@@ -156,6 +127,27 @@ static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b) ...@@ -156,6 +127,27 @@ static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b)
return 1; return 1;
} }
static struct dentry_operations vfat_dentry_ops[4] = {
{
.d_hash = vfat_hashi,
.d_compare = vfat_cmpi,
},
{
.d_revalidate = vfat_revalidate,
.d_hash = vfat_hashi,
.d_compare = vfat_cmpi,
},
{
.d_hash = vfat_hash,
.d_compare = vfat_cmp,
},
{
.d_revalidate = vfat_revalidate,
.d_hash = vfat_hash,
.d_compare = vfat_cmp,
}
};
/* Characters that are undesirable in an MS-DOS file name */ /* Characters that are undesirable in an MS-DOS file name */
static inline wchar_t vfat_bad_char(wchar_t w) static inline wchar_t vfat_bad_char(wchar_t w)
...@@ -260,8 +252,8 @@ struct shortname_info { ...@@ -260,8 +252,8 @@ struct shortname_info {
} while (0) } while (0)
static inline int to_shortname_char(struct nls_table *nls, static inline int to_shortname_char(struct nls_table *nls,
unsigned char *buf, int buf_size, wchar_t *src, unsigned char *buf, int buf_size,
struct shortname_info *info) wchar_t *src, struct shortname_info *info)
{ {
int len; int len;
...@@ -358,7 +350,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls, ...@@ -358,7 +350,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
ext_start++; ext_start++;
} else { } else {
sz = ulen; sz = ulen;
ext_start=NULL; ext_start = NULL;
} }
} }
...@@ -374,7 +366,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls, ...@@ -374,7 +366,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
numtail2_baselen = baselen; numtail2_baselen = baselen;
if (baselen < 6 && (baselen + chl) > 6) if (baselen < 6 && (baselen + chl) > 6)
numtail_baselen = baselen; numtail_baselen = baselen;
for (chi = 0; chi < chl; chi++){ for (chi = 0; chi < chl; chi++) {
*p++ = charbuf[chi]; *p++ = charbuf[chi];
baselen++; baselen++;
if (baselen >= 8) if (baselen >= 8)
...@@ -462,25 +454,25 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls, ...@@ -462,25 +454,25 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
* values for part of the base. * values for part of the base.
*/ */
if (baselen>6) { if (baselen > 6) {
baselen = numtail_baselen; baselen = numtail_baselen;
name_res[7] = ' '; name_res[7] = ' ';
} }
name_res[baselen] = '~'; name_res[baselen] = '~';
for (i = 1; i < 10; i++) { for (i = 1; i < 10; i++) {
name_res[baselen+1] = i + '0'; name_res[baselen + 1] = i + '0';
if (vfat_find_form(dir, name_res) < 0) if (vfat_find_form(dir, name_res) < 0)
return 0; return 0;
} }
i = jiffies & 0xffff; i = jiffies & 0xffff;
sz = (jiffies >> 16) & 0x7; sz = (jiffies >> 16) & 0x7;
if (baselen>2) { if (baselen > 2) {
baselen = numtail2_baselen; baselen = numtail2_baselen;
name_res[7] = ' '; name_res[7] = ' ';
} }
name_res[baselen+4] = '~'; name_res[baselen + 4] = '~';
name_res[baselen+5] = '1' + sz; name_res[baselen + 5] = '1' + sz;
while (1) { while (1) {
sprintf(buf, "%04X", i); sprintf(buf, "%04X", i);
memcpy(&name_res[baselen], buf, 4); memcpy(&name_res[baselen], buf, 4);
...@@ -513,13 +505,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -513,13 +505,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
* We stripped '.'s before and set len appropriately, * We stripped '.'s before and set len appropriately,
* but utf8_mbstowcs doesn't care about len * but utf8_mbstowcs doesn't care about len
*/ */
*outlen -= (name_len-len); *outlen -= (name_len - len);
op = &outname[*outlen * sizeof(wchar_t)]; op = &outname[*outlen * sizeof(wchar_t)];
} else { } else {
if (nls) { if (nls) {
for (i = 0, ip = name, op = outname, *outlen = 0; for (i = 0, ip = name, op = outname, *outlen = 0;
i < len && *outlen <= 260; *outlen += 1) i < len && *outlen <= 260;
*outlen += 1)
{ {
if (escape && (*ip == ':')) { if (escape && (*ip == ':')) {
if (i > len - 5) if (i > len - 5)
...@@ -547,7 +540,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -547,7 +540,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
ip += 5; ip += 5;
i += 5; i += 5;
} else { } else {
if ((charlen = nls->char2uni(ip, len-i, (wchar_t *)op)) < 0) if ((charlen = nls->char2uni(ip, len - i, (wchar_t *)op)) < 0)
return -EINVAL; return -EINVAL;
ip += charlen; ip += charlen;
i += charlen; i += charlen;
...@@ -556,7 +549,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -556,7 +549,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
} }
} else { } else {
for (i = 0, ip = name, op = outname, *outlen = 0; for (i = 0, ip = name, op = outname, *outlen = 0;
i < len && *outlen <= 260; i++, *outlen += 1) i < len && *outlen <= 260;
i++, *outlen += 1)
{ {
*op++ = *ip++; *op++ = *ip++;
*op++ = 0; *op++ = 0;
...@@ -604,7 +598,8 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -604,7 +598,8 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
if (res) if (res)
return res; return res;
if(!(page = __get_free_page(GFP_KERNEL))) page = __get_free_page(GFP_KERNEL);
if (!page)
return -ENOMEM; return -ENOMEM;
uname = (wchar_t *)page; uname = (wchar_t *)page;
...@@ -629,9 +624,8 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -629,9 +624,8 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
/* build the entry of long file name */ /* build the entry of long file name */
*slots = usize / 13; *slots = usize / 13;
for (cksum = i = 0; i < 11; i++) { for (cksum = i = 0; i < 11; i++)
cksum = (((cksum&1)<<7)|((cksum&0xfe)>>1)) + msdos_name[i]; cksum = (((cksum&1)<<7)|((cksum&0xfe)>>1)) + msdos_name[i];
}
for (ps = ds, slot = *slots; slot > 0; slot--, ps++) { for (ps = ds, slot = *slots; slot > 0; slot--, ps++) {
ps->id = slot; ps->id = slot;
...@@ -645,7 +639,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -645,7 +639,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
fatwchar_to16(ps->name11_12, uname + offset + 11, 2); fatwchar_to16(ps->name11_12, uname + offset + 11, 2);
} }
ds[0].id |= 0x40; ds[0].id |= 0x40;
de = (struct msdos_dir_entry *) ps; de = (struct msdos_dir_entry *)ps;
shortname: shortname:
/* build the entry of 8.3 alias name */ /* build the entry of 8.3 alias name */
...@@ -665,7 +659,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, ...@@ -665,7 +659,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
return res; return res;
} }
static int vfat_add_entry(struct inode *dir,struct qstr* qname, static int vfat_add_entry(struct inode *dir, struct qstr *qname,
int is_dir, struct vfat_slot_info *sinfo_out, int is_dir, struct vfat_slot_info *sinfo_out,
struct buffer_head **bh, struct msdos_dir_entry **de) struct buffer_head **bh, struct msdos_dir_entry **de)
{ {
...@@ -681,8 +675,7 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname, ...@@ -681,8 +675,7 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname,
if (len == 0) if (len == 0)
return -ENOENT; return -ENOENT;
dir_slots = dir_slots = kmalloc(sizeof(*dir_slots) * 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;
...@@ -692,7 +685,8 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname, ...@@ -692,7 +685,8 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname,
goto cleanup; goto cleanup;
/* build the empty directory entry of number of slots */ /* build the empty directory entry of number of slots */
offset = fat_add_entries(dir, slots, &dummy_bh, &dummy_de, &dummy_i_pos); offset =
fat_add_entries(dir, slots, &dummy_bh, &dummy_de, &dummy_i_pos);
if (offset < 0) { if (offset < 0) {
res = offset; res = offset;
goto cleanup; goto cleanup;
...@@ -732,7 +726,7 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname, ...@@ -732,7 +726,7 @@ static int vfat_add_entry(struct inode *dir,struct qstr* qname,
return res; return res;
} }
static int vfat_find(struct inode *dir,struct qstr* qname, static int vfat_find(struct inode *dir, struct qstr *qname,
struct vfat_slot_info *sinfo, struct buffer_head **last_bh, struct vfat_slot_info *sinfo, struct buffer_head **last_bh,
struct msdos_dir_entry **last_de) struct msdos_dir_entry **last_de)
{ {
...@@ -748,9 +742,9 @@ static int vfat_find(struct inode *dir,struct qstr* qname, ...@@ -748,9 +742,9 @@ static int vfat_find(struct inode *dir,struct qstr* qname,
res = fat_search_long(dir, qname->name, len, res = fat_search_long(dir, qname->name, len,
(MSDOS_SB(sb)->options.name_check != 's'), (MSDOS_SB(sb)->options.name_check != 's'),
&offset, &sinfo->longname_offset); &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)
return 0; return 0;
res = -EIO; res = -EIO;
} }
...@@ -773,7 +767,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -773,7 +767,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
dentry->d_op = &vfat_dentry_ops[table]; dentry->d_op = &vfat_dentry_ops[table];
inode = NULL; inode = NULL;
res = vfat_find(dir,&dentry->d_name,&sinfo,&bh,&de); res = vfat_find(dir, &dentry->d_name, &sinfo, &bh, &de);
if (res < 0) { if (res < 0) {
table++; table++;
goto error; goto error;
...@@ -786,7 +780,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -786,7 +780,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
} }
alias = d_find_alias(inode); alias = d_find_alias(inode);
if (alias) { if (alias) {
if (d_invalidate(alias)==0) if (d_invalidate(alias) == 0)
dput(alias); dput(alias);
else { else {
iput(inode); iput(inode);
...@@ -807,7 +801,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -807,7 +801,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
return dentry; return dentry;
} }
static int vfat_create(struct inode *dir, struct dentry* dentry, int mode, static int vfat_create(struct inode *dir, struct dentry *dentry, int mode,
struct nameidata *nd) struct nameidata *nd)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
...@@ -831,14 +825,15 @@ static int vfat_create(struct inode *dir, struct dentry* dentry, int mode, ...@@ -831,14 +825,15 @@ static int vfat_create(struct inode *dir, struct dentry* dentry, int mode,
inode->i_version++; inode->i_version++;
dir->i_version++; dir->i_version++;
dentry->d_time = dentry->d_parent->d_inode->i_version; dentry->d_time = dentry->d_parent->d_inode->i_version;
d_instantiate(dentry,inode); d_instantiate(dentry, inode);
out: out:
unlock_kernel(); unlock_kernel();
return res; return res;
} }
static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo, static void vfat_remove_entry(struct inode *dir, struct vfat_slot_info *sinfo,
struct buffer_head *bh, struct msdos_dir_entry *de) struct buffer_head *bh,
struct msdos_dir_entry *de)
{ {
loff_t offset, i_pos; loff_t offset, i_pos;
int i; int i;
...@@ -850,7 +845,8 @@ static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo, ...@@ -850,7 +845,8 @@ static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo,
de->name[0] = DELETED_FLAG; de->name[0] = DELETED_FLAG;
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
/* remove the longname */ /* remove the longname */
offset = sinfo->longname_offset; de = NULL; offset = sinfo->longname_offset;
de = NULL;
for (i = sinfo->long_slots; i > 0; --i) { for (i = sinfo->long_slots; i > 0; --i) {
if (fat_get_entry(dir, &offset, &bh, &de, &i_pos) < 0) if (fat_get_entry(dir, &offset, &bh, &de, &i_pos) < 0)
continue; continue;
...@@ -861,28 +857,30 @@ static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo, ...@@ -861,28 +857,30 @@ static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo,
brelse(bh); brelse(bh);
} }
static int vfat_rmdir(struct inode *dir, struct dentry* dentry) static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
{ {
int res; struct inode *inode = dentry->d_inode;
struct vfat_slot_info sinfo; struct vfat_slot_info sinfo;
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
struct msdos_dir_entry *de; struct msdos_dir_entry *de;
int res;
lock_kernel(); lock_kernel();
res = fat_dir_empty(dentry->d_inode); res = fat_dir_empty(inode);
if (res) if (res)
goto out; goto out;
res = vfat_find(dir,&dentry->d_name,&sinfo, &bh, &de); res = vfat_find(dir, &dentry->d_name, &sinfo, &bh, &de);
if (res < 0) if (res < 0)
goto out; goto out;
res = 0; res = 0;
dentry->d_inode->i_nlink = 0; inode->i_nlink = 0;
dentry->d_inode->i_mtime = dentry->d_inode->i_atime = CURRENT_TIME_SEC; inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
fat_detach(dentry->d_inode); fat_detach(inode);
mark_inode_dirty(dentry->d_inode); mark_inode_dirty(inode);
/* releases bh */ /* releases bh */
vfat_remove_entry(dir,&sinfo,bh,de); vfat_remove_entry(dir, &sinfo, bh, de);
dir->i_nlink--; dir->i_nlink--;
out: out:
unlock_kernel(); unlock_kernel();
...@@ -891,28 +889,29 @@ static int vfat_rmdir(struct inode *dir, struct dentry* dentry) ...@@ -891,28 +889,29 @@ static int vfat_rmdir(struct inode *dir, struct dentry* dentry)
static int vfat_unlink(struct inode *dir, struct dentry *dentry) static int vfat_unlink(struct inode *dir, struct dentry *dentry)
{ {
int res; struct inode *inode = dentry->d_inode;
struct vfat_slot_info sinfo; struct vfat_slot_info sinfo;
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
struct msdos_dir_entry *de; struct msdos_dir_entry *de;
int res;
lock_kernel(); lock_kernel();
res = vfat_find(dir,&dentry->d_name,&sinfo,&bh,&de); res = vfat_find(dir, &dentry->d_name, &sinfo, &bh, &de);
if (res < 0) if (res < 0)
goto out; goto out;
dentry->d_inode->i_nlink = 0; inode->i_nlink = 0;
dentry->d_inode->i_mtime = dentry->d_inode->i_atime = CURRENT_TIME_SEC; inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
fat_detach(dentry->d_inode); fat_detach(inode);
mark_inode_dirty(dentry->d_inode); mark_inode_dirty(inode);
/* releases bh */ /* releases bh */
vfat_remove_entry(dir,&sinfo,bh,de); vfat_remove_entry(dir, &sinfo, bh, de);
out: out:
unlock_kernel(); unlock_kernel();
return res; return res;
} }
static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode) static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
struct inode *inode = NULL; struct inode *inode = NULL;
...@@ -938,7 +937,7 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode) ...@@ -938,7 +937,7 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode)
if (res < 0) if (res < 0)
goto mkdir_failed; goto mkdir_failed;
dentry->d_time = dentry->d_parent->d_inode->i_version; dentry->d_time = dentry->d_parent->d_inode->i_version;
d_instantiate(dentry,inode); d_instantiate(dentry, inode);
out_brelse: out_brelse:
brelse(bh); brelse(bh);
out: out:
...@@ -951,7 +950,7 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode) ...@@ -951,7 +950,7 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode)
fat_detach(inode); fat_detach(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
/* releases bh */ /* releases bh */
vfat_remove_entry(dir,&sinfo,bh,de); vfat_remove_entry(dir, &sinfo, bh, de);
iput(inode); iput(inode);
dir->i_nlink--; dir->i_nlink--;
goto out; goto out;
...@@ -960,18 +959,19 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode) ...@@ -960,18 +959,19 @@ static int vfat_mkdir(struct inode *dir,struct dentry* dentry,int mode)
static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry) struct inode *new_dir, struct dentry *new_dentry)
{ {
struct buffer_head *old_bh,*new_bh,*dotdot_bh; struct buffer_head *old_bh, *new_bh, *dotdot_bh;
struct msdos_dir_entry *old_de,*new_de,*dotdot_de; struct msdos_dir_entry *old_de, *new_de, *dotdot_de;
loff_t dotdot_i_pos; loff_t dotdot_i_pos;
struct inode *old_inode, *new_inode; struct inode *old_inode, *new_inode;
int res, is_dir; int res, is_dir;
struct vfat_slot_info old_sinfo,sinfo; struct vfat_slot_info old_sinfo, sinfo;
old_bh = new_bh = dotdot_bh = NULL; old_bh = new_bh = dotdot_bh = NULL;
old_inode = old_dentry->d_inode; old_inode = old_dentry->d_inode;
new_inode = new_dentry->d_inode; new_inode = new_dentry->d_inode;
lock_kernel(); lock_kernel();
res = vfat_find(old_dir,&old_dentry->d_name,&old_sinfo,&old_bh,&old_de); res = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo, &old_bh,
&old_de);
if (res < 0) if (res < 0)
goto rename_done; goto rename_done;
...@@ -986,7 +986,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -986,7 +986,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
if (new_dentry->d_inode) { if (new_dentry->d_inode) {
res = vfat_find(new_dir,&new_dentry->d_name,&sinfo,&new_bh, res = vfat_find(new_dir, &new_dentry->d_name, &sinfo, &new_bh,
&new_de); &new_de);
if (res < 0 || MSDOS_I(new_inode)->i_pos != sinfo.i_pos) { if (res < 0 || MSDOS_I(new_inode)->i_pos != sinfo.i_pos) {
/* WTF??? Cry and fail. */ /* WTF??? Cry and fail. */
...@@ -1001,16 +1001,17 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1001,16 +1001,17 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
fat_detach(new_inode); fat_detach(new_inode);
} else { } else {
res = vfat_add_entry(new_dir,&new_dentry->d_name,is_dir,&sinfo, res = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir,
&new_bh,&new_de); &sinfo, &new_bh, &new_de);
if (res < 0) goto rename_done; if (res < 0)
goto rename_done;
} }
new_dir->i_version++; new_dir->i_version++;
/* releases old_bh */ /* releases old_bh */
vfat_remove_entry(old_dir,&old_sinfo,old_bh,old_de); vfat_remove_entry(old_dir, &old_sinfo, old_bh, old_de);
old_bh=NULL; old_bh = NULL;
fat_detach(old_inode); fat_detach(old_inode);
fat_attach(old_inode, sinfo.i_pos); fat_attach(old_inode, sinfo.i_pos);
mark_inode_dirty(old_inode); mark_inode_dirty(old_inode);
...@@ -1043,7 +1044,6 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1043,7 +1044,6 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
brelse(new_bh); brelse(new_bh);
unlock_kernel(); unlock_kernel();
return res; return res;
} }
static struct inode_operations vfat_dir_inode_operations = { static struct inode_operations vfat_dir_inode_operations = {
...@@ -1073,7 +1073,8 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1073,7 +1073,8 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)
} }
static struct super_block *vfat_get_sb(struct file_system_type *fs_type, static struct super_block *vfat_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data) int flags, const char *dev_name,
void *data)
{ {
return get_sb_bdev(fs_type, flags, dev_name, data, vfat_fill_super); return get_sb_bdev(fs_type, flags, dev_name, data, vfat_fill_super);
} }
......
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