aboutsummaryrefslogtreecommitdiffstats
path: root/fs/msdos/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/msdos/namei.c')
-rw-r--r--fs/msdos/namei.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c
index 154f511c7245..626a367bcd81 100644
--- a/fs/msdos/namei.c
+++ b/fs/msdos/namei.c
@@ -454,10 +454,10 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
454{ 454{
455 struct buffer_head *dotdot_bh; 455 struct buffer_head *dotdot_bh;
456 struct msdos_dir_entry *dotdot_de; 456 struct msdos_dir_entry *dotdot_de;
457 loff_t dotdot_i_pos;
458 struct inode *old_inode, *new_inode; 457 struct inode *old_inode, *new_inode;
459 struct fat_slot_info old_sinfo, sinfo; 458 struct fat_slot_info old_sinfo, sinfo;
460 struct timespec ts; 459 struct timespec ts;
460 loff_t dotdot_i_pos, new_i_pos;
461 int err, old_attrs, is_dir, update_dotdot, corrupt = 0; 461 int err, old_attrs, is_dir, update_dotdot, corrupt = 0;
462 462
463 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; 463 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
@@ -516,28 +516,24 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
516 if (new_inode) { 516 if (new_inode) {
517 if (err) 517 if (err)
518 goto out; 518 goto out;
519 if (MSDOS_I(new_inode)->i_pos != sinfo.i_pos) {
520 /* WTF??? Cry and fail. */
521 printk(KERN_WARNING "msdos_rename: fs corrupted\n");
522 goto out;
523 }
524
525 if (is_dir) { 519 if (is_dir) {
526 err = fat_dir_empty(new_inode); 520 err = fat_dir_empty(new_inode);
527 if (err) 521 if (err)
528 goto out; 522 goto out;
529 } 523 }
524 new_i_pos = MSDOS_I(new_inode)->i_pos;
530 fat_detach(new_inode); 525 fat_detach(new_inode);
531 } else { 526 } else {
532 err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0, 527 err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0,
533 &ts, &sinfo); 528 &ts, &sinfo);
534 if (err) 529 if (err)
535 goto out; 530 goto out;
531 new_i_pos = sinfo.i_pos;
536 } 532 }
537 new_dir->i_version++; 533 new_dir->i_version++;
538 534
539 fat_detach(old_inode); 535 fat_detach(old_inode);
540 fat_attach(old_inode, sinfo.i_pos); 536 fat_attach(old_inode, new_i_pos);
541 if (is_hid) 537 if (is_hid)
542 MSDOS_I(old_inode)->i_attrs |= ATTR_HIDDEN; 538 MSDOS_I(old_inode)->i_attrs |= ATTR_HIDDEN;
543 else 539 else
@@ -604,7 +600,7 @@ error_inode:
604 fat_attach(old_inode, old_sinfo.i_pos); 600 fat_attach(old_inode, old_sinfo.i_pos);
605 MSDOS_I(old_inode)->i_attrs = old_attrs; 601 MSDOS_I(old_inode)->i_attrs = old_attrs;
606 if (new_inode) { 602 if (new_inode) {
607 fat_attach(new_inode, sinfo.i_pos); 603 fat_attach(new_inode, new_i_pos);
608 if (corrupt) 604 if (corrupt)
609 corrupt |= fat_sync_inode(new_inode); 605 corrupt |= fat_sync_inode(new_inode);
610 } else { 606 } else {