Subject: UMSDOS-0.2_rename_f_fix

From: Michael Leodolter <[email-masked]>
Date: Fri, 18 Mar 94 13:38:10 MEZ

----------------------------Original message----------------------------
X-Mn-Key: normal

The following diff is a fix for a umsdos rename bug if the taget
exists and has different mode
        (Exp.: co -u test.c ; co -l test.c

        or

        before  "mv _Zdddd test.c"
          -rw-r--r--   1 michael  devel         471 Mar 17 22:25 _Zdddd
          -r--r--r--   1 michael  devel         471 Mar 17 22:25 test.c

        after   "mv _Zdddd test.c"
          -r--r--r--   1 michael  devel         471 Mar 17 22:25 test.c).

!!! umsdos_newentry fills the new_info with old if found !!!

--- diff ----
cd /usr/src/linux/fs/umsdos/
diff -c /usr/src/linux/fs/umsdos/namei.c.0.2 /usr/src/linux/fs/umsdos/namei.c
*** /usr/src/linux/fs/umsdos/namei.c.0.2        Sun Mar 13 14:28:13 1994
--- /usr/src/linux/fs/umsdos/namei.c    Thu Mar 17 22:16:07 1994
***************
*** 298,303 ****
--- 298,304 ----
        struct umsdos_info old_info;
        int old_ret = umsdos_parse (old_name,old_len,&old_info);
        struct umsdos_info new_info;
+       struct umsdos_info new_info_save;
        int new_ret = umsdos_parse (new_name,new_len,&new_info);
        PRINTK (("umsdos_rename %d %d ",old_ret,new_ret));
        if (old_ret == 0 && new_ret == 0){
***************
*** 316,324 ****
--- 317,329 ----
                        new_info.entry.mtime = old_info.entry.mtime;
                        new_info.entry.flags = flags ? flags :
old_info.entry.flags;
                        new_info.entry.nlink = old_info.entry.nlink;
+                       /* save if newentry fails */
+                       memcpy (&new_info_save, &new_info, sizeof(new_info));
                        ret = umsdos_newentry (new_dir,&new_info);
                        PRINTK (("ret %d %d ",ret,new_info.fake.len));
                        if (ret == -EEXIST){
+                         /* restore if newentry fails */
+                         memcpy (&new_info, &new_info_save, sizeof(new_info));
                                /* #Specification: rename / new name exist
                                        If the destination name already exist,
it will
                                        silently be removed. EXT2 does it this
way

Diff finished at Thu Mar 17 22:35:06

--- diff end ---

Good luck!

michael