Lines Matching refs:nd

547 static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)  in unlazy_walk()  argument
550 struct dentry *parent = nd->path.dentry; in unlazy_walk()
552 BUG_ON(!(nd->flags & LOOKUP_RCU)); in unlazy_walk()
562 if (!legitimize_mnt(nd->path.mnt, nd->m_seq)) in unlazy_walk()
564 nd->flags &= ~LOOKUP_RCU; in unlazy_walk()
567 nd->path.dentry = NULL; in unlazy_walk()
583 if (read_seqcount_retry(&parent->d_seq, nd->seq)) in unlazy_walk()
585 BUG_ON(nd->inode != parent->d_inode); in unlazy_walk()
589 if (read_seqcount_retry(&dentry->d_seq, nd->seq)) in unlazy_walk()
597 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { in unlazy_walk()
599 if (nd->root.mnt != fs->root.mnt || nd->root.dentry != fs->root.dentry) in unlazy_walk()
601 path_get(&nd->root); in unlazy_walk()
617 if (!(nd->flags & LOOKUP_ROOT)) in unlazy_walk()
618 nd->root.mnt = NULL; in unlazy_walk()
637 static int complete_walk(struct nameidata *nd) in complete_walk() argument
639 struct dentry *dentry = nd->path.dentry; in complete_walk()
642 if (nd->flags & LOOKUP_RCU) { in complete_walk()
643 nd->flags &= ~LOOKUP_RCU; in complete_walk()
644 if (!(nd->flags & LOOKUP_ROOT)) in complete_walk()
645 nd->root.mnt = NULL; in complete_walk()
647 if (!legitimize_mnt(nd->path.mnt, nd->m_seq)) { in complete_walk()
653 mntput(nd->path.mnt); in complete_walk()
656 if (read_seqcount_retry(&dentry->d_seq, nd->seq)) { in complete_walk()
659 mntput(nd->path.mnt); in complete_walk()
665 if (likely(!(nd->flags & LOOKUP_JUMPED))) in complete_walk()
671 status = dentry->d_op->d_weak_revalidate(dentry, nd->flags); in complete_walk()
678 path_put(&nd->path); in complete_walk()
682 static __always_inline void set_root(struct nameidata *nd) in set_root() argument
684 get_fs_root(current->fs, &nd->root); in set_root()
689 static __always_inline unsigned set_root_rcu(struct nameidata *nd) in set_root_rcu() argument
696 nd->root = fs->root; in set_root_rcu()
697 res = __read_seqcount_begin(&nd->root.dentry->d_seq); in set_root_rcu()
702 static void path_put_conditional(struct path *path, struct nameidata *nd) in path_put_conditional() argument
705 if (path->mnt != nd->path.mnt) in path_put_conditional()
710 struct nameidata *nd) in path_to_nameidata() argument
712 if (!(nd->flags & LOOKUP_RCU)) { in path_to_nameidata()
713 dput(nd->path.dentry); in path_to_nameidata()
714 if (nd->path.mnt != path->mnt) in path_to_nameidata()
715 mntput(nd->path.mnt); in path_to_nameidata()
717 nd->path.mnt = path->mnt; in path_to_nameidata()
718 nd->path.dentry = path->dentry; in path_to_nameidata()
725 void nd_jump_link(struct nameidata *nd, struct path *path) in nd_jump_link() argument
727 path_put(&nd->path); in nd_jump_link()
729 nd->path = *path; in nd_jump_link()
730 nd->inode = nd->path.dentry->d_inode; in nd_jump_link()
731 nd->flags |= LOOKUP_JUMPED; in nd_jump_link()
734 void nd_set_link(struct nameidata *nd, char *path) in nd_set_link() argument
736 nd->saved_names[nd->depth] = path; in nd_set_link()
740 char *nd_get_link(struct nameidata *nd) in nd_get_link() argument
742 return nd->saved_names[nd->depth]; in nd_get_link()
746 static inline void put_link(struct nameidata *nd, struct path *link, void *cookie) in put_link() argument
750 inode->i_op->put_link(link->dentry, nd, cookie); in put_link()
773 static inline int may_follow_link(struct path *link, struct nameidata *nd) in may_follow_link() argument
787 parent = nd->path.dentry->d_inode; in may_follow_link()
796 path_put_conditional(link, nd); in may_follow_link()
797 path_put(&nd->path); in may_follow_link()
871 follow_link(struct path *link, struct nameidata *nd, void **p) in follow_link() argument
877 BUG_ON(nd->flags & LOOKUP_RCU); in follow_link()
879 if (link->mnt == nd->path.mnt) in follow_link()
890 nd_set_link(nd, NULL); in follow_link()
892 error = security_inode_follow_link(link->dentry, nd); in follow_link()
896 nd->last_type = LAST_BIND; in follow_link()
897 *p = dentry->d_inode->i_op->follow_link(dentry, nd); in follow_link()
903 s = nd_get_link(nd); in follow_link()
906 path_put(&nd->path); in follow_link()
907 put_link(nd, link, *p); in follow_link()
911 if (!nd->root.mnt) in follow_link()
912 set_root(nd); in follow_link()
913 path_put(&nd->path); in follow_link()
914 nd->path = nd->root; in follow_link()
915 path_get(&nd->root); in follow_link()
916 nd->flags |= LOOKUP_JUMPED; in follow_link()
918 nd->inode = nd->path.dentry->d_inode; in follow_link()
919 error = link_path_walk(s, nd); in follow_link()
921 put_link(nd, link, *p); in follow_link()
928 path_put(&nd->path); in follow_link()
1153 static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, in __follow_mount_rcu() argument
1180 nd->flags |= LOOKUP_JUMPED; in __follow_mount_rcu()
1181 nd->seq = read_seqcount_begin(&path->dentry->d_seq); in __follow_mount_rcu()
1189 return !read_seqretry(&mount_lock, nd->m_seq) && in __follow_mount_rcu()
1193 static int follow_dotdot_rcu(struct nameidata *nd) in follow_dotdot_rcu() argument
1195 struct inode *inode = nd->inode; in follow_dotdot_rcu()
1196 if (!nd->root.mnt) in follow_dotdot_rcu()
1197 set_root_rcu(nd); in follow_dotdot_rcu()
1200 if (nd->path.dentry == nd->root.dentry && in follow_dotdot_rcu()
1201 nd->path.mnt == nd->root.mnt) { in follow_dotdot_rcu()
1204 if (nd->path.dentry != nd->path.mnt->mnt_root) { in follow_dotdot_rcu()
1205 struct dentry *old = nd->path.dentry; in follow_dotdot_rcu()
1211 if (read_seqcount_retry(&old->d_seq, nd->seq)) in follow_dotdot_rcu()
1213 nd->path.dentry = parent; in follow_dotdot_rcu()
1214 nd->seq = seq; in follow_dotdot_rcu()
1215 if (unlikely(!path_connected(&nd->path))) in follow_dotdot_rcu()
1219 if (!follow_up_rcu(&nd->path)) in follow_dotdot_rcu()
1221 inode = nd->path.dentry->d_inode; in follow_dotdot_rcu()
1222 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in follow_dotdot_rcu()
1224 while (d_mountpoint(nd->path.dentry)) { in follow_dotdot_rcu()
1226 mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry); in follow_dotdot_rcu()
1229 nd->path.mnt = &mounted->mnt; in follow_dotdot_rcu()
1230 nd->path.dentry = mounted->mnt.mnt_root; in follow_dotdot_rcu()
1231 inode = nd->path.dentry->d_inode; in follow_dotdot_rcu()
1232 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in follow_dotdot_rcu()
1233 if (read_seqretry(&mount_lock, nd->m_seq)) in follow_dotdot_rcu()
1236 nd->inode = inode; in follow_dotdot_rcu()
1240 nd->flags &= ~LOOKUP_RCU; in follow_dotdot_rcu()
1241 if (!(nd->flags & LOOKUP_ROOT)) in follow_dotdot_rcu()
1242 nd->root.mnt = NULL; in follow_dotdot_rcu()
1313 static int follow_dotdot(struct nameidata *nd) in follow_dotdot() argument
1315 if (!nd->root.mnt) in follow_dotdot()
1316 set_root(nd); in follow_dotdot()
1319 struct dentry *old = nd->path.dentry; in follow_dotdot()
1321 if (nd->path.dentry == nd->root.dentry && in follow_dotdot()
1322 nd->path.mnt == nd->root.mnt) { in follow_dotdot()
1325 if (nd->path.dentry != nd->path.mnt->mnt_root) { in follow_dotdot()
1327 nd->path.dentry = dget_parent(nd->path.dentry); in follow_dotdot()
1329 if (unlikely(!path_connected(&nd->path))) { in follow_dotdot()
1330 path_put(&nd->path); in follow_dotdot()
1335 if (!follow_up(&nd->path)) in follow_dotdot()
1338 follow_mount(&nd->path); in follow_dotdot()
1339 nd->inode = nd->path.dentry->d_inode; in follow_dotdot()
1427 static int lookup_fast(struct nameidata *nd, in lookup_fast() argument
1430 struct vfsmount *mnt = nd->path.mnt; in lookup_fast()
1431 struct dentry *dentry, *parent = nd->path.dentry; in lookup_fast()
1441 if (nd->flags & LOOKUP_RCU) { in lookup_fast()
1444 dentry = __d_lookup_rcu(parent, &nd->last, &seq); in lookup_fast()
1464 if (__read_seqcount_retry(&parent->d_seq, nd->seq)) in lookup_fast()
1466 nd->seq = seq; in lookup_fast()
1469 status = d_revalidate(dentry, nd->flags); in lookup_fast()
1484 if (likely(__follow_mount_rcu(nd, path, inode))) in lookup_fast()
1487 if (unlazy_walk(nd, dentry)) in lookup_fast()
1490 dentry = __d_lookup(parent, &nd->last); in lookup_fast()
1497 status = d_revalidate(dentry, nd->flags); in lookup_fast()
1514 err = follow_managed(path, nd->flags); in lookup_fast()
1516 path_put_conditional(path, nd); in lookup_fast()
1520 nd->flags |= LOOKUP_JUMPED; in lookup_fast()
1529 static int lookup_slow(struct nameidata *nd, struct path *path) in lookup_slow() argument
1534 parent = nd->path.dentry; in lookup_slow()
1535 BUG_ON(nd->inode != parent->d_inode); in lookup_slow()
1538 dentry = __lookup_hash(&nd->last, parent, nd->flags); in lookup_slow()
1542 path->mnt = nd->path.mnt; in lookup_slow()
1544 err = follow_managed(path, nd->flags); in lookup_slow()
1546 path_put_conditional(path, nd); in lookup_slow()
1550 nd->flags |= LOOKUP_JUMPED; in lookup_slow()
1554 static inline int may_lookup(struct nameidata *nd) in may_lookup() argument
1556 if (nd->flags & LOOKUP_RCU) { in may_lookup()
1557 int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK); in may_lookup()
1560 if (unlazy_walk(nd, NULL)) in may_lookup()
1563 return inode_permission(nd->inode, MAY_EXEC); in may_lookup()
1566 static inline int handle_dots(struct nameidata *nd, int type) in handle_dots() argument
1569 if (nd->flags & LOOKUP_RCU) { in handle_dots()
1570 if (follow_dotdot_rcu(nd)) in handle_dots()
1573 return follow_dotdot(nd); in handle_dots()
1578 static void terminate_walk(struct nameidata *nd) in terminate_walk() argument
1580 if (!(nd->flags & LOOKUP_RCU)) { in terminate_walk()
1581 path_put(&nd->path); in terminate_walk()
1583 nd->flags &= ~LOOKUP_RCU; in terminate_walk()
1584 if (!(nd->flags & LOOKUP_ROOT)) in terminate_walk()
1585 nd->root.mnt = NULL; in terminate_walk()
1601 static inline int walk_component(struct nameidata *nd, struct path *path, in walk_component() argument
1611 if (unlikely(nd->last_type != LAST_NORM)) in walk_component()
1612 return handle_dots(nd, nd->last_type); in walk_component()
1613 err = lookup_fast(nd, path, &inode); in walk_component()
1618 err = lookup_slow(nd, path); in walk_component()
1629 if (nd->flags & LOOKUP_RCU) { in walk_component()
1630 if (unlikely(nd->path.mnt != path->mnt || in walk_component()
1631 unlazy_walk(nd, path->dentry))) { in walk_component()
1639 path_to_nameidata(path, nd); in walk_component()
1640 nd->inode = inode; in walk_component()
1644 path_to_nameidata(path, nd); in walk_component()
1646 terminate_walk(nd); in walk_component()
1657 static inline int nested_symlink(struct path *path, struct nameidata *nd) in nested_symlink() argument
1662 path_put_conditional(path, nd); in nested_symlink()
1663 path_put(&nd->path); in nested_symlink()
1666 BUG_ON(nd->depth >= MAX_NESTED_LINKS); in nested_symlink()
1668 nd->depth++; in nested_symlink()
1675 res = follow_link(&link, nd, &cookie); in nested_symlink()
1678 res = walk_component(nd, path, LOOKUP_FOLLOW); in nested_symlink()
1679 put_link(nd, &link, cookie); in nested_symlink()
1683 nd->depth--; in nested_symlink()
1811 static int link_path_walk(const char *name, struct nameidata *nd) in link_path_walk() argument
1826 err = may_lookup(nd); in link_path_walk()
1837 nd->flags |= LOOKUP_JUMPED; in link_path_walk()
1844 struct dentry *parent = nd->path.dentry; in link_path_walk()
1845 nd->flags &= ~LOOKUP_JUMPED; in link_path_walk()
1856 nd->last.hash_len = hash_len; in link_path_walk()
1857 nd->last.name = name; in link_path_walk()
1858 nd->last_type = type; in link_path_walk()
1873 err = walk_component(nd, &next, LOOKUP_FOLLOW); in link_path_walk()
1878 err = nested_symlink(&next, nd); in link_path_walk()
1882 if (!d_can_lookup(nd->path.dentry)) { in link_path_walk()
1887 terminate_walk(nd); in link_path_walk()
1892 struct nameidata *nd) in path_init() argument
1897 nd->last_type = LAST_ROOT; /* if there are only slashes... */ in path_init()
1898 nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; in path_init()
1899 nd->depth = 0; in path_init()
1900 nd->base = NULL; in path_init()
1902 struct dentry *root = nd->root.dentry; in path_init()
1911 nd->path = nd->root; in path_init()
1912 nd->inode = inode; in path_init()
1915 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
1916 nd->m_seq = read_seqbegin(&mount_lock); in path_init()
1918 path_get(&nd->path); in path_init()
1923 nd->root.mnt = NULL; in path_init()
1925 nd->m_seq = read_seqbegin(&mount_lock); in path_init()
1929 nd->seq = set_root_rcu(nd); in path_init()
1931 set_root(nd); in path_init()
1932 path_get(&nd->root); in path_init()
1934 nd->path = nd->root; in path_init()
1944 nd->path = fs->pwd; in path_init()
1945 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
1948 get_fs_pwd(current->fs, &nd->path); in path_init()
1967 nd->path = f.file->f_path; in path_init()
1970 nd->base = f.file; in path_init()
1971 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
1974 path_get(&nd->path); in path_init()
1979 nd->inode = nd->path.dentry->d_inode; in path_init()
1982 if (likely(!read_seqcount_retry(&nd->path.dentry->d_seq, nd->seq))) in path_init()
1984 if (!(nd->flags & LOOKUP_ROOT)) in path_init()
1985 nd->root.mnt = NULL; in path_init()
1990 return link_path_walk(s, nd); in path_init()
1993 static void path_cleanup(struct nameidata *nd) in path_cleanup() argument
1995 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { in path_cleanup()
1996 path_put(&nd->root); in path_cleanup()
1997 nd->root.mnt = NULL; in path_cleanup()
1999 if (unlikely(nd->base)) in path_cleanup()
2000 fput(nd->base); in path_cleanup()
2003 static inline int lookup_last(struct nameidata *nd, struct path *path) in lookup_last() argument
2005 if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) in lookup_last()
2006 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; in lookup_last()
2008 nd->flags &= ~LOOKUP_PARENT; in lookup_last()
2009 return walk_component(nd, path, nd->flags & LOOKUP_FOLLOW); in lookup_last()
2014 unsigned int flags, struct nameidata *nd) in path_lookupat() argument
2033 err = path_init(dfd, name, flags, nd); in path_lookupat()
2035 err = lookup_last(nd, &path); in path_lookupat()
2039 err = may_follow_link(&link, nd); in path_lookupat()
2042 nd->flags |= LOOKUP_PARENT; in path_lookupat()
2043 err = follow_link(&link, nd, &cookie); in path_lookupat()
2046 err = lookup_last(nd, &path); in path_lookupat()
2047 put_link(nd, &link, cookie); in path_lookupat()
2052 err = complete_walk(nd); in path_lookupat()
2054 if (!err && nd->flags & LOOKUP_DIRECTORY) { in path_lookupat()
2055 if (!d_can_lookup(nd->path.dentry)) { in path_lookupat()
2056 path_put(&nd->path); in path_lookupat()
2061 path_cleanup(nd); in path_lookupat()
2066 unsigned int flags, struct nameidata *nd) in filename_lookup() argument
2068 int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd); in filename_lookup()
2070 retval = path_lookupat(dfd, name, flags, nd); in filename_lookup()
2072 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd); in filename_lookup()
2075 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT); in filename_lookup()
2083 struct nameidata nd; in kern_path_locked() local
2090 err = filename_lookup(AT_FDCWD, filename, LOOKUP_PARENT, &nd); in kern_path_locked()
2095 if (nd.last_type != LAST_NORM) { in kern_path_locked()
2096 path_put(&nd.path); in kern_path_locked()
2100 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); in kern_path_locked()
2101 d = __lookup_hash(&nd.last, nd.path.dentry, 0); in kern_path_locked()
2103 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); in kern_path_locked()
2104 path_put(&nd.path); in kern_path_locked()
2107 *path = nd.path; in kern_path_locked()
2115 struct nameidata nd; in kern_path() local
2120 res = filename_lookup(AT_FDCWD, filename, flags, &nd); in kern_path()
2123 *path = nd.path; in kern_path()
2148 struct nameidata nd; in vfs_path_lookup() local
2149 nd.root.dentry = dentry; in vfs_path_lookup()
2150 nd.root.mnt = mnt; in vfs_path_lookup()
2152 flags | LOOKUP_ROOT, &nd); in vfs_path_lookup()
2154 *path = nd.path; in vfs_path_lookup()
2166 static struct dentry *lookup_hash(struct nameidata *nd) in lookup_hash() argument
2168 return __lookup_hash(&nd->last, nd->path.dentry, nd->flags); in lookup_hash()
2225 struct nameidata nd; in user_path_at_empty() local
2232 err = filename_lookup(dfd, tmp, flags, &nd); in user_path_at_empty()
2235 *path = nd.path; in user_path_at_empty()
2254 user_path_parent(int dfd, const char __user *path, struct nameidata *nd, in user_path_parent() argument
2266 error = filename_lookup(dfd, s, flags | LOOKUP_PARENT, nd); in user_path_parent()
2303 mountpoint_last(struct nameidata *nd, struct path *path) in mountpoint_last() argument
2307 struct dentry *dir = nd->path.dentry; in mountpoint_last()
2310 if (nd->flags & LOOKUP_RCU) { in mountpoint_last()
2311 if (unlazy_walk(nd, NULL)) { in mountpoint_last()
2317 nd->flags &= ~LOOKUP_PARENT; in mountpoint_last()
2319 if (unlikely(nd->last_type != LAST_NORM)) { in mountpoint_last()
2320 error = handle_dots(nd, nd->last_type); in mountpoint_last()
2323 dentry = dget(nd->path.dentry); in mountpoint_last()
2328 dentry = d_lookup(dir, &nd->last); in mountpoint_last()
2335 dentry = d_alloc(dir, &nd->last); in mountpoint_last()
2341 dentry = lookup_real(dir->d_inode, dentry, nd->flags); in mountpoint_last()
2357 path->mnt = nd->path.mnt; in mountpoint_last()
2358 if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW)) in mountpoint_last()
2364 terminate_walk(nd); in mountpoint_last()
2382 struct nameidata nd; in path_mountpoint() local
2385 err = path_init(dfd, name, flags, &nd); in path_mountpoint()
2389 err = mountpoint_last(&nd, path); in path_mountpoint()
2393 err = may_follow_link(&link, &nd); in path_mountpoint()
2396 nd.flags |= LOOKUP_PARENT; in path_mountpoint()
2397 err = follow_link(&link, &nd, &cookie); in path_mountpoint()
2400 err = mountpoint_last(&nd, path); in path_mountpoint()
2401 put_link(&nd, &link, cookie); in path_mountpoint()
2404 path_cleanup(&nd); in path_mountpoint()
2711 static int atomic_open(struct nameidata *nd, struct dentry *dentry, in atomic_open() argument
2717 struct inode *dir = nd->path.dentry->d_inode; in atomic_open()
2771 error = may_o_create(&nd->path, dentry, mode); in atomic_open()
2780 if (nd->flags & LOOKUP_DIRECTORY) in atomic_open()
2784 file->f_path.mnt = nd->path.mnt; in atomic_open()
2839 dentry = lookup_real(dir, dentry, nd->flags); in atomic_open()
2849 path->mnt = nd->path.mnt; in atomic_open()
2871 static int lookup_open(struct nameidata *nd, struct path *path, in lookup_open() argument
2876 struct dentry *dir = nd->path.dentry; in lookup_open()
2883 dentry = lookup_dcache(&nd->last, dir, nd->flags, &need_lookup); in lookup_open()
2891 if ((nd->flags & LOOKUP_OPEN) && dir_inode->i_op->atomic_open) { in lookup_open()
2892 return atomic_open(nd, dentry, path, file, op, got_write, in lookup_open()
2899 dentry = lookup_real(dir_inode, dentry, nd->flags); in lookup_open()
2921 error = security_path_mknod(&nd->path, dentry, mode, 0); in lookup_open()
2925 nd->flags & LOOKUP_EXCL); in lookup_open()
2931 path->mnt = nd->path.mnt; in lookup_open()
2942 static int do_last(struct nameidata *nd, struct path *path, in do_last() argument
2946 struct dentry *dir = nd->path.dentry; in do_last()
2957 nd->flags &= ~LOOKUP_PARENT; in do_last()
2958 nd->flags |= op->intent; in do_last()
2960 if (nd->last_type != LAST_NORM) { in do_last()
2961 error = handle_dots(nd, nd->last_type); in do_last()
2968 if (nd->last.name[nd->last.len]) in do_last()
2969 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; in do_last()
2970 if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) in do_last()
2973 error = lookup_fast(nd, path, &inode); in do_last()
2980 BUG_ON(nd->inode != dir->d_inode); in do_last()
2988 error = complete_walk(nd); in do_last()
2995 if (nd->last.name[nd->last.len]) in do_last()
3001 error = mnt_want_write(nd->path.mnt); in do_last()
3011 error = lookup_open(nd, path, file, op, got_write, opened); in do_last()
3031 path_to_nameidata(path, nd); in do_last()
3047 mnt_drop_write(nd->path.mnt); in do_last()
3055 error = follow_managed(path, nd->flags); in do_last()
3060 nd->flags |= LOOKUP_JUMPED; in do_last()
3062 BUG_ON(nd->flags & LOOKUP_RCU); in do_last()
3066 path_to_nameidata(path, nd); in do_last()
3073 if (nd->flags & LOOKUP_RCU) { in do_last()
3074 if (unlikely(nd->path.mnt != path->mnt || in do_last()
3075 unlazy_walk(nd, path->dentry))) { in do_last()
3084 if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { in do_last()
3085 path_to_nameidata(path, nd); in do_last()
3087 save_parent.dentry = nd->path.dentry; in do_last()
3089 nd->path.dentry = path->dentry; in do_last()
3092 nd->inode = inode; in do_last()
3095 error = complete_walk(nd); in do_last()
3100 audit_inode(name, nd->path.dentry, 0); in do_last()
3102 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) in do_last()
3105 if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) in do_last()
3107 if (!d_is_reg(nd->path.dentry)) in do_last()
3111 error = mnt_want_write(nd->path.mnt); in do_last()
3117 error = may_open(&nd->path, acc_mode, open_flag); in do_last()
3122 error = vfs_open(&nd->path, file, current_cred()); in do_last()
3149 mnt_drop_write(nd->path.mnt); in do_last()
3151 terminate_walk(nd); in do_last()
3155 path_put_conditional(path, nd); in do_last()
3167 path_put(&nd->path); in do_last()
3168 nd->path = save_parent; in do_last()
3169 nd->inode = dir->d_inode; in do_last()
3173 mnt_drop_write(nd->path.mnt); in do_last()
3181 struct nameidata *nd, int flags, in do_tmpfile() argument
3189 flags | LOOKUP_DIRECTORY, nd); in do_tmpfile()
3192 error = mnt_want_write(nd->path.mnt); in do_tmpfile()
3196 error = inode_permission(nd->inode, MAY_WRITE | MAY_EXEC); in do_tmpfile()
3199 dentry = nd->path.dentry; in do_tmpfile()
3210 nd->flags &= ~LOOKUP_DIRECTORY; in do_tmpfile()
3211 nd->flags |= op->intent; in do_tmpfile()
3212 dput(nd->path.dentry); in do_tmpfile()
3213 nd->path.dentry = child; in do_tmpfile()
3214 error = dir->i_op->tmpfile(dir, nd->path.dentry, op->mode); in do_tmpfile()
3217 audit_inode(pathname, nd->path.dentry, 0); in do_tmpfile()
3219 error = may_open(&nd->path, MAY_OPEN, op->open_flag); in do_tmpfile()
3222 file->f_path.mnt = nd->path.mnt; in do_tmpfile()
3223 error = finish_open(file, nd->path.dentry, NULL, opened); in do_tmpfile()
3236 mnt_drop_write(nd->path.mnt); in do_tmpfile()
3238 path_put(&nd->path); in do_tmpfile()
3243 struct nameidata *nd, const struct open_flags *op, int flags) in path_openat() argument
3257 error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened); in path_openat()
3261 error = path_init(dfd, pathname, flags, nd); in path_openat()
3265 error = do_last(nd, &path, file, op, &opened, pathname); in path_openat()
3269 if (!(nd->flags & LOOKUP_FOLLOW)) { in path_openat()
3270 path_put_conditional(&path, nd); in path_openat()
3271 path_put(&nd->path); in path_openat()
3275 error = may_follow_link(&link, nd); in path_openat()
3278 nd->flags |= LOOKUP_PARENT; in path_openat()
3279 nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL); in path_openat()
3280 error = follow_link(&link, nd, &cookie); in path_openat()
3283 error = do_last(nd, &path, file, op, &opened, pathname); in path_openat()
3284 put_link(nd, &link, cookie); in path_openat()
3287 path_cleanup(nd); in path_openat()
3308 struct nameidata nd; in do_filp_open() local
3312 filp = path_openat(dfd, pathname, &nd, op, flags | LOOKUP_RCU); in do_filp_open()
3314 filp = path_openat(dfd, pathname, &nd, op, flags); in do_filp_open()
3316 filp = path_openat(dfd, pathname, &nd, op, flags | LOOKUP_REVAL); in do_filp_open()
3323 struct nameidata nd; in do_file_open_root() local
3328 nd.root.mnt = mnt; in do_file_open_root()
3329 nd.root.dentry = dentry; in do_file_open_root()
3338 file = path_openat(-1, filename, &nd, op, flags | LOOKUP_RCU); in do_file_open_root()
3340 file = path_openat(-1, filename, &nd, op, flags); in do_file_open_root()
3342 file = path_openat(-1, filename, &nd, op, flags | LOOKUP_REVAL); in do_file_open_root()
3351 struct nameidata nd; in filename_create() local
3362 error = filename_lookup(dfd, name, LOOKUP_PARENT|lookup_flags, &nd); in filename_create()
3370 if (nd.last_type != LAST_NORM) in filename_create()
3372 nd.flags &= ~LOOKUP_PARENT; in filename_create()
3373 nd.flags |= LOOKUP_CREATE | LOOKUP_EXCL; in filename_create()
3376 err2 = mnt_want_write(nd.path.mnt); in filename_create()
3380 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); in filename_create()
3381 dentry = lookup_hash(&nd); in filename_create()
3395 if (unlikely(!is_dir && nd.last.name[nd.last.len])) { in filename_create()
3403 *path = nd.path; in filename_create()
3409 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); in filename_create()
3411 mnt_drop_write(nd.path.mnt); in filename_create()
3413 path_put(&nd.path); in filename_create()
3670 struct nameidata nd; in do_rmdir() local
3673 name = user_path_parent(dfd, pathname, &nd, lookup_flags); in do_rmdir()
3677 switch(nd.last_type) { in do_rmdir()
3689 nd.flags &= ~LOOKUP_PARENT; in do_rmdir()
3690 error = mnt_want_write(nd.path.mnt); in do_rmdir()
3694 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); in do_rmdir()
3695 dentry = lookup_hash(&nd); in do_rmdir()
3703 error = security_path_rmdir(&nd.path, dentry); in do_rmdir()
3706 error = vfs_rmdir(nd.path.dentry->d_inode, dentry); in do_rmdir()
3710 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); in do_rmdir()
3711 mnt_drop_write(nd.path.mnt); in do_rmdir()
3713 path_put(&nd.path); in do_rmdir()
3796 struct nameidata nd; in do_unlinkat() local
3801 name = user_path_parent(dfd, pathname, &nd, lookup_flags); in do_unlinkat()
3806 if (nd.last_type != LAST_NORM) in do_unlinkat()
3809 nd.flags &= ~LOOKUP_PARENT; in do_unlinkat()
3810 error = mnt_want_write(nd.path.mnt); in do_unlinkat()
3814 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); in do_unlinkat()
3815 dentry = lookup_hash(&nd); in do_unlinkat()
3819 if (nd.last.name[nd.last.len]) in do_unlinkat()
3825 error = security_path_unlink(&nd.path, dentry); in do_unlinkat()
3828 error = vfs_unlink(nd.path.dentry->d_inode, dentry, &delegated_inode); in do_unlinkat()
3832 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); in do_unlinkat()
3841 mnt_drop_write(nd.path.mnt); in do_unlinkat()
3843 path_put(&nd.path); in do_unlinkat()
4462 struct nameidata nd; in generic_readlink() local
4466 nd.depth = 0; in generic_readlink()
4467 cookie = dentry->d_inode->i_op->follow_link(dentry, &nd); in generic_readlink()
4471 res = readlink_copy(buffer, buflen, nd_get_link(&nd)); in generic_readlink()
4473 dentry->d_inode->i_op->put_link(dentry, &nd, cookie); in generic_readlink()
4505 void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd) in page_follow_link_light() argument
4508 nd_set_link(nd, page_getlink(dentry, &page)); in page_follow_link_light()
4513 void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) in page_put_link() argument