diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-06-25 19:15:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 01:43:52 -0400 |
commit | 8a5e929dd2e05ab4d3d89f58c5e8fca596af8f3a (patch) | |
tree | 8cbed05fcd99d24e881e5ea12d8a954865e31085 /fs/nfs/dir.c | |
parent | 554a8b9f54cd7ca2b89f5dc227df08be082fae0d (diff) |
don't transliterate lower bits of ->intent.open.flags to FMODE_...
->create() instances are much happier that way...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1f4625749038..b5f63a50fa7f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1338,16 +1338,26 @@ static int is_atomic_open(struct nameidata *nd) | |||
1338 | return 0; | 1338 | return 0; |
1339 | /* Are we trying to write to a read only partition? */ | 1339 | /* Are we trying to write to a read only partition? */ |
1340 | if (__mnt_is_readonly(nd->path.mnt) && | 1340 | if (__mnt_is_readonly(nd->path.mnt) && |
1341 | (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE))) | 1341 | (nd->intent.open.flags & (O_CREAT|O_TRUNC|O_ACCMODE))) |
1342 | return 0; | 1342 | return 0; |
1343 | return 1; | 1343 | return 1; |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | static fmode_t flags_to_mode(int flags) | ||
1347 | { | ||
1348 | fmode_t res = (__force fmode_t)flags & FMODE_EXEC; | ||
1349 | if ((flags & O_ACCMODE) != O_WRONLY) | ||
1350 | res |= FMODE_READ; | ||
1351 | if ((flags & O_ACCMODE) != O_RDONLY) | ||
1352 | res |= FMODE_WRITE; | ||
1353 | return res; | ||
1354 | } | ||
1355 | |||
1346 | static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags) | 1356 | static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags) |
1347 | { | 1357 | { |
1348 | struct nfs_open_context *ctx; | 1358 | struct nfs_open_context *ctx; |
1349 | struct rpc_cred *cred; | 1359 | struct rpc_cred *cred; |
1350 | fmode_t fmode = open_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC); | 1360 | fmode_t fmode = flags_to_mode(open_flags); |
1351 | 1361 | ||
1352 | cred = rpc_lookup_cred(); | 1362 | cred = rpc_lookup_cred(); |
1353 | if (IS_ERR(cred)) | 1363 | if (IS_ERR(cred)) |
@@ -1567,7 +1577,7 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1567 | struct nfs_open_context *ctx = NULL; | 1577 | struct nfs_open_context *ctx = NULL; |
1568 | struct iattr attr; | 1578 | struct iattr attr; |
1569 | int error; | 1579 | int error; |
1570 | int open_flags = O_CREAT|O_EXCL|FMODE_READ; | 1580 | int open_flags = O_CREAT|O_EXCL; |
1571 | 1581 | ||
1572 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", | 1582 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", |
1573 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1583 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
@@ -1657,7 +1667,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1657 | { | 1667 | { |
1658 | struct iattr attr; | 1668 | struct iattr attr; |
1659 | int error; | 1669 | int error; |
1660 | int open_flags = O_CREAT|O_EXCL|FMODE_READ; | 1670 | int open_flags = O_CREAT|O_EXCL; |
1661 | 1671 | ||
1662 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", | 1672 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", |
1663 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1673 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
@@ -2256,11 +2266,11 @@ static int nfs_open_permission_mask(int openflags) | |||
2256 | { | 2266 | { |
2257 | int mask = 0; | 2267 | int mask = 0; |
2258 | 2268 | ||
2259 | if (openflags & FMODE_READ) | 2269 | if ((openflags & O_ACCMODE) != O_WRONLY) |
2260 | mask |= MAY_READ; | 2270 | mask |= MAY_READ; |
2261 | if (openflags & FMODE_WRITE) | 2271 | if ((openflags & O_ACCMODE) != O_RDONLY) |
2262 | mask |= MAY_WRITE; | 2272 | mask |= MAY_WRITE; |
2263 | if (openflags & FMODE_EXEC) | 2273 | if (openflags & __FMODE_EXEC) |
2264 | mask |= MAY_EXEC; | 2274 | mask |= MAY_EXEC; |
2265 | return mask; | 2275 | return mask; |
2266 | } | 2276 | } |