patch-2.4.10 linux/fs/affs/namei.c

Next file: linux/fs/affs/super.c
Previous file: linux/fs/affs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/fs/affs/namei.c linux/fs/affs/namei.c
@@ -72,7 +72,7 @@
 static inline int
 __affs_hash_dentry(struct dentry *dentry, struct qstr *qstr, toupper_t toupper)
 {
-	const char *name = qstr->name;
+	const u8 *name = qstr->name;
 	unsigned long hash;
 	int i;
 
@@ -81,7 +81,7 @@
 		return i;
 
 	hash = init_name_hash();
-	i = MIN(qstr->len, 30);
+	i = min(qstr->len, 30u);
 	for (; i > 0; name++, i--)
 		hash = partial_name_hash(toupper(*name), hash);
 	qstr->hash = end_name_hash(hash);
@@ -172,7 +172,7 @@
 	toupper_t toupper = affs_get_toupper(sb);
 	int hash;
 
-	hash = len = MIN(len, 30);
+	hash = len = min(len, 30u);
 	for (; len > 0; len--)
 		hash = (hash * 13 + toupper(*name++)) & 0x7ff;
 
@@ -448,25 +448,20 @@
 	if (!bh)
 		goto done;
 
-	affs_lock_dir(old_dir);
-	if (old_dir != new_dir)
-		affs_lock_dir(new_dir);
-
 	/* Remove header from its parent directory. */
+	affs_lock_dir(old_dir);
 	retval = affs_remove_hash(old_dir, bh);
+	affs_unlock_dir(old_dir);
 	if (retval)
-		goto done_unlock;
+		goto done;
 
 	/* And insert it into the new directory with the new name. */
 	affs_copy_name(AFFS_TAIL(sb, bh)->name, new_dentry);
 	affs_fix_checksum(sb, bh);
+	affs_lock_dir(new_dir);
 	retval = affs_insert_hash(new_dir, bh);
-	/* TODO: move it back to old_dir? */
-
-done_unlock:
-	affs_unlock_dir(old_dir);
-	if (old_dir != new_dir)
-		affs_unlock_dir(new_dir);
+	affs_unlock_dir(new_dir);
+	/* TODO: move it back to old_dir, if error? */
 
 done:
 	mark_buffer_dirty_inode(bh, retval ? old_dir : new_dir);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)