diff options
Diffstat (limited to 'fs/vfat/namei.c')
-rw-r--r-- | fs/vfat/namei.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index 467346b123d9..ef46939c0c1a 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -887,10 +887,10 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
887 | { | 887 | { |
888 | struct buffer_head *dotdot_bh; | 888 | struct buffer_head *dotdot_bh; |
889 | struct msdos_dir_entry *dotdot_de; | 889 | struct msdos_dir_entry *dotdot_de; |
890 | loff_t dotdot_i_pos; | ||
891 | struct inode *old_inode, *new_inode; | 890 | struct inode *old_inode, *new_inode; |
892 | struct fat_slot_info old_sinfo, sinfo; | 891 | struct fat_slot_info old_sinfo, sinfo; |
893 | struct timespec ts; | 892 | struct timespec ts; |
893 | loff_t dotdot_i_pos, new_i_pos; | ||
894 | int err, is_dir, update_dotdot, corrupt = 0; | 894 | int err, is_dir, update_dotdot, corrupt = 0; |
895 | 895 | ||
896 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; | 896 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; |
@@ -913,31 +913,24 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
913 | 913 | ||
914 | ts = CURRENT_TIME_SEC; | 914 | ts = CURRENT_TIME_SEC; |
915 | if (new_inode) { | 915 | if (new_inode) { |
916 | err = vfat_find(new_dir, &new_dentry->d_name, &sinfo); | ||
917 | if (err) | ||
918 | goto out; | ||
919 | if (MSDOS_I(new_inode)->i_pos != sinfo.i_pos) { | ||
920 | /* WTF??? Cry and fail. */ | ||
921 | printk(KERN_WARNING "vfat_rename: fs corrupted\n"); | ||
922 | goto out; | ||
923 | } | ||
924 | |||
925 | if (is_dir) { | 916 | if (is_dir) { |
926 | err = fat_dir_empty(new_inode); | 917 | err = fat_dir_empty(new_inode); |
927 | if (err) | 918 | if (err) |
928 | goto out; | 919 | goto out; |
929 | } | 920 | } |
921 | new_i_pos = MSDOS_I(new_inode)->i_pos; | ||
930 | fat_detach(new_inode); | 922 | fat_detach(new_inode); |
931 | } else { | 923 | } else { |
932 | err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0, | 924 | err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0, |
933 | &ts, &sinfo); | 925 | &ts, &sinfo); |
934 | if (err) | 926 | if (err) |
935 | goto out; | 927 | goto out; |
928 | new_i_pos = sinfo.i_pos; | ||
936 | } | 929 | } |
937 | new_dir->i_version++; | 930 | new_dir->i_version++; |
938 | 931 | ||
939 | fat_detach(old_inode); | 932 | fat_detach(old_inode); |
940 | fat_attach(old_inode, sinfo.i_pos); | 933 | fat_attach(old_inode, new_i_pos); |
941 | if (IS_DIRSYNC(new_dir)) { | 934 | if (IS_DIRSYNC(new_dir)) { |
942 | err = fat_sync_inode(old_inode); | 935 | err = fat_sync_inode(old_inode); |
943 | if (err) | 936 | if (err) |
@@ -1001,7 +994,7 @@ error_inode: | |||
1001 | fat_detach(old_inode); | 994 | fat_detach(old_inode); |
1002 | fat_attach(old_inode, old_sinfo.i_pos); | 995 | fat_attach(old_inode, old_sinfo.i_pos); |
1003 | if (new_inode) { | 996 | if (new_inode) { |
1004 | fat_attach(new_inode, sinfo.i_pos); | 997 | fat_attach(new_inode, new_i_pos); |
1005 | if (corrupt) | 998 | if (corrupt) |
1006 | corrupt |= fat_sync_inode(new_inode); | 999 | corrupt |= fat_sync_inode(new_inode); |
1007 | } else { | 1000 | } else { |