Split helper ovl_lookup_data() out of ovl_lookup_single(). The helper takes care of updating the ovl_lookup_data context according to the dentry that was found in layer. Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- fs/overlayfs/namei.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 17f9372..b965785 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -96,22 +96,13 @@ static bool ovl_is_opaquedir(struct dentry *dentry) return false; } -static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, - const char *name, unsigned int namelen, - size_t prelen, const char *post, - struct dentry **ret) +/* Update ovl_lookup_data struct from dentry found in layer */ +static int ovl_lookup_data(struct dentry *this, struct ovl_lookup_data *d, + size_t prelen, const char *post, + struct dentry **ret) { - struct dentry *this; int err; - this = lookup_one_len_unlocked(name, base, namelen); - if (IS_ERR(this)) { - err = PTR_ERR(this); - this = NULL; - if (err == -ENOENT || err == -ENAMETOOLONG) - goto out; - goto out_err; - } if (!this->d_inode) goto put_and_out; @@ -152,6 +143,25 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, return err; } +static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, + const char *name, unsigned int namelen, + size_t prelen, const char *post, + struct dentry **ret) +{ + struct dentry *this = lookup_one_len_unlocked(name, base, namelen); + int err; + + if (IS_ERR(this)) { + err = PTR_ERR(this); + *ret = NULL; + if (err == -ENOENT || err == -ENAMETOOLONG) + return 0; + return err; + } + + return ovl_lookup_data(this, d, prelen, post, ret); +} + static int ovl_lookup_layer(struct dentry *base, struct ovl_lookup_data *d, struct dentry **ret) { -- 2.7.4