Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / vfat / namei.c
index 1c6f6b5..a56cec3 100644 (file)
@@ -185,24 +185,6 @@ static int vfat_valid_longname(const unsigned char *name, unsigned int len)
                return -EINVAL;
        if (len >= 256)
                return -ENAMETOOLONG;
-
-       /* MS-DOS "device special files" */
-       if (len == 3 || (len > 3 && name[3] == '.')) {  /* basename == 3 */
-               if (!strnicmp(name, "aux", 3) ||
-                   !strnicmp(name, "con", 3) ||
-                   !strnicmp(name, "nul", 3) ||
-                   !strnicmp(name, "prn", 3))
-                       return -EINVAL;
-       }
-       if (len == 4 || (len > 4 && name[4] == '.')) {  /* basename == 4 */
-               /* "com1", "com2", ... */
-               if ('1' <= name[3] && name[3] <= '9') {
-                       if (!strnicmp(name, "com", 3) ||
-                           !strnicmp(name, "lpt", 3))
-                               return -EINVAL;
-               }
-       }
-
        return 0;
 }
 
@@ -621,8 +603,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
        }
 
        /* build the entry of long file name */
-       for (cksum = i = 0; i < 11; i++)
-               cksum = (((cksum&1)<<7)|((cksum&0xfe)>>1)) + msdos_name[i];
+       cksum = fat_checksum(msdos_name);
 
        *nr_slots = usize / 13;
        for (ps = slots, i = *nr_slots; i > 0; i--, ps++) {
@@ -888,10 +869,10 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 {
        struct buffer_head *dotdot_bh;
        struct msdos_dir_entry *dotdot_de;
-       loff_t dotdot_i_pos;
        struct inode *old_inode, *new_inode;
        struct fat_slot_info old_sinfo, sinfo;
        struct timespec ts;
+       loff_t dotdot_i_pos, new_i_pos;
        int err, is_dir, update_dotdot, corrupt = 0;
 
        old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
@@ -914,31 +895,24 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 
        ts = CURRENT_TIME_SEC;
        if (new_inode) {
-               err = vfat_find(new_dir, &new_dentry->d_name, &sinfo);
-               if (err)
-                       goto out;
-               if (MSDOS_I(new_inode)->i_pos != sinfo.i_pos) {
-                       /* WTF??? Cry and fail. */
-                       printk(KERN_WARNING "vfat_rename: fs corrupted\n");
-                       goto out;
-               }
-
                if (is_dir) {
                        err = fat_dir_empty(new_inode);
                        if (err)
                                goto out;
                }
+               new_i_pos = MSDOS_I(new_inode)->i_pos;
                fat_detach(new_inode);
        } else {
                err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0,
                                     &ts, &sinfo);
                if (err)
                        goto out;
+               new_i_pos = sinfo.i_pos;
        }
        new_dir->i_version++;
 
        fat_detach(old_inode);
-       fat_attach(old_inode, sinfo.i_pos);
+       fat_attach(old_inode, new_i_pos);
        if (IS_DIRSYNC(new_dir)) {
                err = fat_sync_inode(old_inode);
                if (err)
@@ -1002,7 +976,7 @@ error_inode:
        fat_detach(old_inode);
        fat_attach(old_inode, old_sinfo.i_pos);
        if (new_inode) {
-               fat_attach(new_inode, sinfo.i_pos);
+               fat_attach(new_inode, new_i_pos);
                if (corrupt)
                        corrupt |= fat_sync_inode(new_inode);
        } else {