Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234251
b: refs/heads/master
c: 13aab42
h: refs/heads/master
i:
  234249: a055a34
  234247: 13ad09f
v: v3
  • Loading branch information
Al Viro committed Mar 14, 2011
1 parent 9a31ad4 commit 5a296a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 47c805dc2d2dff686962f5f0baa6bac2d703ba19
refs/heads/master: 13aab428a73d3200b9283b61b7fdf5713181ac66
49 changes: 20 additions & 29 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2292,19 +2292,14 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
return ERR_PTR(error);
}

/*
* Note that the low bits of the passed in "open_flag"
* are not the same as in the local variable "flag". See
* open_to_namei_flags() for more details.
*/
struct file *do_filp_open(int dfd, const char *pathname,
static struct file *path_openat(int dfd, const char *pathname,
const struct open_flags *op, int flags)
{
struct file *filp;
struct nameidata nd;
int error;
struct path path;
int count = 0;
int error;

filp = get_empty_filp();
if (!filp)
Expand All @@ -2319,42 +2314,27 @@ struct file *do_filp_open(int dfd, const char *pathname,
goto creat;

/* !O_CREAT, simple open */
error = do_path_lookup(dfd, pathname, flags | op->intent, &nd);
error = path_lookupat(dfd, pathname, flags | op->intent, &nd);
if (unlikely(error))
goto out_filp2;
goto out_filp;
error = -ELOOP;
if (!(nd.flags & LOOKUP_FOLLOW)) {
if (nd.inode->i_op->follow_link)
goto out_path2;
goto out_path;
}
error = -ENOTDIR;
if (nd.flags & LOOKUP_DIRECTORY) {
if (!nd.inode->i_op->lookup)
goto out_path2;
goto out_path;
}
audit_inode(pathname, nd.path.dentry);
filp = finish_open(&nd, op->open_flag, op->acc_mode);
out2:
release_open_intent(&nd);
return filp;

out_path2:
path_put(&nd.path);
out_filp2:
filp = ERR_PTR(error);
goto out2;

creat:
/* OK, have to create the file. Find the parent. */
error = path_lookupat(dfd, pathname,
LOOKUP_PARENT | LOOKUP_RCU | flags, &nd);
if (unlikely(error == -ECHILD))
error = path_lookupat(dfd, pathname, LOOKUP_PARENT | flags, &nd);
if (unlikely(error == -ESTALE)) {
reval:
flags |= LOOKUP_REVAL;
error = path_lookupat(dfd, pathname, LOOKUP_PARENT | flags, &nd);
}
error = path_lookupat(dfd, pathname, LOOKUP_PARENT | flags, &nd);
if (unlikely(error))
goto out_filp;
if (unlikely(!audit_dummy_context()))
Expand Down Expand Up @@ -2398,8 +2378,6 @@ struct file *do_filp_open(int dfd, const char *pathname,
out:
if (nd.root.mnt)
path_put(&nd.root);
if (filp == ERR_PTR(-ESTALE) && !(flags & LOOKUP_REVAL))
goto reval;
release_open_intent(&nd);
return filp;

Expand All @@ -2412,6 +2390,19 @@ struct file *do_filp_open(int dfd, const char *pathname,
goto out;
}

struct file *do_filp_open(int dfd, const char *pathname,
const struct open_flags *op, int flags)
{
struct file *filp;

filp = path_openat(dfd, pathname, op, flags | LOOKUP_RCU);
if (unlikely(filp == ERR_PTR(-ECHILD)))
filp = path_openat(dfd, pathname, op, flags);
if (unlikely(filp == ERR_PTR(-ESTALE)))
filp = path_openat(dfd, pathname, op, flags | LOOKUP_REVAL);
return filp;
}

/**
* lookup_create - lookup a dentry, creating it if it doesn't exist
* @nd: nameidata info
Expand Down

0 comments on commit 5a296a1

Please sign in to comment.