Commit 9b4a9b14a793bc69b505ed916051f6f32db13bb8
1 parent
4e44b6852e
Exists in
master
and in
20 other branches
Preparations to caching root in path_walk()
Split do_path_lookup(), opencode the call from do_filp_open() do_filp_open() is the only caller of do_path_lookup() that cares about root afterwards (it keeps resolving symlinks on O_CREAT path after it'd done LOOKUP_PARENT walk). So when we start caching fs->root in path_walk(), it'll need a different treatment. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 21 additions and 10 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -1017,9 +1017,7 @@ |
1017 | 1017 | return link_path_walk(name, nd); |
1018 | 1018 | } |
1019 | 1019 | |
1020 | -/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ | |
1021 | -static int do_path_lookup(int dfd, const char *name, | |
1022 | - unsigned int flags, struct nameidata *nd) | |
1020 | +static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) | |
1023 | 1021 | { |
1024 | 1022 | int retval = 0; |
1025 | 1023 | int fput_needed; |
1026 | 1024 | |
1027 | 1025 | |
1028 | 1026 | |
... | ... | @@ -1063,17 +1061,25 @@ |
1063 | 1061 | |
1064 | 1062 | fput_light(file, fput_needed); |
1065 | 1063 | } |
1064 | + return 0; | |
1066 | 1065 | |
1067 | - retval = path_walk(name, nd); | |
1066 | +fput_fail: | |
1067 | + fput_light(file, fput_needed); | |
1068 | +out_fail: | |
1069 | + return retval; | |
1070 | +} | |
1071 | + | |
1072 | +/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ | |
1073 | +static int do_path_lookup(int dfd, const char *name, | |
1074 | + unsigned int flags, struct nameidata *nd) | |
1075 | +{ | |
1076 | + int retval = path_init(dfd, name, flags, nd); | |
1077 | + if (!retval) | |
1078 | + retval = path_walk(name, nd); | |
1068 | 1079 | if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry && |
1069 | 1080 | nd->path.dentry->d_inode)) |
1070 | 1081 | audit_inode(name, nd->path.dentry); |
1071 | -out_fail: | |
1072 | 1082 | return retval; |
1073 | - | |
1074 | -fput_fail: | |
1075 | - fput_light(file, fput_needed); | |
1076 | - goto out_fail; | |
1077 | 1083 | } |
1078 | 1084 | |
1079 | 1085 | int path_lookup(const char *name, unsigned int flags, |
1080 | 1086 | |
... | ... | @@ -1676,9 +1682,14 @@ |
1676 | 1682 | /* |
1677 | 1683 | * Create - we need to know the parent. |
1678 | 1684 | */ |
1679 | - error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd); | |
1685 | + error = path_init(dfd, pathname, LOOKUP_PARENT, &nd); | |
1680 | 1686 | if (error) |
1681 | 1687 | return ERR_PTR(error); |
1688 | + error = path_walk(pathname, &nd); | |
1689 | + if (error) | |
1690 | + return ERR_PTR(error); | |
1691 | + if (unlikely(!audit_dummy_context())) | |
1692 | + audit_inode(pathname, nd.path.dentry); | |
1682 | 1693 | |
1683 | 1694 | /* |
1684 | 1695 | * We have the parent and last component. First of all, check |