patch-2.1.115 linux/fs/namei.c

Next file: linux/fs/nfsd/nfsfh.c
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.114/linux/fs/namei.c linux/fs/namei.c
@@ -524,13 +524,19 @@
 	if (flag & O_CREAT) {
 		struct dentry *dir;
 
+		error = -EEXIST;
+		if (dentry->d_inode && (flag & O_EXCL))
+			goto exit;
+
 		dir = lock_parent(dentry);
 		error = PTR_ERR(dir);
 		if (IS_ERR(dir))
 			goto exit;
+
 		/*
-		 * The existence test must be done _after_ getting the directory
-		 * semaphore - the dentry might otherwise change.
+		 * Somebody might have created the file while we
+		 * waited for the directory lock.. So we have to
+		 * re-do the existence test.
 		 */
 		if (dentry->d_inode) {
 			error = 0;

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