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 | |
| 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')
| -rw-r--r-- | fs/9p/vfs_inode.c | 2 | ||||
| -rw-r--r-- | fs/9p/vfs_inode_dotl.c | 2 | ||||
| -rw-r--r-- | fs/ceph/file.c | 2 | ||||
| -rw-r--r-- | fs/fuse/dir.c | 2 | ||||
| -rw-r--r-- | fs/namei.c | 21 | ||||
| -rw-r--r-- | fs/nfs/dir.c | 24 |
6 files changed, 23 insertions, 30 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 7f6c67703195..47f71eb66b32 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
| @@ -634,7 +634,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
| 634 | v9ses = v9fs_inode2v9ses(dir); | 634 | v9ses = v9fs_inode2v9ses(dir); |
| 635 | perm = unixmode2p9mode(v9ses, mode); | 635 | perm = unixmode2p9mode(v9ses, mode); |
| 636 | if (nd && nd->flags & LOOKUP_OPEN) | 636 | if (nd && nd->flags & LOOKUP_OPEN) |
| 637 | flags = nd->intent.open.flags - 1; | 637 | flags = nd->intent.open.flags; |
| 638 | else | 638 | else |
| 639 | flags = O_RDWR; | 639 | flags = O_RDWR; |
| 640 | 640 | ||
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 691c78f58bef..d148e69f21b5 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
| @@ -174,7 +174,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
| 174 | 174 | ||
| 175 | v9ses = v9fs_inode2v9ses(dir); | 175 | v9ses = v9fs_inode2v9ses(dir); |
| 176 | if (nd && nd->flags & LOOKUP_OPEN) | 176 | if (nd && nd->flags & LOOKUP_OPEN) |
| 177 | flags = nd->intent.open.flags - 1; | 177 | flags = nd->intent.open.flags; |
| 178 | else { | 178 | else { |
| 179 | /* | 179 | /* |
| 180 | * create call without LOOKUP_OPEN is due | 180 | * create call without LOOKUP_OPEN is due |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 4698a5c553dc..0a292459c895 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
| @@ -226,7 +226,7 @@ struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry, | |||
| 226 | struct inode *parent_inode = get_dentry_parent_inode(file->f_dentry); | 226 | struct inode *parent_inode = get_dentry_parent_inode(file->f_dentry); |
| 227 | struct ceph_mds_request *req; | 227 | struct ceph_mds_request *req; |
| 228 | int err; | 228 | int err; |
| 229 | int flags = nd->intent.open.flags - 1; /* silly vfs! */ | 229 | int flags = nd->intent.open.flags; |
| 230 | 230 | ||
| 231 | dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n", | 231 | dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n", |
| 232 | dentry, dentry->d_name.len, dentry->d_name.name, flags, mode); | 232 | dentry, dentry->d_name.len, dentry->d_name.name, flags, mode); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index e2b14001cea5..47559dd33193 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
| @@ -382,7 +382,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, | |||
| 382 | struct fuse_entry_out outentry; | 382 | struct fuse_entry_out outentry; |
| 383 | struct fuse_file *ff; | 383 | struct fuse_file *ff; |
| 384 | struct file *file; | 384 | struct file *file; |
| 385 | int flags = nd->intent.open.flags - 1; | 385 | int flags = nd->intent.open.flags; |
| 386 | 386 | ||
| 387 | if (fc->no_create) | 387 | if (fc->no_create) |
| 388 | return -ENOSYS; | 388 | return -ENOSYS; |
diff --git a/fs/namei.c b/fs/namei.c index 94fd0fa2d647..5e65f67ee926 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -1965,27 +1965,10 @@ static int handle_truncate(struct file *filp) | |||
| 1965 | return error; | 1965 | return error; |
| 1966 | } | 1966 | } |
| 1967 | 1967 | ||
| 1968 | /* | ||
| 1969 | * Note that while the flag value (low two bits) for sys_open means: | ||
| 1970 | * 00 - read-only | ||
| 1971 | * 01 - write-only | ||
| 1972 | * 10 - read-write | ||
| 1973 | * 11 - special | ||
| 1974 | * it is changed into | ||
| 1975 | * 00 - no permissions needed | ||
| 1976 | * 01 - read-permission | ||
| 1977 | * 10 - write-permission | ||
| 1978 | * 11 - read-write | ||
| 1979 | * for the internal routines (ie open_namei()/follow_link() etc) | ||
| 1980 | * This is more logical, and also allows the 00 "no perm needed" | ||
| 1981 | * to be used for symlinks (where the permissions are checked | ||
| 1982 | * later). | ||
| 1983 | * | ||
| 1984 | */ | ||
| 1985 | static inline int open_to_namei_flags(int flag) | 1968 | static inline int open_to_namei_flags(int flag) |
| 1986 | { | 1969 | { |
| 1987 | if ((flag+1) & O_ACCMODE) | 1970 | if ((flag & O_ACCMODE) == 3) |
| 1988 | flag++; | 1971 | flag--; |
| 1989 | return flag; | 1972 | return flag; |
| 1990 | } | 1973 | } |
| 1991 | 1974 | ||
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 | } |
