diff options
Diffstat (limited to 'fs/vfat/namei.c')
-rw-r--r-- | fs/vfat/namei.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index 1c6f6b57ef1c..ef46939c0c1a 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -621,8 +621,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, | |||
621 | } | 621 | } |
622 | 622 | ||
623 | /* build the entry of long file name */ | 623 | /* build the entry of long file name */ |
624 | for (cksum = i = 0; i < 11; i++) | 624 | cksum = fat_checksum(msdos_name); |
625 | cksum = (((cksum&1)<<7)|((cksum&0xfe)>>1)) + msdos_name[i]; | ||
626 | 625 | ||
627 | *nr_slots = usize / 13; | 626 | *nr_slots = usize / 13; |
628 | for (ps = slots, i = *nr_slots; i > 0; i--, ps++) { | 627 | for (ps = slots, i = *nr_slots; i > 0; i--, ps++) { |
@@ -888,10 +887,10 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
888 | { | 887 | { |
889 | struct buffer_head *dotdot_bh; | 888 | struct buffer_head *dotdot_bh; |
890 | struct msdos_dir_entry *dotdot_de; | 889 | struct msdos_dir_entry *dotdot_de; |
891 | loff_t dotdot_i_pos; | ||
892 | struct inode *old_inode, *new_inode; | 890 | struct inode *old_inode, *new_inode; |
893 | struct fat_slot_info old_sinfo, sinfo; | 891 | struct fat_slot_info old_sinfo, sinfo; |
894 | struct timespec ts; | 892 | struct timespec ts; |
893 | loff_t dotdot_i_pos, new_i_pos; | ||
895 | int err, is_dir, update_dotdot, corrupt = 0; | 894 | int err, is_dir, update_dotdot, corrupt = 0; |
896 | 895 | ||
897 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; | 896 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; |
@@ -914,31 +913,24 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
914 | 913 | ||
915 | ts = CURRENT_TIME_SEC; | 914 | ts = CURRENT_TIME_SEC; |
916 | if (new_inode) { | 915 | if (new_inode) { |
917 | err = vfat_find(new_dir, &new_dentry->d_name, &sinfo); | ||
918 | if (err) | ||
919 | goto out; | ||
920 | if (MSDOS_I(new_inode)->i_pos != sinfo.i_pos) { | ||
921 | /* WTF??? Cry and fail. */ | ||
922 | printk(KERN_WARNING "vfat_rename: fs corrupted\n"); | ||
923 | goto out; | ||
924 | } | ||
925 | |||
926 | if (is_dir) { | 916 | if (is_dir) { |
927 | err = fat_dir_empty(new_inode); | 917 | err = fat_dir_empty(new_inode); |
928 | if (err) | 918 | if (err) |
929 | goto out; | 919 | goto out; |
930 | } | 920 | } |
921 | new_i_pos = MSDOS_I(new_inode)->i_pos; | ||
931 | fat_detach(new_inode); | 922 | fat_detach(new_inode); |
932 | } else { | 923 | } else { |
933 | 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, |
934 | &ts, &sinfo); | 925 | &ts, &sinfo); |
935 | if (err) | 926 | if (err) |
936 | goto out; | 927 | goto out; |
928 | new_i_pos = sinfo.i_pos; | ||
937 | } | 929 | } |
938 | new_dir->i_version++; | 930 | new_dir->i_version++; |
939 | 931 | ||
940 | fat_detach(old_inode); | 932 | fat_detach(old_inode); |
941 | fat_attach(old_inode, sinfo.i_pos); | 933 | fat_attach(old_inode, new_i_pos); |
942 | if (IS_DIRSYNC(new_dir)) { | 934 | if (IS_DIRSYNC(new_dir)) { |
943 | err = fat_sync_inode(old_inode); | 935 | err = fat_sync_inode(old_inode); |
944 | if (err) | 936 | if (err) |
@@ -1002,7 +994,7 @@ error_inode: | |||
1002 | fat_detach(old_inode); | 994 | fat_detach(old_inode); |
1003 | fat_attach(old_inode, old_sinfo.i_pos); | 995 | fat_attach(old_inode, old_sinfo.i_pos); |
1004 | if (new_inode) { | 996 | if (new_inode) { |
1005 | fat_attach(new_inode, sinfo.i_pos); | 997 | fat_attach(new_inode, new_i_pos); |
1006 | if (corrupt) | 998 | if (corrupt) |
1007 | corrupt |= fat_sync_inode(new_inode); | 999 | corrupt |= fat_sync_inode(new_inode); |
1008 | } else { | 1000 | } else { |