Re: [PATCH] VFAT fixes (addition)

Alexander Viro (viro@math.psu.edu)
Fri, 15 Jan 1999 14:46:42 -0500 (EST)


Linus, I've made an additional cleanup of vfat_rename(). It's atop
of the last version I've sent to you. Now it does the right thing wrt
non-directory targets. Please, apply it too.
Al

--- linux/fs/vfat/namei.c.old Fri Jan 15 13:26:34 1999
+++ linux/fs/vfat/namei.c Fri Jan 15 14:00:47 1999
@@ -1387,10 +1387,8 @@
/* remove the longname */
offset = sinfo->longname_offset;
for (i = sinfo->long_slots; i > 0; --i) {
- res = fat_get_entry(dir, &offset, &bh, &de);
- if (res < 0) {
+ if (fat_get_entry(dir, &offset, &bh, &de) < 0)
continue;
- }
de->name[0] = DELETED_FLAG;
de->attr = 0;
fat_mark_buffer_dirty(sb, bh, 1);
@@ -1655,29 +1653,32 @@
res = vfat_empty(new_inode);
if (res)
goto rename_done;
- res = vfat_remove_entry(new_dir,&sinfo,new_inode);
- if (res)
- goto rename_done;
- new_dir->i_nlink--;
- d_delete(new_dentry);
} else {
- /* Plain d_drop() is safe here. */
- d_drop(new_dentry);
- res = vfat_unlink(new_dir,new_dentry);
- if (res)
- goto rename_done;
+ drop_aliases(new_dentry);
}
}
+ res = vfat_remove_entry(new_dir,&sinfo,new_inode);
+ if (res)
+ goto rename_done;
+
+ /* Serious lossage here. FAT uses braindead inode numbers scheme,
+ * so we can't simply cannibalize the entry. It means that we have
+ * no warranties that crash here will not make target disappear
+ * after reboot. Lose, lose. Nothing to do with that until we'll
+ * separate the functions of i_ino: it serves both as a search key
+ * in icache and as a part of stat output. It would kill all the
+ * 'busy' stuff on the spot. Later.
+ */
+
+ if (is_dir)
+ new_dir->i_nlink--;

- PRINTK3(("vfat_rename 11\n"));
res = vfat_find(new_dir,&new_dentry->d_name,1,is_dir,&sinfo);

- PRINTK3(("vfat_rename 12\n"));
if (res < 0) goto rename_done;

new_offset = sinfo.shortname_offset;
new_ino = sinfo.ino;
- PRINTK3(("vfat_rename 13: new_ino=%d\n", new_ino));

/* XXX: take care of other owners */

@@ -1703,7 +1704,7 @@
fat_mark_buffer_dirty(sb, old_bh, 1);
}

- if (S_ISDIR(old_inode->i_mode)) {
+ if (is_dir) {
if ((res = fat_scan(old_inode,MSDOS_DOTDOT,&dotdot_bh,
&dotdot_de,&dotdot_ino,SCAN_ANY)) < 0) goto rename_done;
if (!(dotdot_inode = iget(old_inode->i_sb,dotdot_ino))) {
@@ -1726,13 +1727,8 @@
}

if (res >= 0) {
- if (new_inode) {
- /* probably we should do it only for directories,
- * but that would require lambda-expanding the
- * call of vfat_unlink(). FIXME.
- */
+ if (new_inode && is_dir)
d_rehash(new_dentry);
- }
d_move(old_dentry, new_dentry);
res = 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/