patch-2.1.123 linux/fs/super.c

Next file: linux/fs/sysv/symlink.c
Previous file: linux/fs/romfs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.122/linux/fs/super.c linux/fs/super.c
@@ -868,17 +868,19 @@
 	struct vfsmount *vfsmnt;
 	int error;
 
-	down(&mount_sem);
 	error = -EACCES;
 	if (!(flags & MS_RDONLY) && dev && is_read_only(dev))
 		goto out;
-		/*flags |= MS_RDONLY;*/
 
+	/*
+	 * Do the lookup first to force automounting.
+	 */
 	dir_d = namei(dir_name);
 	error = PTR_ERR(dir_d);
 	if (IS_ERR(dir_d))
 		goto out;
 
+	down(&mount_sem);
 	error = -ENOTDIR;
 	if (!S_ISDIR(dir_d->d_inode->i_mode))
 		goto dput_and_out;
@@ -906,18 +908,16 @@
 
 	error = -ENOMEM;
 	vfsmnt = add_vfsmnt(sb, dev_name, dir_name);
-	if (!vfsmnt)
-		goto dput_and_out;
-	d_mount(dir_d, sb->s_root);
-	error = 0;	/* we don't dput(dir_d) - see umount */
-
-out:
-	up(&mount_sem);
-	return error;	
+	if (vfsmnt) {
+		d_mount(dget(dir_d), sb->s_root);
+		error = 0;
+	}
 
 dput_and_out:
 	dput(dir_d);
-	goto out;
+	up(&mount_sem);
+out:
+	return error;	
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov