diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2019-07-16 21:05:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2019-08-30 21:30:13 -0400 |
commit | ee594bfff389aa9105f713135211c0da736e5698 (patch) | |
tree | 6307646c6e58ce9475cc7f248262c90af3d46dd2 | |
parent | ce6595a28a15c874aee374757dcd08f537d7b24d (diff) | |
download | linux-ee594bfff389aa9105f713135211c0da736e5698.tar.bz2 |
fs/namei.c: new helper - legitimize_root()
identical logics in unlazy_walk() and unlazy_child()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namei.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/namei.c b/fs/namei.c index 3fca26398bc2..2af485ddc507 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -641,6 +641,13 @@ static bool legitimize_links(struct nameidata *nd) return true; } +static bool legitimize_root(struct nameidata *nd) +{ + if (!nd->root.mnt || (nd->flags & LOOKUP_ROOT)) + return true; + return legitimize_path(nd, &nd->root, nd->root_seq); +} + /* * Path walking has 2 modes, rcu-walk and ref-walk (see * Documentation/filesystems/path-lookup.txt). In situations when we can't @@ -674,10 +681,8 @@ static int unlazy_walk(struct nameidata *nd) goto out2; if (unlikely(!legitimize_path(nd, &nd->path, nd->seq))) goto out1; - if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { - if (unlikely(!legitimize_path(nd, &nd->root, nd->root_seq))) - goto out; - } + if (unlikely(!legitimize_root(nd))) + goto out; rcu_read_unlock(); BUG_ON(nd->inode != parent->d_inode); return 0; @@ -736,12 +741,10 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se * Sequence counts matched. Now make sure that the root is * still valid and get it if required. */ - if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { - if (unlikely(!legitimize_path(nd, &nd->root, nd->root_seq))) { - rcu_read_unlock(); - dput(dentry); - return -ECHILD; - } + if (unlikely(!legitimize_root(nd))) { + rcu_read_unlock(); + dput(dentry); + return -ECHILD; } rcu_read_unlock(); |