patch-1.3.46 linux/fs/open.c

Next file: linux/fs/proc/array.c
Previous file: linux/fs/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.45/linux/fs/open.c linux/fs/open.c
@@ -122,7 +122,7 @@
 		return -EBADF;
 	if (!(inode = file->f_inode))
 		return -ENOENT;
-	if (S_ISDIR(inode->i_mode) || !(file->f_mode & 2))
+	if (S_ISDIR(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
 		return -EACCES;
 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
 		return -EPERM;
@@ -481,7 +481,7 @@
 	error = open_namei(filename,flag,mode,&inode,NULL);
 	if (error)
 		goto cleanup_file;
-	if (f->f_mode & 2) {
+	if (f->f_mode & FMODE_WRITE) {
 		error = get_write_access(inode);
 		if (error)
 			goto cleanup_inode;
@@ -516,7 +516,7 @@
 	if (f->f_op && f->f_op->release)
 		f->f_op->release(inode,f);
 cleanup_all:
-	if (f->f_mode & 2)
+	if (f->f_mode & FMODE_WRITE)
 		put_write_access(inode);
 cleanup_inode:
 	iput(inode);
@@ -562,7 +562,8 @@
 		filp->f_op->release(inode,filp);
 	filp->f_count--;
 	filp->f_inode = NULL;
-	if (filp->f_mode & 2) put_write_access(inode);
+	if (filp->f_mode & FMODE_WRITE)
+		put_write_access(inode);
 	iput(inode);
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this