Commit 3fb64190 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

pass a struct path * to may_open

No need for the nameidata in may_open - a struct path is enough.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b4091d5f
...@@ -1487,9 +1487,9 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -1487,9 +1487,9 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
return error; return error;
} }
int may_open(struct nameidata *nd, int acc_mode, int flag) int may_open(struct path *path, int acc_mode, int flag)
{ {
struct dentry *dentry = nd->path.dentry; struct dentry *dentry = path->dentry;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error; int error;
...@@ -1510,13 +1510,13 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) ...@@ -1510,13 +1510,13 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
flag &= ~O_TRUNC; flag &= ~O_TRUNC;
} else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) { } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
if (nd->path.mnt->mnt_flags & MNT_NODEV) if (path->mnt->mnt_flags & MNT_NODEV)
return -EACCES; return -EACCES;
flag &= ~O_TRUNC; flag &= ~O_TRUNC;
} }
error = vfs_permission(nd, acc_mode); error = inode_permission(inode, acc_mode);
if (error) if (error)
return error; return error;
/* /*
...@@ -1551,7 +1551,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) ...@@ -1551,7 +1551,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
*/ */
error = locks_verify_locked(inode); error = locks_verify_locked(inode);
if (!error) if (!error)
error = security_path_truncate(&nd->path, 0, error = security_path_truncate(path, 0,
ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
if (!error) { if (!error) {
DQUOT_INIT(inode); DQUOT_INIT(inode);
...@@ -1594,7 +1594,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path, ...@@ -1594,7 +1594,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path,
if (error) if (error)
return error; return error;
/* Don't check for write permission, don't truncate */ /* Don't check for write permission, don't truncate */
return may_open(nd, 0, flag & ~O_TRUNC); return may_open(&nd->path, 0, flag & ~O_TRUNC);
} }
/* /*
...@@ -1780,7 +1780,7 @@ struct file *do_filp_open(int dfd, const char *pathname, ...@@ -1780,7 +1780,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
if (error) if (error)
goto exit; goto exit;
} }
error = may_open(&nd, acc_mode, flag); error = may_open(&nd.path, acc_mode, flag);
if (error) { if (error) {
if (will_write) if (will_write)
mnt_drop_write(nd.path.mnt); mnt_drop_write(nd.path.mnt);
......
...@@ -38,9 +38,10 @@ static struct file *do_open(char *name, int flags) ...@@ -38,9 +38,10 @@ static struct file *do_open(char *name, int flags)
return ERR_PTR(error); return ERR_PTR(error);
if (flags == O_RDWR) if (flags == O_RDWR)
error = may_open(&nd,MAY_READ|MAY_WRITE,FMODE_READ|FMODE_WRITE); error = may_open(&nd.path, MAY_READ|MAY_WRITE,
FMODE_READ|FMODE_WRITE);
else else
error = may_open(&nd, MAY_WRITE, FMODE_WRITE); error = may_open(&nd.path, MAY_WRITE, FMODE_WRITE);
if (!error) if (!error)
return dentry_open(nd.path.dentry, nd.path.mnt, flags, return dentry_open(nd.path.dentry, nd.path.mnt, flags,
......
...@@ -1869,7 +1869,7 @@ extern void free_write_pipe(struct file *); ...@@ -1869,7 +1869,7 @@ extern void free_write_pipe(struct file *);
extern struct file *do_filp_open(int dfd, const char *pathname, extern struct file *do_filp_open(int dfd, const char *pathname,
int open_flag, int mode); int open_flag, int mode);
extern int may_open(struct nameidata *, int, int); extern int may_open(struct path *, int, int);
extern int kernel_read(struct file *, unsigned long, char *, unsigned long); extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
extern struct file * open_exec(const char *); extern struct file * open_exec(const char *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment