mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
[PATCH] get rid of path_lookup_create()
... and don't pass bogus flags when we are just looking for parent. Fold __path_lookup_intent_open() into path_lookup_open() while we are at it; that's the only remaining caller. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
98bc993f99
commit
8737f3a1b3
1 changed files with 27 additions and 44 deletions
71
fs/namei.c
71
fs/namei.c
|
@ -1147,29 +1147,6 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __path_lookup_intent_open(int dfd, const char *name,
|
|
||||||
unsigned int lookup_flags, struct nameidata *nd,
|
|
||||||
int open_flags, int create_mode)
|
|
||||||
{
|
|
||||||
struct file *filp = get_empty_filp();
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (filp == NULL)
|
|
||||||
return -ENFILE;
|
|
||||||
nd->intent.open.file = filp;
|
|
||||||
nd->intent.open.flags = open_flags;
|
|
||||||
nd->intent.open.create_mode = create_mode;
|
|
||||||
err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);
|
|
||||||
if (IS_ERR(nd->intent.open.file)) {
|
|
||||||
if (err == 0) {
|
|
||||||
err = PTR_ERR(nd->intent.open.file);
|
|
||||||
path_put(&nd->path);
|
|
||||||
}
|
|
||||||
} else if (err != 0)
|
|
||||||
release_open_intent(nd);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_lookup_open - lookup a file path with open intent
|
* path_lookup_open - lookup a file path with open intent
|
||||||
* @dfd: the directory to use as base, or AT_FDCWD
|
* @dfd: the directory to use as base, or AT_FDCWD
|
||||||
|
@ -1181,25 +1158,23 @@ static int __path_lookup_intent_open(int dfd, const char *name,
|
||||||
int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags,
|
int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags,
|
||||||
struct nameidata *nd, int open_flags)
|
struct nameidata *nd, int open_flags)
|
||||||
{
|
{
|
||||||
return __path_lookup_intent_open(dfd, name, lookup_flags, nd,
|
struct file *filp = get_empty_filp();
|
||||||
open_flags, 0);
|
int err;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (filp == NULL)
|
||||||
* path_lookup_create - lookup a file path with open + create intent
|
return -ENFILE;
|
||||||
* @dfd: the directory to use as base, or AT_FDCWD
|
nd->intent.open.file = filp;
|
||||||
* @name: pointer to file name
|
nd->intent.open.flags = open_flags;
|
||||||
* @lookup_flags: lookup intent flags
|
nd->intent.open.create_mode = 0;
|
||||||
* @nd: pointer to nameidata
|
err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);
|
||||||
* @open_flags: open intent flags
|
if (IS_ERR(nd->intent.open.file)) {
|
||||||
* @create_mode: create intent flags
|
if (err == 0) {
|
||||||
*/
|
err = PTR_ERR(nd->intent.open.file);
|
||||||
static int path_lookup_create(int dfd, const char *name,
|
path_put(&nd->path);
|
||||||
unsigned int lookup_flags, struct nameidata *nd,
|
}
|
||||||
int open_flags, int create_mode)
|
} else if (err != 0)
|
||||||
{
|
release_open_intent(nd);
|
||||||
return __path_lookup_intent_open(dfd, name, lookup_flags|LOOKUP_CREATE,
|
return err;
|
||||||
nd, open_flags, create_mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *__lookup_hash(struct qstr *name,
|
static struct dentry *__lookup_hash(struct qstr *name,
|
||||||
|
@ -1711,8 +1686,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
|
||||||
/*
|
/*
|
||||||
* Create - we need to know the parent.
|
* Create - we need to know the parent.
|
||||||
*/
|
*/
|
||||||
error = path_lookup_create(dfd, pathname, LOOKUP_PARENT,
|
error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd);
|
||||||
&nd, flag, mode);
|
|
||||||
if (error)
|
if (error)
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
|
@ -1723,10 +1697,18 @@ struct file *do_filp_open(int dfd, const char *pathname,
|
||||||
*/
|
*/
|
||||||
error = -EISDIR;
|
error = -EISDIR;
|
||||||
if (nd.last_type != LAST_NORM || nd.last.name[nd.last.len])
|
if (nd.last_type != LAST_NORM || nd.last.name[nd.last.len])
|
||||||
goto exit;
|
goto exit_parent;
|
||||||
|
|
||||||
|
error = -ENFILE;
|
||||||
|
filp = get_empty_filp();
|
||||||
|
if (filp == NULL)
|
||||||
|
goto exit_parent;
|
||||||
|
nd.intent.open.file = filp;
|
||||||
|
nd.intent.open.flags = flag;
|
||||||
|
nd.intent.open.create_mode = mode;
|
||||||
dir = nd.path.dentry;
|
dir = nd.path.dentry;
|
||||||
nd.flags &= ~LOOKUP_PARENT;
|
nd.flags &= ~LOOKUP_PARENT;
|
||||||
|
nd.flags |= LOOKUP_CREATE | LOOKUP_OPEN;
|
||||||
mutex_lock(&dir->d_inode->i_mutex);
|
mutex_lock(&dir->d_inode->i_mutex);
|
||||||
path.dentry = lookup_hash(&nd);
|
path.dentry = lookup_hash(&nd);
|
||||||
path.mnt = nd.path.mnt;
|
path.mnt = nd.path.mnt;
|
||||||
|
@ -1831,6 +1813,7 @@ exit_dput:
|
||||||
exit:
|
exit:
|
||||||
if (!IS_ERR(nd.intent.open.file))
|
if (!IS_ERR(nd.intent.open.file))
|
||||||
release_open_intent(&nd);
|
release_open_intent(&nd);
|
||||||
|
exit_parent:
|
||||||
path_put(&nd.path);
|
path_put(&nd.path);
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue