patch-2.1.132 linux/fs/msdos/namei.c
Next file: linux/fs/namei.c
Previous file: linux/fs/minix/namei.c
Back to the patch index
Back to the overall index
- Lines: 90
- Date:
Fri Dec 18 07:09:35 1998
- Orig file:
v2.1.131/linux/fs/msdos/namei.c
- Orig date:
Wed Dec 16 10:32:55 1998
diff -u --recursive --new-file v2.1.131/linux/fs/msdos/namei.c linux/fs/msdos/namei.c
@@ -439,18 +439,10 @@
&bh, &de, &ino);
if (res < 0)
goto rmdir_done;
- res = -ENOTDIR;
- if (!S_ISDIR(inode->i_mode))
- goto rmdir_done;
- if (dir->i_dev != inode->i_dev || dir == inode)
- printk("msdos_rmdir: impossible condition\n");
/*
- * Check whether the directory is empty, then prune
- * any child dentries and make sure it's not in use.
+ * Check whether the directory is not in use, then check
+ * whether it is empty.
*/
- res = msdos_empty(inode);
- if (res)
- goto rmdir_done;
res = -EBUSY;
if (!list_empty(&dentry->d_hash)) {
#ifdef MSDOS_DEBUG
@@ -459,6 +451,9 @@
#endif
goto rmdir_done;
}
+ res = msdos_empty(inode);
+ if (res)
+ goto rmdir_done;
inode->i_nlink = 0;
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
@@ -507,11 +502,14 @@
dir->i_nlink++;
inode->i_nlink = 2; /* no need to mark them dirty */
- MSDOS_I(inode)->i_busy = 1; /* prevent lookups */
+
+#ifdef whatfor
/*
- * Instantiate the dentry now, in case we need to cleanup.
+ * He's dead, Jim. We don't d_instantiate anymore. Should do it
+ * from the very beginning, actually.
*/
- d_instantiate(dentry, inode);
+ MSDOS_I(inode)->i_busy = 1; /* prevent lookups */
+#endif
if ((res = fat_add_cluster(inode)) < 0)
goto mkdir_error;
@@ -531,8 +529,11 @@
MSDOS_I(dot)->i_logstart = MSDOS_I(dir)->i_logstart;
dot->i_nlink = dir->i_nlink;
mark_inode_dirty(dot);
+#ifdef whatfor
MSDOS_I(inode)->i_busy = 0;
+#endif
iput(dot);
+ d_instantiate(dentry, inode);
res = 0;
out_unlock:
@@ -541,8 +542,17 @@
mkdir_error:
printk("msdos_mkdir: error=%d, attempting cleanup\n", res);
- if (msdos_rmdir(dir,dentry) < 0)
- fat_fs_panic(dir->i_sb,"rmdir in mkdir failed");
+ bh = NULL;
+ fat_scan(dir,msdos_name,&bh,&de,&ino,SCAN_ANY);
+ inode->i_nlink = 0;
+ inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+ dir->i_nlink--;
+ mark_inode_dirty(inode);
+ mark_inode_dirty(dir);
+ iput(inode);
+ de->name[0] = DELETED_FLAG;
+ fat_mark_buffer_dirty(sb, bh, 1);
+ fat_brelse(sb, bh);
goto out_unlock;
out_exist:
@@ -567,8 +577,6 @@
goto unlink_done;
res = -EPERM;
if (!S_ISREG(inode->i_mode) && nospc)
- goto unlink_done;
- if (IS_IMMUTABLE(inode))
goto unlink_done;
/* N.B. check for busy files? */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov