ecryptfs: fixed testing of file descriptor flags
authorRoberto Sassu <roberto.sassu@polito.it>
Wed, 3 Nov 2010 10:11:34 +0000 (11:11 +0100)
committerTyler Hicks <tyhicks@linux.vnet.ibm.com>
Mon, 17 Jan 2011 17:24:43 +0000 (11:24 -0600)
This patch replaces the check (lower_file->f_flags & O_RDONLY) with
((lower_file & O_ACCMODE) == O_RDONLY).

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
fs/ecryptfs/file.c

index 99259f850e586c9dabd0f0de87d1205825b3f33e..e069e786da43a073c0233a13094bc723c292ed08 100644 (file)
@@ -199,8 +199,8 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
                        ecryptfs_dentry->d_name.name, rc);
                goto out_free;
        }
-       if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY)
-           && !(file->f_flags & O_RDONLY)) {
+       if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_ACCMODE)
+           == O_RDONLY && (file->f_flags & O_ACCMODE) != O_RDONLY) {
                rc = -EPERM;
                printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs "
                       "file must hence be opened RO\n", __func__);