Lines Matching defs:path
98 * inside the path - always follow.
190 /* The empty path is special. */
476 * path_get - get a reference to a path
477 * @path: path to get the reference to
479 * Given a path increment the reference count to the dentry and the vfsmount.
481 void path_get(const struct path *path)
483 mntget(path->mnt);
484 dget(path->dentry);
489 * path_put - put a reference to a path
490 * @path: path to put the reference to
492 * Given a path decrement the reference count to the dentry and the vfsmount.
494 void path_put(const struct path *path)
496 dput(path->dentry);
497 mntput(path->mnt);
503 struct path path;
505 struct path root;
506 struct inode *inode; /* path.dentry.d_inode */
513 struct path link;
536 p->path.mnt = NULL;
537 p->path.dentry = NULL;
600 path_put(&nd->path);
612 nd->path.mnt = NULL;
613 nd->path.dentry = NULL;
617 static bool __legitimize_path(struct path *path, unsigned seq, unsigned mseq)
619 int res = __legitimize_mnt(path->mnt, mseq);
622 path->mnt = NULL;
623 path->dentry = NULL;
626 if (unlikely(!lockref_get_not_dead(&path->dentry->d_lockref))) {
627 path->dentry = NULL;
630 return !read_seqcount_retry(&path->dentry->d_seq, seq);
634 struct path *path, unsigned seq)
636 return __legitimize_path(path, seq, nd->m_seq);
676 * Documentation/filesystems/path-lookup.txt). In situations when we can't
682 * to restart the path walk from the beginning in ref-walk mode.
690 * try_to_unlazy attempts to legitimize the current nd->path and nd->root
698 struct dentry *parent = nd->path.dentry;
705 if (unlikely(!legitimize_path(nd, &nd->path, nd->seq)))
714 nd->path.mnt = NULL;
715 nd->path.dentry = NULL;
730 * nd->path and nd->root for ref-walk mode. Must be called from rcu-walk context.
741 if (unlikely(!legitimize_mnt(nd->path.mnt, nd->m_seq)))
743 if (unlikely(!lockref_get_not_dead(&nd->path.dentry->d_lockref)))
767 nd->path.mnt = NULL;
769 nd->path.dentry = NULL;
788 * complete_walk - successful completion of path walk
791 * If we had been in RCU mode, drop out of it and legitimize nd->path.
793 * the path walk or the filesystem doesn't ask for it. Return 0 on
795 * need to drop nd->path.
799 struct dentry *dentry = nd->path.dentry;
820 * BUG resulting in userspace being given a path that was not
828 * Userspace could move the path outside the root after this
832 if (!path_is_under(&nd->path, &nd->root))
884 /* Absolute path arguments to path_init() are allowed. */
885 if (nd->path.mnt != NULL && nd->path.mnt != nd->root.mnt)
895 nd->path = nd->root;
896 d = nd->path.dentry;
902 path_put(&nd->path);
903 nd->path = nd->root;
904 path_get(&nd->path);
905 nd->inode = nd->path.dentry->d_inode;
912 * Helper to directly jump to a known parsed path from ->get_link,
913 * caller must have taken a reference to path beforehand.
915 int nd_jump_link(struct path *path)
925 if (nd->path.mnt != path->mnt)
932 path_put(&nd->path);
933 nd->path = *path;
934 nd->inode = nd->path.dentry->d_inode;
939 path_put(path);
963 * processes from failing races against path names that may change out
1043 int may_linkat(struct path *link)
1109 * follow_up - Find the mountpoint of path's vfsmount
1111 * Given a path, find the mountpoint of its source file system.
1112 * Replace @path with the path of the mountpoint in the parent mount.
1118 int follow_up(struct path *path)
1120 struct mount *mnt = real_mount(path->mnt);
1133 dput(path->dentry);
1134 path->dentry = mountpoint;
1135 mntput(path->mnt);
1136 path->mnt = &parent->mnt;
1141 static bool choose_mountpoint_rcu(struct mount *m, const struct path *root,
1142 struct path *path, unsigned *seqp)
1152 path->mnt = &m->mnt;
1153 path->dentry = mountpoint;
1161 static bool choose_mountpoint(struct mount *m, const struct path *root,
1162 struct path *path)
1170 found = choose_mountpoint_rcu(m, root, path, &seq);
1175 if (likely(__legitimize_path(path, seq, mseq)))
1178 path_put(path);
1188 * - return -EISDIR to tell follow_managed() to stop and return the path we
1191 static int follow_automount(struct path *path, int *count, unsigned lookup_flags)
1193 struct dentry *dentry = path->dentry;
1214 return finish_automount(dentry->d_op->d_automount(path), path);
1223 static int __traverse_mounts(struct path *path, unsigned flags, bool *jumped,
1226 struct vfsmount *mnt = path->mnt;
1234 ret = path->dentry->d_op->d_manage(path, false);
1235 flags = smp_load_acquire(&path->dentry->d_flags);
1241 struct vfsmount *mounted = lookup_mnt(path);
1243 dput(path->dentry);
1245 mntput(path->mnt);
1246 path->mnt = mounted;
1247 path->dentry = dget(mounted->mnt_root);
1249 flags = path->dentry->d_flags;
1259 ret = follow_automount(path, count, lookup_flags);
1260 flags = smp_load_acquire(&path->dentry->d_flags);
1268 if (need_mntput && path->mnt == mnt)
1269 mntput(path->mnt);
1276 static inline int traverse_mounts(struct path *path, bool *jumped,
1279 unsigned flags = smp_load_acquire(&path->dentry->d_flags);
1288 return __traverse_mounts(path, flags, jumped, count, lookup_flags);
1291 int follow_down_one(struct path *path)
1295 mounted = lookup_mnt(path);
1297 dput(path->dentry);
1298 mntput(path->mnt);
1299 path->mnt = mounted;
1300 path->dentry = dget(mounted->mnt_root);
1312 int follow_down(struct path *path)
1314 struct vfsmount *mnt = path->mnt;
1316 int ret = traverse_mounts(path, &jumped, NULL, 0);
1318 if (path->mnt != mnt)
1328 static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
1331 struct dentry *dentry = path->dentry;
1346 int res = dentry->d_op->d_manage(path, true);
1353 struct mount *mounted = __lookup_mnt(path->mnt, dentry);
1355 path->mnt = &mounted->mnt;
1356 dentry = path->dentry = mounted->mnt.mnt_root;
1379 struct path *path, struct inode **inode,
1385 path->mnt = nd->path.mnt;
1386 path->dentry = dentry;
1391 if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
1395 // *path might've been clobbered by __follow_mount_rcu()
1396 path->mnt = nd->path.mnt;
1397 path->dentry = dentry;
1399 ret = traverse_mounts(path, &jumped, &nd->total_link_count, nd->flags);
1407 dput(path->dentry);
1408 if (path->mnt != nd->path.mnt)
1409 mntput(path->mnt);
1411 *inode = d_backing_inode(path->dentry);
1475 struct dentry *dentry, *parent = nd->path.dentry;
1594 static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq)
1622 static const char *pick_link(struct nameidata *nd, struct path *link,
1703 struct path path;
1704 int err = handle_mounts(nd, dentry, &path, &inode, &seq);
1708 if (likely(!d_is_symlink(path.dentry)) ||
1713 dput(nd->path.dentry);
1714 if (nd->path.mnt != path.mnt)
1715 mntput(nd->path.mnt);
1717 nd->path = path;
1724 if (read_seqcount_retry(&path.dentry->d_seq, seq))
1727 if (path.mnt == nd->path.mnt)
1728 mntget(path.mnt);
1730 return pick_link(nd, &path, inode, seq, flags);
1739 if (path_equal(&nd->path, &nd->root))
1741 if (unlikely(nd->path.dentry == nd->path.mnt->mnt_root)) {
1742 struct path path;
1744 if (!choose_mountpoint_rcu(real_mount(nd->path.mnt),
1745 &nd->root, &path, &seq))
1749 nd->path = path;
1750 nd->inode = path.dentry->d_inode;
1756 old = nd->path.dentry;
1762 if (unlikely(!path_connected(nd->path.mnt, parent)))
1779 if (path_equal(&nd->path, &nd->root))
1781 if (unlikely(nd->path.dentry == nd->path.mnt->mnt_root)) {
1782 struct path path;
1784 if (!choose_mountpoint(real_mount(nd->path.mnt),
1785 &nd->root, &path))
1787 path_put(&nd->path);
1788 nd->path = path;
1789 nd->inode = path.dentry->d_inode;
1794 parent = dget_parent(nd->path.dentry);
1795 if (unlikely(!path_connected(nd->path.mnt, parent))) {
1806 dget(nd->path.dentry);
1831 nd->path.dentry, nd->inode, nd->seq);
1841 * path, then we can't be sure that ".." hasn't jumped
1874 dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags);
2035 * Calculate the length and hash of the path component, and
2092 * We know there's a real path component here of at least
2133 /* At this point we know we have a real path component. */
2143 hash_len = hash_name(nd->path.dentry, name);
2157 struct dentry *parent = nd->path.dentry;
2207 if (unlikely(!d_can_lookup(nd->path.dentry))) {
2245 nd->path = nd->root;
2248 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
2251 path_get(&nd->path);
2274 nd->path = fs->pwd;
2275 nd->inode = nd->path.dentry->d_inode;
2276 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
2279 get_fs_pwd(current->fs, &nd->path);
2280 nd->inode = nd->path.dentry->d_inode;
2283 /* Caller must check execute permissions on the starting path component */
2297 nd->path = f.file->f_path;
2299 nd->inode = nd->path.dentry->d_inode;
2300 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
2302 path_get(&nd->path);
2303 nd->inode = nd->path.dentry->d_inode;
2310 nd->root = nd->path;
2332 dget(nd->path.dentry);
2334 nd->path.dentry, nd->inode, nd->seq));
2338 static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path)
2360 if (!d_can_lookup(nd->path.dentry))
2363 *path = nd->path;
2364 nd->path.mnt = NULL;
2365 nd->path.dentry = NULL;
2372 struct path *path, struct path *root)
2383 retval = path_lookupat(&nd, flags | LOOKUP_RCU, path);
2385 retval = path_lookupat(&nd, flags, path);
2387 retval = path_lookupat(&nd, flags | LOOKUP_REVAL, path);
2390 audit_inode(name, path->dentry,
2399 struct path *parent)
2406 *parent = nd->path;
2407 nd->path.mnt = NULL;
2408 nd->path.dentry = NULL;
2415 unsigned int flags, struct path *parent,
2442 struct dentry *kern_path_locked(const char *name, struct path *path)
2449 filename = filename_parentat(AT_FDCWD, getname_kernel(name), 0, path,
2454 path_put(path);
2458 inode_lock_nested(path->dentry->d_inode, I_MUTEX_PARENT);
2459 d = __lookup_hash(&last, path->dentry, 0);
2461 inode_unlock(path->dentry->d_inode);
2462 path_put(path);
2468 int kern_path(const char *name, unsigned int flags, struct path *path)
2471 flags, path, NULL);
2476 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
2481 * @path: pointer to struct path to fill
2485 struct path *path)
2487 struct path root = {.mnt = mnt, .dentry = dentry};
2490 flags , path, &root);
2634 int path_pts(struct path *path)
2637 * the input path.
2639 struct dentry *parent = dget_parent(path->dentry);
2643 if (unlikely(!path_connected(path->mnt, parent))) {
2647 dput(path->dentry);
2648 path->dentry = parent;
2653 path->dentry = child;
2655 follow_down(path);
2661 struct path *path, int *empty)
2664 flags, path, NULL);
2901 bool may_open_dev(const struct path *path)
2903 return !(path->mnt->mnt_flags & MNT_NODEV) &&
2904 !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV);
2907 static int may_open(const struct path *path, int acc_mode, int flag)
2909 struct dentry *dentry = path->dentry;
2927 if (!may_open_dev(path))
2937 if ((acc_mode & MAY_EXEC) && path_noexec(path))
2965 const struct path *path = &filp->f_path;
2966 struct inode *inode = path->dentry->d_inode;
2975 error = security_path_truncate(path);
2977 error = do_truncate(path->dentry, 0,
2992 static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode)
3019 * be set. The caller will need to perform the open themselves. @path will
3029 struct inode *dir = nd->path.dentry->d_inode;
3036 file->f_path.mnt = nd->path.mnt;
3074 * In the latter case dentry returned in @path might be negative if O_CREAT
3083 struct dentry *dir = nd->path.dentry;
3135 create_error = may_o_create(&nd->path, dentry, mode);
3189 struct dentry *dir = nd->path.dentry;
3229 got_write = !mnt_want_write(nd->path.mnt);
3249 mnt_drop_write(nd->path.mnt);
3255 dput(nd->path.dentry);
3256 nd->path.dentry = dentry;
3286 audit_inode(nd->name, nd->path.dentry, 0);
3290 if (d_is_dir(nd->path.dentry))
3293 d_backing_inode(nd->path.dentry));
3297 if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
3306 } else if (d_is_reg(nd->path.dentry) && open_flag & O_TRUNC) {
3307 error = mnt_want_write(nd->path.mnt);
3312 error = may_open(&nd->path, acc_mode, open_flag);
3314 error = vfs_open(&nd->path, file);
3324 mnt_drop_write(nd->path.mnt);
3373 struct path path;
3374 int error = path_lookupat(nd, flags | LOOKUP_DIRECTORY, &path);
3377 error = mnt_want_write(path.mnt);
3380 child = vfs_tmpfile(path.dentry, op->mode, op->open_flag);
3384 dput(path.dentry);
3385 path.dentry = child;
3388 error = may_open(&path, 0, op->open_flag);
3391 file->f_path.mnt = path.mnt;
3394 mnt_drop_write(path.mnt);
3396 path_put(&path);
3402 struct path path;
3403 int error = path_lookupat(nd, flags, &path);
3405 audit_inode(nd->name, path.dentry, 0);
3406 error = vfs_open(&path, file);
3407 path_put(&path);
3468 struct file *do_file_open_root(const struct path *root,
3497 struct path *path, unsigned int lookup_flags)
3512 name = filename_parentat(dfd, name, lookup_flags, path, &last, &type);
3524 err2 = mnt_want_write(path->mnt);
3529 inode_lock_nested(path->dentry->d_inode, I_MUTEX_PARENT);
3530 dentry = __lookup_hash(&last, path->dentry, lookup_flags);
3558 inode_unlock(path->dentry->d_inode);
3560 mnt_drop_write(path->mnt);
3562 path_put(path);
3568 struct path *path, unsigned int lookup_flags)
3571 path, lookup_flags);
3575 void done_path_create(struct path *path, struct dentry *dentry)
3578 inode_unlock(path->dentry->d_inode);
3579 mnt_drop_write(path->mnt);
3580 path_put(path);
3585 struct path *path, unsigned int lookup_flags)
3587 return filename_create(dfd, getname(pathname), path, lookup_flags);
3643 struct path path;
3651 dentry = user_path_create(dfd, filename, &path, lookup_flags);
3655 error = security_path_mknod(&path, dentry,
3656 mode_strip_umask(path.dentry->d_inode, mode), dev);
3661 error = vfs_create(path.dentry->d_inode,dentry,mode,true);
3666 error = vfs_mknod(path.dentry->d_inode,dentry,mode,
3670 error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
3674 done_path_create(&path, dentry);
3722 struct path path;
3727 dentry = user_path_create(dfd, pathname, &path, lookup_flags);
3731 error = security_path_mkdir(&path, dentry,
3732 mode_strip_umask(path.dentry->d_inode, mode));
3734 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
3735 done_path_create(&path, dentry);
3796 struct path path;
3802 &path, &last, &type);
3818 error = mnt_want_write(path.mnt);
3822 inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT);
3823 dentry = __lookup_hash(&last, path.dentry, lookup_flags);
3831 error = security_path_rmdir(&path, dentry);
3834 error = vfs_rmdir(path.dentry->d_inode, dentry);
3838 inode_unlock(path.dentry->d_inode);
3839 mnt_drop_write(path.mnt);
3841 path_put(&path);
3925 struct path path;
3932 name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
3940 error = mnt_want_write(path.mnt);
3944 inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT);
3945 dentry = __lookup_hash(&last, path.dentry, lookup_flags);
3955 error = security_path_unlink(&path, dentry);
3958 error = vfs_unlink(path.dentry->d_inode, dentry, &delegated_inode);
3962 inode_unlock(path.dentry->d_inode);
3971 mnt_drop_write(path.mnt);
3973 path_put(&path);
4034 struct path path;
4041 dentry = user_path_create(newdfd, newname, &path, lookup_flags);
4046 error = security_path_symlink(&path, dentry, from->name);
4048 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
4049 done_path_create(&path, dentry);
4163 struct path old_path, new_path;
4440 struct path old_path, new_path;