Lines Matching refs:nd
533 static int __nd_alloc_stack(struct nameidata *nd) in __nd_alloc_stack() argument
537 if (nd->flags & LOOKUP_RCU) { in __nd_alloc_stack()
548 memcpy(p, nd->internal, sizeof(nd->internal)); in __nd_alloc_stack()
549 nd->stack = p; in __nd_alloc_stack()
572 static inline int nd_alloc_stack(struct nameidata *nd) in nd_alloc_stack() argument
574 if (likely(nd->depth != EMBEDDED_LEVELS)) in nd_alloc_stack()
576 if (likely(nd->stack != nd->internal)) in nd_alloc_stack()
578 return __nd_alloc_stack(nd); in nd_alloc_stack()
581 static void drop_links(struct nameidata *nd) in drop_links() argument
583 int i = nd->depth; in drop_links()
585 struct saved *last = nd->stack + i; in drop_links()
591 static void terminate_walk(struct nameidata *nd) in terminate_walk() argument
593 drop_links(nd); in terminate_walk()
594 if (!(nd->flags & LOOKUP_RCU)) { in terminate_walk()
596 path_put(&nd->path); in terminate_walk()
597 for (i = 0; i < nd->depth; i++) in terminate_walk()
598 path_put(&nd->stack[i].link); in terminate_walk()
599 if (nd->flags & LOOKUP_ROOT_GRABBED) { in terminate_walk()
600 path_put(&nd->root); in terminate_walk()
601 nd->flags &= ~LOOKUP_ROOT_GRABBED; in terminate_walk()
604 nd->flags &= ~LOOKUP_RCU; in terminate_walk()
607 nd->depth = 0; in terminate_walk()
611 static bool legitimize_path(struct nameidata *nd, in legitimize_path() argument
614 int res = __legitimize_mnt(path->mnt, nd->m_seq); in legitimize_path()
628 static bool legitimize_links(struct nameidata *nd) in legitimize_links() argument
631 for (i = 0; i < nd->depth; i++) { in legitimize_links()
632 struct saved *last = nd->stack + i; in legitimize_links()
633 if (unlikely(!legitimize_path(nd, &last->link, last->seq))) { in legitimize_links()
634 drop_links(nd); in legitimize_links()
635 nd->depth = i + 1; in legitimize_links()
642 static bool legitimize_root(struct nameidata *nd) in legitimize_root() argument
644 if (!nd->root.mnt || (nd->flags & LOOKUP_ROOT)) in legitimize_root()
646 nd->flags |= LOOKUP_ROOT_GRABBED; in legitimize_root()
647 return legitimize_path(nd, &nd->root, nd->root_seq); in legitimize_root()
672 static int unlazy_walk(struct nameidata *nd) in unlazy_walk() argument
674 struct dentry *parent = nd->path.dentry; in unlazy_walk()
676 BUG_ON(!(nd->flags & LOOKUP_RCU)); in unlazy_walk()
678 nd->flags &= ~LOOKUP_RCU; in unlazy_walk()
679 if (unlikely(!legitimize_links(nd))) in unlazy_walk()
681 if (unlikely(!legitimize_path(nd, &nd->path, nd->seq))) in unlazy_walk()
683 if (unlikely(!legitimize_root(nd))) in unlazy_walk()
686 BUG_ON(nd->inode != parent->d_inode); in unlazy_walk()
690 nd->path.mnt = NULL; in unlazy_walk()
691 nd->path.dentry = NULL; in unlazy_walk()
710 static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned seq) in unlazy_child() argument
712 BUG_ON(!(nd->flags & LOOKUP_RCU)); in unlazy_child()
714 nd->flags &= ~LOOKUP_RCU; in unlazy_child()
715 if (unlikely(!legitimize_links(nd))) in unlazy_child()
717 if (unlikely(!legitimize_mnt(nd->path.mnt, nd->m_seq))) in unlazy_child()
719 if (unlikely(!lockref_get_not_dead(&nd->path.dentry->d_lockref))) in unlazy_child()
737 if (unlikely(!legitimize_root(nd))) in unlazy_child()
743 nd->path.mnt = NULL; in unlazy_child()
745 nd->path.dentry = NULL; in unlazy_child()
773 static int complete_walk(struct nameidata *nd) in complete_walk() argument
775 struct dentry *dentry = nd->path.dentry; in complete_walk()
778 if (nd->flags & LOOKUP_RCU) { in complete_walk()
779 if (!(nd->flags & LOOKUP_ROOT)) in complete_walk()
780 nd->root.mnt = NULL; in complete_walk()
781 if (unlikely(unlazy_walk(nd))) in complete_walk()
785 if (likely(!(nd->flags & LOOKUP_JUMPED))) in complete_walk()
791 status = dentry->d_op->d_weak_revalidate(dentry, nd->flags); in complete_walk()
801 static void set_root(struct nameidata *nd) in set_root() argument
805 if (nd->flags & LOOKUP_RCU) { in set_root()
810 nd->root = fs->root; in set_root()
811 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq); in set_root()
814 get_fs_root(fs, &nd->root); in set_root()
815 nd->flags |= LOOKUP_ROOT_GRABBED; in set_root()
819 static void path_put_conditional(struct path *path, struct nameidata *nd) in path_put_conditional() argument
822 if (path->mnt != nd->path.mnt) in path_put_conditional()
827 struct nameidata *nd) in path_to_nameidata() argument
829 if (!(nd->flags & LOOKUP_RCU)) { in path_to_nameidata()
830 dput(nd->path.dentry); in path_to_nameidata()
831 if (nd->path.mnt != path->mnt) in path_to_nameidata()
832 mntput(nd->path.mnt); in path_to_nameidata()
834 nd->path.mnt = path->mnt; in path_to_nameidata()
835 nd->path.dentry = path->dentry; in path_to_nameidata()
838 static int nd_jump_root(struct nameidata *nd) in nd_jump_root() argument
840 if (nd->flags & LOOKUP_RCU) { in nd_jump_root()
842 nd->path = nd->root; in nd_jump_root()
843 d = nd->path.dentry; in nd_jump_root()
844 nd->inode = d->d_inode; in nd_jump_root()
845 nd->seq = nd->root_seq; in nd_jump_root()
846 if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq))) in nd_jump_root()
849 path_put(&nd->path); in nd_jump_root()
850 nd->path = nd->root; in nd_jump_root()
851 path_get(&nd->path); in nd_jump_root()
852 nd->inode = nd->path.dentry->d_inode; in nd_jump_root()
854 nd->flags |= LOOKUP_JUMPED; in nd_jump_root()
864 struct nameidata *nd = current->nameidata; in nd_jump_link() local
865 path_put(&nd->path); in nd_jump_link()
867 nd->path = *path; in nd_jump_link()
868 nd->inode = nd->path.dentry->d_inode; in nd_jump_link()
869 nd->flags |= LOOKUP_JUMPED; in nd_jump_link()
872 static inline void put_link(struct nameidata *nd) in put_link() argument
874 struct saved *last = nd->stack + --nd->depth; in put_link()
876 if (!(nd->flags & LOOKUP_RCU)) in put_link()
900 static inline int may_follow_link(struct nameidata *nd) in may_follow_link() argument
910 inode = nd->link_inode; in may_follow_link()
915 parent = nd->inode; in may_follow_link()
924 if (nd->flags & LOOKUP_RCU) in may_follow_link()
927 audit_inode(nd->name, nd->stack[0].link.dentry, 0); in may_follow_link()
1040 const char *get_link(struct nameidata *nd) in get_link() argument
1042 struct saved *last = nd->stack + nd->depth - 1; in get_link()
1044 struct inode *inode = nd->link_inode; in get_link()
1048 if (!(nd->flags & LOOKUP_RCU)) { in get_link()
1052 if (unlikely(unlazy_walk(nd))) in get_link()
1058 nd->flags & LOOKUP_RCU); in get_link()
1062 nd->last_type = LAST_BIND; in get_link()
1068 if (nd->flags & LOOKUP_RCU) { in get_link()
1071 if (unlikely(unlazy_walk(nd))) in get_link()
1082 if (!nd->root.mnt) in get_link()
1083 set_root(nd); in get_link()
1084 if (unlikely(nd_jump_root(nd))) in get_link()
1132 static int follow_automount(struct path *path, struct nameidata *nd, in follow_automount() argument
1152 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | in follow_automount()
1157 nd->total_link_count++; in follow_automount()
1158 if (nd->total_link_count >= 40) in follow_automount()
1172 if (PTR_ERR(mnt) == -EISDIR && (nd->flags & LOOKUP_PARENT)) in follow_automount()
1212 static int follow_managed(struct path *path, struct nameidata *nd) in follow_managed() argument
1256 ret = follow_automount(path, nd, &need_mntput); in follow_managed()
1271 nd->flags |= LOOKUP_JUMPED; in follow_managed()
1273 path_put_conditional(path, nd); in follow_managed()
1303 static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, in __follow_mount_rcu() argument
1330 nd->flags |= LOOKUP_JUMPED; in __follow_mount_rcu()
1339 return !read_seqretry(&mount_lock, nd->m_seq) && in __follow_mount_rcu()
1343 static int follow_dotdot_rcu(struct nameidata *nd) in follow_dotdot_rcu() argument
1345 struct inode *inode = nd->inode; in follow_dotdot_rcu()
1348 if (path_equal(&nd->path, &nd->root)) in follow_dotdot_rcu()
1350 if (nd->path.dentry != nd->path.mnt->mnt_root) { in follow_dotdot_rcu()
1351 struct dentry *old = nd->path.dentry; in follow_dotdot_rcu()
1357 if (unlikely(read_seqcount_retry(&old->d_seq, nd->seq))) in follow_dotdot_rcu()
1359 nd->path.dentry = parent; in follow_dotdot_rcu()
1360 nd->seq = seq; in follow_dotdot_rcu()
1361 if (unlikely(!path_connected(&nd->path))) in follow_dotdot_rcu()
1365 struct mount *mnt = real_mount(nd->path.mnt); in follow_dotdot_rcu()
1370 if (unlikely(read_seqretry(&mount_lock, nd->m_seq))) in follow_dotdot_rcu()
1372 if (&mparent->mnt == nd->path.mnt) in follow_dotdot_rcu()
1375 nd->path.dentry = mountpoint; in follow_dotdot_rcu()
1376 nd->path.mnt = &mparent->mnt; in follow_dotdot_rcu()
1378 nd->seq = seq; in follow_dotdot_rcu()
1381 while (unlikely(d_mountpoint(nd->path.dentry))) { in follow_dotdot_rcu()
1383 mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry); in follow_dotdot_rcu()
1384 if (unlikely(read_seqretry(&mount_lock, nd->m_seq))) in follow_dotdot_rcu()
1388 nd->path.mnt = &mounted->mnt; in follow_dotdot_rcu()
1389 nd->path.dentry = mounted->mnt.mnt_root; in follow_dotdot_rcu()
1390 inode = nd->path.dentry->d_inode; in follow_dotdot_rcu()
1391 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in follow_dotdot_rcu()
1393 nd->inode = inode; in follow_dotdot_rcu()
1473 static int follow_dotdot(struct nameidata *nd) in follow_dotdot() argument
1476 if (path_equal(&nd->path, &nd->root)) in follow_dotdot()
1478 if (nd->path.dentry != nd->path.mnt->mnt_root) { in follow_dotdot()
1479 int ret = path_parent_directory(&nd->path); in follow_dotdot()
1484 if (!follow_up(&nd->path)) in follow_dotdot()
1487 follow_mount(&nd->path); in follow_dotdot()
1488 nd->inode = nd->path.dentry->d_inode; in follow_dotdot()
1546 static int lookup_fast(struct nameidata *nd, in lookup_fast() argument
1550 struct vfsmount *mnt = nd->path.mnt; in lookup_fast()
1551 struct dentry *dentry, *parent = nd->path.dentry; in lookup_fast()
1560 if (nd->flags & LOOKUP_RCU) { in lookup_fast()
1563 dentry = __d_lookup_rcu(parent, &nd->last, &seq); in lookup_fast()
1565 if (unlazy_walk(nd)) in lookup_fast()
1586 if (unlikely(__read_seqcount_retry(&parent->d_seq, nd->seq))) in lookup_fast()
1590 status = d_revalidate(dentry, nd->flags); in lookup_fast()
1600 if (likely(__follow_mount_rcu(nd, path, inode, seqp))) in lookup_fast()
1603 if (unlazy_child(nd, dentry, seq)) in lookup_fast()
1607 status = d_revalidate(dentry, nd->flags); in lookup_fast()
1609 dentry = __d_lookup(parent, &nd->last); in lookup_fast()
1612 status = d_revalidate(dentry, nd->flags); in lookup_fast()
1627 err = follow_managed(path, nd); in lookup_fast()
1685 static inline int may_lookup(struct nameidata *nd) in may_lookup() argument
1687 if (nd->flags & LOOKUP_RCU) { in may_lookup()
1688 int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK); in may_lookup()
1691 if (unlazy_walk(nd)) in may_lookup()
1694 return inode_permission(nd->inode, MAY_EXEC); in may_lookup()
1697 static inline int handle_dots(struct nameidata *nd, int type) in handle_dots() argument
1700 if (!nd->root.mnt) in handle_dots()
1701 set_root(nd); in handle_dots()
1702 if (nd->flags & LOOKUP_RCU) { in handle_dots()
1703 return follow_dotdot_rcu(nd); in handle_dots()
1705 return follow_dotdot(nd); in handle_dots()
1710 static int pick_link(struct nameidata *nd, struct path *link, in pick_link() argument
1715 if (unlikely(nd->total_link_count++ >= MAXSYMLINKS)) { in pick_link()
1716 path_to_nameidata(link, nd); in pick_link()
1719 if (!(nd->flags & LOOKUP_RCU)) { in pick_link()
1720 if (link->mnt == nd->path.mnt) in pick_link()
1723 error = nd_alloc_stack(nd); in pick_link()
1726 if (unlikely(!legitimize_path(nd, link, seq))) { in pick_link()
1727 drop_links(nd); in pick_link()
1728 nd->depth = 0; in pick_link()
1729 nd->flags &= ~LOOKUP_RCU; in pick_link()
1730 nd->path.mnt = NULL; in pick_link()
1731 nd->path.dentry = NULL; in pick_link()
1733 } else if (likely(unlazy_walk(nd)) == 0) in pick_link()
1734 error = nd_alloc_stack(nd); in pick_link()
1742 last = nd->stack + nd->depth++; in pick_link()
1745 nd->link_inode = inode; in pick_link()
1758 static inline int step_into(struct nameidata *nd, struct path *path, in step_into() argument
1761 if (!(flags & WALK_MORE) && nd->depth) in step_into()
1762 put_link(nd); in step_into()
1764 !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW)) { in step_into()
1766 path_to_nameidata(path, nd); in step_into()
1767 nd->inode = inode; in step_into()
1768 nd->seq = seq; in step_into()
1772 if (nd->flags & LOOKUP_RCU) { in step_into()
1776 return pick_link(nd, path, inode, seq); in step_into()
1779 static int walk_component(struct nameidata *nd, int flags) in walk_component() argument
1790 if (unlikely(nd->last_type != LAST_NORM)) { in walk_component()
1791 err = handle_dots(nd, nd->last_type); in walk_component()
1792 if (!(flags & WALK_MORE) && nd->depth) in walk_component()
1793 put_link(nd); in walk_component()
1796 err = lookup_fast(nd, &path, &inode, &seq); in walk_component()
1800 path.dentry = lookup_slow(&nd->last, nd->path.dentry, in walk_component()
1801 nd->flags); in walk_component()
1805 path.mnt = nd->path.mnt; in walk_component()
1806 err = follow_managed(&path, nd); in walk_component()
1811 path_to_nameidata(&path, nd); in walk_component()
1819 return step_into(nd, &path, flags, inode, seq); in walk_component()
2058 static int link_path_walk(const char *name, struct nameidata *nd) in link_path_walk() argument
2074 err = may_lookup(nd); in link_path_walk()
2078 hash_len = hash_name(nd->path.dentry, name); in link_path_walk()
2085 nd->flags |= LOOKUP_JUMPED; in link_path_walk()
2092 struct dentry *parent = nd->path.dentry; in link_path_walk()
2093 nd->flags &= ~LOOKUP_JUMPED; in link_path_walk()
2104 nd->last.hash_len = hash_len; in link_path_walk()
2105 nd->last.name = name; in link_path_walk()
2106 nd->last_type = type; in link_path_walk()
2121 if (!nd->depth) in link_path_walk()
2123 name = nd->stack[nd->depth - 1].name; in link_path_walk()
2128 err = walk_component(nd, WALK_FOLLOW); in link_path_walk()
2131 err = walk_component(nd, WALK_FOLLOW | WALK_MORE); in link_path_walk()
2137 const char *s = get_link(nd); in link_path_walk()
2144 put_link(nd); in link_path_walk()
2146 nd->stack[nd->depth - 1].name = name; in link_path_walk()
2151 if (unlikely(!d_can_lookup(nd->path.dentry))) { in link_path_walk()
2152 if (nd->flags & LOOKUP_RCU) { in link_path_walk()
2153 if (unlazy_walk(nd)) in link_path_walk()
2162 static const char *path_init(struct nameidata *nd, unsigned flags) in path_init() argument
2164 const char *s = nd->name->name; in path_init()
2171 nd->last_type = LAST_ROOT; /* if there are only slashes... */ in path_init()
2172 nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; in path_init()
2173 nd->depth = 0; in path_init()
2175 struct dentry *root = nd->root.dentry; in path_init()
2179 nd->path = nd->root; in path_init()
2180 nd->inode = inode; in path_init()
2182 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2183 nd->root_seq = nd->seq; in path_init()
2184 nd->m_seq = read_seqbegin(&mount_lock); in path_init()
2186 path_get(&nd->path); in path_init()
2191 nd->root.mnt = NULL; in path_init()
2192 nd->path.mnt = NULL; in path_init()
2193 nd->path.dentry = NULL; in path_init()
2195 nd->m_seq = read_seqbegin(&mount_lock); in path_init()
2197 set_root(nd); in path_init()
2198 if (likely(!nd_jump_root(nd))) in path_init()
2201 } else if (nd->dfd == AT_FDCWD) { in path_init()
2208 nd->path = fs->pwd; in path_init()
2209 nd->inode = nd->path.dentry->d_inode; in path_init()
2210 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2213 get_fs_pwd(current->fs, &nd->path); in path_init()
2214 nd->inode = nd->path.dentry->d_inode; in path_init()
2219 struct fd f = fdget_raw(nd->dfd); in path_init()
2232 nd->path = f.file->f_path; in path_init()
2234 nd->inode = nd->path.dentry->d_inode; in path_init()
2235 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2237 path_get(&nd->path); in path_init()
2238 nd->inode = nd->path.dentry->d_inode; in path_init()
2245 static const char *trailing_symlink(struct nameidata *nd) in trailing_symlink() argument
2248 int error = may_follow_link(nd); in trailing_symlink()
2251 nd->flags |= LOOKUP_PARENT; in trailing_symlink()
2252 nd->stack[0].name = NULL; in trailing_symlink()
2253 s = get_link(nd); in trailing_symlink()
2257 static inline int lookup_last(struct nameidata *nd) in lookup_last() argument
2259 if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) in lookup_last()
2260 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; in lookup_last()
2262 nd->flags &= ~LOOKUP_PARENT; in lookup_last()
2263 return walk_component(nd, 0); in lookup_last()
2266 static int handle_lookup_down(struct nameidata *nd) in handle_lookup_down() argument
2268 struct path path = nd->path; in handle_lookup_down()
2269 struct inode *inode = nd->inode; in handle_lookup_down()
2270 unsigned seq = nd->seq; in handle_lookup_down()
2273 if (nd->flags & LOOKUP_RCU) { in handle_lookup_down()
2279 if (unlikely(!__follow_mount_rcu(nd, &path, &inode, &seq))) in handle_lookup_down()
2283 err = follow_managed(&path, nd); in handle_lookup_down()
2289 path_to_nameidata(&path, nd); in handle_lookup_down()
2290 nd->inode = inode; in handle_lookup_down()
2291 nd->seq = seq; in handle_lookup_down()
2296 static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path) in path_lookupat() argument
2298 const char *s = path_init(nd, flags); in path_lookupat()
2302 err = handle_lookup_down(nd); in path_lookupat()
2307 while (!(err = link_path_walk(s, nd)) in path_lookupat()
2308 && ((err = lookup_last(nd)) > 0)) { in path_lookupat()
2309 s = trailing_symlink(nd); in path_lookupat()
2312 err = complete_walk(nd); in path_lookupat()
2314 if (!err && nd->flags & LOOKUP_DIRECTORY) in path_lookupat()
2315 if (!d_can_lookup(nd->path.dentry)) in path_lookupat()
2318 *path = nd->path; in path_lookupat()
2319 nd->path.mnt = NULL; in path_lookupat()
2320 nd->path.dentry = NULL; in path_lookupat()
2322 terminate_walk(nd); in path_lookupat()
2330 struct nameidata nd; in filename_lookup() local
2334 nd.root = *root; in filename_lookup()
2337 set_nameidata(&nd, dfd, name); in filename_lookup()
2338 retval = path_lookupat(&nd, flags | LOOKUP_RCU, path); in filename_lookup()
2340 retval = path_lookupat(&nd, flags, path); in filename_lookup()
2342 retval = path_lookupat(&nd, flags | LOOKUP_REVAL, path); in filename_lookup()
2352 static int path_parentat(struct nameidata *nd, unsigned flags, in path_parentat() argument
2355 const char *s = path_init(nd, flags); in path_parentat()
2356 int err = link_path_walk(s, nd); in path_parentat()
2358 err = complete_walk(nd); in path_parentat()
2360 *parent = nd->path; in path_parentat()
2361 nd->path.mnt = NULL; in path_parentat()
2362 nd->path.dentry = NULL; in path_parentat()
2364 terminate_walk(nd); in path_parentat()
2373 struct nameidata nd; in filename_parentat() local
2377 set_nameidata(&nd, dfd, name); in filename_parentat()
2378 retval = path_parentat(&nd, flags | LOOKUP_RCU, parent); in filename_parentat()
2380 retval = path_parentat(&nd, flags, parent); in filename_parentat()
2382 retval = path_parentat(&nd, flags | LOOKUP_REVAL, parent); in filename_parentat()
2384 *last = nd.last; in filename_parentat()
2385 *type = nd.last_type; in filename_parentat()
2627 mountpoint_last(struct nameidata *nd) in mountpoint_last() argument
2630 struct dentry *dir = nd->path.dentry; in mountpoint_last()
2634 if (nd->flags & LOOKUP_RCU) { in mountpoint_last()
2635 if (unlazy_walk(nd)) in mountpoint_last()
2639 nd->flags &= ~LOOKUP_PARENT; in mountpoint_last()
2641 if (unlikely(nd->last_type != LAST_NORM)) { in mountpoint_last()
2642 error = handle_dots(nd, nd->last_type); in mountpoint_last()
2645 path.dentry = dget(nd->path.dentry); in mountpoint_last()
2647 path.dentry = d_lookup(dir, &nd->last); in mountpoint_last()
2655 path.dentry = lookup_slow(&nd->last, dir, in mountpoint_last()
2656 nd->flags | LOOKUP_NO_REVAL); in mountpoint_last()
2665 path.mnt = nd->path.mnt; in mountpoint_last()
2666 return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0); in mountpoint_last()
2679 path_mountpoint(struct nameidata *nd, unsigned flags, struct path *path) in path_mountpoint() argument
2681 const char *s = path_init(nd, flags); in path_mountpoint()
2684 while (!(err = link_path_walk(s, nd)) && in path_mountpoint()
2685 (err = mountpoint_last(nd)) > 0) { in path_mountpoint()
2686 s = trailing_symlink(nd); in path_mountpoint()
2689 *path = nd->path; in path_mountpoint()
2690 nd->path.mnt = NULL; in path_mountpoint()
2691 nd->path.dentry = NULL; in path_mountpoint()
2694 terminate_walk(nd); in path_mountpoint()
2702 struct nameidata nd; in filename_mountpoint() local
2706 set_nameidata(&nd, dfd, name); in filename_mountpoint()
2707 error = path_mountpoint(&nd, flags | LOOKUP_RCU, path); in filename_mountpoint()
2709 error = path_mountpoint(&nd, flags, path); in filename_mountpoint()
2711 error = path_mountpoint(&nd, flags | LOOKUP_REVAL, path); in filename_mountpoint()
3045 static int atomic_open(struct nameidata *nd, struct dentry *dentry, in atomic_open() argument
3051 struct inode *dir = nd->path.dentry->d_inode; in atomic_open()
3057 if (nd->flags & LOOKUP_DIRECTORY) in atomic_open()
3061 file->f_path.mnt = nd->path.mnt; in atomic_open()
3093 path->mnt = nd->path.mnt; in atomic_open()
3117 static int lookup_open(struct nameidata *nd, struct path *path, in lookup_open() argument
3122 struct dentry *dir = nd->path.dentry; in lookup_open()
3134 dentry = d_lookup(dir, &nd->last); in lookup_open()
3137 dentry = d_alloc_parallel(dir, &nd->last, &wq); in lookup_open()
3144 error = d_revalidate(dentry, nd->flags); in lookup_open()
3177 create_error = may_o_create(&nd->path, dentry, mode); in lookup_open()
3194 error = atomic_open(nd, dentry, path, file, op, open_flag, in lookup_open()
3204 nd->flags); in lookup_open()
3236 path->mnt = nd->path.mnt; in lookup_open()
3247 static int do_last(struct nameidata *nd, in do_last() argument
3250 struct dentry *dir = nd->path.dentry; in do_last()
3260 nd->flags &= ~LOOKUP_PARENT; in do_last()
3261 nd->flags |= op->intent; in do_last()
3263 if (nd->last_type != LAST_NORM) { in do_last()
3264 error = handle_dots(nd, nd->last_type); in do_last()
3271 if (nd->last.name[nd->last.len]) in do_last()
3272 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; in do_last()
3274 error = lookup_fast(nd, &path, &inode, &seq); in do_last()
3281 BUG_ON(nd->inode != dir->d_inode); in do_last()
3282 BUG_ON(nd->flags & LOOKUP_RCU); in do_last()
3290 error = complete_walk(nd); in do_last()
3294 audit_inode(nd->name, dir, AUDIT_INODE_PARENT); in do_last()
3296 if (unlikely(nd->last.name[nd->last.len])) in do_last()
3301 error = mnt_want_write(nd->path.mnt); in do_last()
3314 error = lookup_open(nd, &path, file, op, got_write); in do_last()
3328 audit_inode(nd->name, file->f_path.dentry, 0); in do_last()
3337 path_to_nameidata(&path, nd); in do_last()
3347 mnt_drop_write(nd->path.mnt); in do_last()
3351 error = follow_managed(&path, nd); in do_last()
3356 path_to_nameidata(&path, nd); in do_last()
3363 audit_inode(nd->name, path.dentry, 0); in do_last()
3366 path_to_nameidata(&path, nd); in do_last()
3373 error = step_into(nd, &path, 0, inode, seq); in do_last()
3378 error = complete_walk(nd); in do_last()
3381 audit_inode(nd->name, nd->path.dentry, 0); in do_last()
3384 if (d_is_dir(nd->path.dentry)) in do_last()
3387 d_backing_inode(nd->path.dentry)); in do_last()
3392 if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) in do_last()
3394 if (!d_is_reg(nd->path.dentry)) in do_last()
3398 error = mnt_want_write(nd->path.mnt); in do_last()
3404 error = may_open(&nd->path, acc_mode, open_flag); in do_last()
3408 error = vfs_open(&nd->path, file); in do_last()
3421 mnt_drop_write(nd->path.mnt); in do_last()
3464 static int do_tmpfile(struct nameidata *nd, unsigned flags, in do_tmpfile() argument
3470 int error = path_lookupat(nd, flags | LOOKUP_DIRECTORY, &path); in do_tmpfile()
3482 audit_inode(nd->name, child, 0); in do_tmpfile()
3496 static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file) in do_o_path() argument
3499 int error = path_lookupat(nd, flags, &path); in do_o_path()
3501 audit_inode(nd->name, path.dentry, 0); in do_o_path()
3508 static struct file *path_openat(struct nameidata *nd, in path_openat() argument
3519 error = do_tmpfile(nd, flags, op, file); in path_openat()
3521 error = do_o_path(nd, flags, file); in path_openat()
3523 const char *s = path_init(nd, flags); in path_openat()
3524 while (!(error = link_path_walk(s, nd)) && in path_openat()
3525 (error = do_last(nd, file, op)) > 0) { in path_openat()
3526 nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL); in path_openat()
3527 s = trailing_symlink(nd); in path_openat()
3529 terminate_walk(nd); in path_openat()
3550 struct nameidata nd; in do_filp_open() local
3554 set_nameidata(&nd, dfd, pathname); in do_filp_open()
3555 filp = path_openat(&nd, op, flags | LOOKUP_RCU); in do_filp_open()
3557 filp = path_openat(&nd, op, flags); in do_filp_open()
3559 filp = path_openat(&nd, op, flags | LOOKUP_REVAL); in do_filp_open()
3567 struct nameidata nd; in do_file_open_root() local
3572 nd.root.mnt = mnt; in do_file_open_root()
3573 nd.root.dentry = dentry; in do_file_open_root()
3582 set_nameidata(&nd, -1, filename); in do_file_open_root()
3583 file = path_openat(&nd, op, flags | LOOKUP_RCU); in do_file_open_root()
3585 file = path_openat(&nd, op, flags); in do_file_open_root()
3587 file = path_openat(&nd, op, flags | LOOKUP_REVAL); in do_file_open_root()