mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 06:34:12 +08:00
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>
This commit is contained in:
parent
554a8b9f54
commit
8a5e929dd2
@ -512,7 +512,7 @@ struct dentry *pohmelfs_lookup(struct inode *dir, struct dentry *dentry, struct
|
|||||||
int err, lock_type = POHMELFS_READ_LOCK, need_lock = 1;
|
int err, lock_type = POHMELFS_READ_LOCK, need_lock = 1;
|
||||||
struct qstr str = dentry->d_name;
|
struct qstr str = dentry->d_name;
|
||||||
|
|
||||||
if ((nd->intent.open.flags & O_ACCMODE) > 1)
|
if ((nd->intent.open.flags & O_ACCMODE) != O_RDONLY)
|
||||||
lock_type = POHMELFS_WRITE_LOCK;
|
lock_type = POHMELFS_WRITE_LOCK;
|
||||||
|
|
||||||
if (test_bit(NETFS_INODE_OWNED, &parent->state)) {
|
if (test_bit(NETFS_INODE_OWNED, &parent->state)) {
|
||||||
|
@ -634,7 +634,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
v9ses = v9fs_inode2v9ses(dir);
|
v9ses = v9fs_inode2v9ses(dir);
|
||||||
perm = unixmode2p9mode(v9ses, mode);
|
perm = unixmode2p9mode(v9ses, mode);
|
||||||
if (nd && nd->flags & LOOKUP_OPEN)
|
if (nd && nd->flags & LOOKUP_OPEN)
|
||||||
flags = nd->intent.open.flags - 1;
|
flags = nd->intent.open.flags;
|
||||||
else
|
else
|
||||||
flags = O_RDWR;
|
flags = O_RDWR;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
|
|||||||
|
|
||||||
v9ses = v9fs_inode2v9ses(dir);
|
v9ses = v9fs_inode2v9ses(dir);
|
||||||
if (nd && nd->flags & LOOKUP_OPEN)
|
if (nd && nd->flags & LOOKUP_OPEN)
|
||||||
flags = nd->intent.open.flags - 1;
|
flags = nd->intent.open.flags;
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* create call without LOOKUP_OPEN is due
|
* create call without LOOKUP_OPEN is due
|
||||||
|
@ -226,7 +226,7 @@ struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
|
|||||||
struct inode *parent_inode = get_dentry_parent_inode(file->f_dentry);
|
struct inode *parent_inode = get_dentry_parent_inode(file->f_dentry);
|
||||||
struct ceph_mds_request *req;
|
struct ceph_mds_request *req;
|
||||||
int err;
|
int err;
|
||||||
int flags = nd->intent.open.flags - 1; /* silly vfs! */
|
int flags = nd->intent.open.flags;
|
||||||
|
|
||||||
dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n",
|
dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n",
|
||||||
dentry, dentry->d_name.len, dentry->d_name.name, flags, mode);
|
dentry, dentry->d_name.len, dentry->d_name.name, flags, mode);
|
||||||
|
@ -382,7 +382,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
|
|||||||
struct fuse_entry_out outentry;
|
struct fuse_entry_out outentry;
|
||||||
struct fuse_file *ff;
|
struct fuse_file *ff;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
int flags = nd->intent.open.flags - 1;
|
int flags = nd->intent.open.flags;
|
||||||
|
|
||||||
if (fc->no_create)
|
if (fc->no_create)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
21
fs/namei.c
21
fs/namei.c
@ -1965,27 +1965,10 @@ static int handle_truncate(struct file *filp)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Note that while the flag value (low two bits) for sys_open means:
|
|
||||||
* 00 - read-only
|
|
||||||
* 01 - write-only
|
|
||||||
* 10 - read-write
|
|
||||||
* 11 - special
|
|
||||||
* it is changed into
|
|
||||||
* 00 - no permissions needed
|
|
||||||
* 01 - read-permission
|
|
||||||
* 10 - write-permission
|
|
||||||
* 11 - read-write
|
|
||||||
* for the internal routines (ie open_namei()/follow_link() etc)
|
|
||||||
* This is more logical, and also allows the 00 "no perm needed"
|
|
||||||
* to be used for symlinks (where the permissions are checked
|
|
||||||
* later).
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static inline int open_to_namei_flags(int flag)
|
static inline int open_to_namei_flags(int flag)
|
||||||
{
|
{
|
||||||
if ((flag+1) & O_ACCMODE)
|
if ((flag & O_ACCMODE) == 3)
|
||||||
flag++;
|
flag--;
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
fs/nfs/dir.c
24
fs/nfs/dir.c
@ -1338,16 +1338,26 @@ static int is_atomic_open(struct nameidata *nd)
|
|||||||
return 0;
|
return 0;
|
||||||
/* Are we trying to write to a read only partition? */
|
/* Are we trying to write to a read only partition? */
|
||||||
if (__mnt_is_readonly(nd->path.mnt) &&
|
if (__mnt_is_readonly(nd->path.mnt) &&
|
||||||
(nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
|
(nd->intent.open.flags & (O_CREAT|O_TRUNC|O_ACCMODE)))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fmode_t flags_to_mode(int flags)
|
||||||
|
{
|
||||||
|
fmode_t res = (__force fmode_t)flags & FMODE_EXEC;
|
||||||
|
if ((flags & O_ACCMODE) != O_WRONLY)
|
||||||
|
res |= FMODE_READ;
|
||||||
|
if ((flags & O_ACCMODE) != O_RDONLY)
|
||||||
|
res |= FMODE_WRITE;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
|
static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
|
||||||
{
|
{
|
||||||
struct nfs_open_context *ctx;
|
struct nfs_open_context *ctx;
|
||||||
struct rpc_cred *cred;
|
struct rpc_cred *cred;
|
||||||
fmode_t fmode = open_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
|
fmode_t fmode = flags_to_mode(open_flags);
|
||||||
|
|
||||||
cred = rpc_lookup_cred();
|
cred = rpc_lookup_cred();
|
||||||
if (IS_ERR(cred))
|
if (IS_ERR(cred))
|
||||||
@ -1567,7 +1577,7 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
struct nfs_open_context *ctx = NULL;
|
struct nfs_open_context *ctx = NULL;
|
||||||
struct iattr attr;
|
struct iattr attr;
|
||||||
int error;
|
int error;
|
||||||
int open_flags = O_CREAT|O_EXCL|FMODE_READ;
|
int open_flags = O_CREAT|O_EXCL;
|
||||||
|
|
||||||
dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
|
dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
|
||||||
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
|
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,
|
|||||||
{
|
{
|
||||||
struct iattr attr;
|
struct iattr attr;
|
||||||
int error;
|
int error;
|
||||||
int open_flags = O_CREAT|O_EXCL|FMODE_READ;
|
int open_flags = O_CREAT|O_EXCL;
|
||||||
|
|
||||||
dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
|
dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
|
||||||
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
|
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
|
||||||
@ -2256,11 +2266,11 @@ static int nfs_open_permission_mask(int openflags)
|
|||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
if (openflags & FMODE_READ)
|
if ((openflags & O_ACCMODE) != O_WRONLY)
|
||||||
mask |= MAY_READ;
|
mask |= MAY_READ;
|
||||||
if (openflags & FMODE_WRITE)
|
if ((openflags & O_ACCMODE) != O_RDONLY)
|
||||||
mask |= MAY_WRITE;
|
mask |= MAY_WRITE;
|
||||||
if (openflags & FMODE_EXEC)
|
if (openflags & __FMODE_EXEC)
|
||||||
mask |= MAY_EXEC;
|
mask |= MAY_EXEC;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user