summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/fs/namei.c b/fs/namei.c
index af83ede92a4f..aaff8a862151 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2194,7 +2194,7 @@ static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode)
}
static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
- struct path *path, struct opendata *od,
+ struct path *path, struct file *file,
const struct open_flags *op,
bool *want_write, bool need_lookup,
int *opened)
@@ -2269,9 +2269,9 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
if (nd->flags & LOOKUP_DIRECTORY)
open_flag |= O_DIRECTORY;
- od->filp->f_path.dentry = DENTRY_NOT_SET;
- od->filp->f_path.mnt = nd->path.mnt;
- error = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode,
+ file->f_path.dentry = DENTRY_NOT_SET;
+ file->f_path.mnt = nd->path.mnt;
+ error = dir->i_op->atomic_open(dir, dentry, file, open_flag, mode,
opened);
if (error < 0) {
if (create_error && error == -ENOENT)
@@ -2287,13 +2287,13 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
}
if (error) { /* returned 1, that is */
- if (WARN_ON(od->filp->f_path.dentry == DENTRY_NOT_SET)) {
+ if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
filp = ERR_PTR(-EIO);
goto out;
}
- if (od->filp->f_path.dentry) {
+ if (file->f_path.dentry) {
dput(dentry);
- dentry = od->filp->f_path.dentry;
+ dentry = file->f_path.dentry;
}
goto looked_up;
}
@@ -2302,7 +2302,7 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
* We didn't have the inode before the open, so check open permission
* here.
*/
- filp = od->filp;
+ filp = file;
error = may_open(&filp->f_path, acc_mode, open_flag);
if (error) {
fput(filp);
@@ -2350,7 +2350,7 @@ looked_up:
* was performed, only lookup.
*/
static struct file *lookup_open(struct nameidata *nd, struct path *path,
- struct opendata *od,
+ struct file *file,
const struct open_flags *op,
bool *want_write, int *opened)
{
@@ -2370,7 +2370,7 @@ static struct file *lookup_open(struct nameidata *nd, struct path *path,
goto out_no_open;
if ((nd->flags & LOOKUP_OPEN) && dir_inode->i_op->atomic_open) {
- return atomic_open(nd, dentry, path, od, op, want_write,
+ return atomic_open(nd, dentry, path, file, op, want_write,
need_lookup, opened);
}
@@ -2420,7 +2420,7 @@ out_dput:
* Handle the last step of open()
*/
static struct file *do_last(struct nameidata *nd, struct path *path,
- struct opendata *od, const struct open_flags *op,
+ struct file *file, const struct open_flags *op,
int *opened, const char *pathname)
{
struct dentry *dir = nd->path.dentry;
@@ -2497,7 +2497,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
retry_lookup:
mutex_lock(&dir->d_inode->i_mutex);
- filp = lookup_open(nd, path, od, op, &want_write, opened);
+ filp = lookup_open(nd, path, file, op, &want_write, opened);
mutex_unlock(&dir->d_inode->i_mutex);
if (filp) {
@@ -2604,13 +2604,15 @@ finish_open_created:
error = may_open(&nd->path, acc_mode, open_flag);
if (error)
goto exit;
- od->filp->f_path.mnt = nd->path.mnt;
- filp = finish_open(od, nd->path.dentry, NULL, opened);
- if (IS_ERR(filp)) {
- if (filp == ERR_PTR(-EOPENSTALE))
+ file->f_path.mnt = nd->path.mnt;
+ error = finish_open(file, nd->path.dentry, NULL, opened);
+ if (error) {
+ filp = ERR_PTR(error);
+ if (error == -EOPENSTALE)
goto stale_open;
goto out;
}
+ filp = file;
opened:
error = open_check_o_direct(filp);
if (error)
@@ -2663,17 +2665,17 @@ static struct file *path_openat(int dfd, const char *pathname,
struct nameidata *nd, const struct open_flags *op, int flags)
{
struct file *base = NULL;
- struct opendata od;
+ struct file *file;
struct file *res;
struct path path;
int opened = 0;
int error;
- od.filp = get_empty_filp();
- if (!od.filp)
+ file = get_empty_filp();
+ if (!file)
return ERR_PTR(-ENFILE);
- od.filp->f_flags = op->open_flag;
+ file->f_flags = op->open_flag;
error = path_init(dfd, pathname, flags | LOOKUP_PARENT, nd, &base);
if (unlikely(error))
@@ -2684,7 +2686,7 @@ static struct file *path_openat(int dfd, const char *pathname,
if (unlikely(error))
goto out_filp;
- res = do_last(nd, &path, &od, op, &opened, pathname);
+ res = do_last(nd, &path, file, op, &opened, pathname);
while (unlikely(!res)) { /* trailing symlink */
struct path link = path;
void *cookie;
@@ -2699,7 +2701,7 @@ static struct file *path_openat(int dfd, const char *pathname,
error = follow_link(&link, nd, &cookie);
if (unlikely(error))
goto out_filp;
- res = do_last(nd, &path, &od, op, &opened, pathname);
+ res = do_last(nd, &path, file, op, &opened, pathname);
put_link(nd, &link, cookie);
}
out:
@@ -2708,7 +2710,7 @@ out:
if (base)
fput(base);
if (!(opened & FILE_OPENED))
- put_filp(od.filp);
+ put_filp(file);
if (res == ERR_PTR(-EOPENSTALE)) {
if (flags & LOOKUP_RCU)
res = ERR_PTR(-ECHILD);