patch-2.2.10 linux/fs/minix/namei.c
Next file: linux/fs/ncpfs/dir.c
Previous file: linux/fs/hfs/dir_nat.c
Back to the patch index
Back to the overall index
- Lines: 134
- Date:
Thu May 13 23:25:58 1999
- Orig file:
v2.2.9/linux/fs/minix/namei.c
- Orig date:
Tue May 11 13:10:31 1999
diff -u --recursive --new-file v2.2.9/linux/fs/minix/namei.c linux/fs/minix/namei.c
@@ -45,8 +45,6 @@
struct minix_dir_entry *de;
*res_dir = NULL;
- if (!dir->i_sb)
- return NULL;
info = &dir->i_sb->u.minix_sb;
if (namelen > info->s_namelen) {
#ifdef NO_TRUNCATE
@@ -161,8 +159,6 @@
*res_buf = NULL;
*res_dir = NULL;
- if (!dir || !dir->i_sb)
- return -ENOENT;
info = &dir->i_sb->u.minix_sb;
if (namelen > info->s_namelen) {
#ifdef NO_TRUNCATE
@@ -342,8 +338,6 @@
struct minix_dir_entry * de;
struct minix_sb_info * info;
- if (!inode || !inode->i_sb)
- return 1;
info = &inode->i_sb->u.minix_sb;
block = 0;
bh = NULL;
@@ -442,26 +436,12 @@
struct buffer_head * bh;
struct minix_dir_entry * de;
-repeat:
retval = -ENOENT;
- inode = NULL;
+ inode = dentry->d_inode;
bh = minix_find_entry(dir, dentry->d_name.name,
dentry->d_name.len, &de);
- if (!bh)
- goto end_unlink;
- inode = dentry->d_inode;
-
- retval = -EPERM;
- if (de->inode != inode->i_ino) {
- brelse(bh);
- current->counter = 0;
- schedule();
- goto repeat;
- }
- if (de->inode != inode->i_ino) {
- retval = -ENOENT;
+ if (!bh || de->inode != inode->i_ino)
goto end_unlink;
- }
if (!inode->i_nlink) {
printk("Deleting nonexistent file (%s:%lu), %d\n",
kdevname(inode->i_dev),
@@ -562,12 +542,6 @@
(((struct minix_dir_entry *) ((buffer)+info->s_dirsize))->inode)
/*
- * rename uses retrying to avoid race-conditions: at least they should be minimal.
- * it tries to allocate all the blocks, then sanity-checks, and if the sanity-
- * checks fail, it tries to restart itself again. Very practical - no changes
- * are done until we know everything works ok.. and then all the changes can be
- * done in one fell swoop when we have claimed all the buffers needed.
- *
* Anybody can rename anything with this: the permission checks are left to the
* higher-level routines.
*/
@@ -581,24 +555,15 @@
int retval;
info = &old_dir->i_sb->u.minix_sb;
- goto start_up;
-try_again:
- brelse(old_bh);
- brelse(new_bh);
- brelse(dir_bh);
- current->counter = 0;
- schedule();
-start_up:
- old_inode = new_inode = NULL;
- old_bh = new_bh = dir_bh = NULL;
+ new_bh = dir_bh = NULL;
+ old_inode = old_dentry->d_inode;
+ new_inode = new_dentry->d_inode;
old_bh = minix_find_entry(old_dir, old_dentry->d_name.name,
old_dentry->d_name.len, &old_de);
retval = -ENOENT;
- if (!old_bh)
+ if (!old_bh || old_de->inode != old_inode->i_ino)
goto end_rename;
- old_inode = old_dentry->d_inode;
retval = -EPERM;
- new_inode = new_dentry->d_inode;
new_bh = minix_find_entry(new_dir, new_dentry->d_name.name,
new_dentry->d_name.len, &new_de);
if (new_bh) {
@@ -620,7 +585,8 @@
if (PARENT_INO(dir_bh->b_data) != old_dir->i_ino)
goto end_rename;
retval = -EMLINK;
- if (!new_inode && new_dir->i_nlink >= info->s_link_max)
+ if (!new_inode && new_dir != old_dir &&
+ new_dir->i_nlink >= info->s_link_max)
goto end_rename;
}
if (!new_bh) {
@@ -631,22 +597,15 @@
if (retval)
goto end_rename;
}
-/* sanity checking before doing the rename - avoid races */
- if (new_inode && (new_de->inode != new_inode->i_ino))
- goto try_again;
- if (new_de->inode && !new_inode)
- goto try_again;
- if (old_de->inode != old_inode->i_ino)
- goto try_again;
/* ok, that's it */
- old_de->inode = 0;
new_de->inode = old_inode->i_ino;
+ old_de->inode = 0;
old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
- mark_inode_dirty(old_dir);
old_dir->i_version = ++event;
+ mark_inode_dirty(old_dir);
new_dir->i_ctime = new_dir->i_mtime = CURRENT_TIME;
- mark_inode_dirty(new_dir);
new_dir->i_version = ++event;
+ mark_inode_dirty(new_dir);
if (new_inode) {
new_inode->i_nlink--;
new_inode->i_ctime = CURRENT_TIME;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)