Lines Matching refs:dentry

614 	dget(path->dentry);  in path_get()
626 dput(path->dentry); in path_put()
670 p->path.dentry = NULL; in __set_nameidata()
719 static bool path_connected(struct vfsmount *mnt, struct dentry *dentry) in path_connected() argument
727 return is_subdir(dentry, mnt->mnt_root); in path_connected()
764 nd->path.dentry = NULL; in terminate_walk()
774 path->dentry = NULL; in __legitimize_path()
777 if (unlikely(!lockref_get_not_dead(&path->dentry->d_lockref))) { in __legitimize_path()
778 path->dentry = NULL; in __legitimize_path()
781 return !read_seqcount_retry(&path->dentry->d_seq, seq); in __legitimize_path()
842 struct dentry *parent = nd->path.dentry; in try_to_unlazy()
858 nd->path.dentry = NULL; in try_to_unlazy()
876 static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry) in try_to_unlazy_next() argument
889 if (unlikely(!lockref_get_not_dead(&nd->path.dentry->d_lockref))) in try_to_unlazy_next()
899 if (unlikely(!lockref_get_not_dead(&dentry->d_lockref))) in try_to_unlazy_next()
901 if (read_seqcount_retry(&dentry->d_seq, nd->next_seq)) in try_to_unlazy_next()
915 nd->path.dentry = NULL; in try_to_unlazy_next()
921 dput(dentry); in try_to_unlazy_next()
926 struct dentry *dentry, unsigned int flags) in d_revalidate() argument
928 if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) in d_revalidate()
929 return dentry->d_op->d_revalidate(dir, name, dentry, flags); in d_revalidate()
946 struct dentry *dentry = nd->path.dentry; in complete_walk() local
986 if (likely(!(dentry->d_flags & DCACHE_OP_WEAK_REVALIDATE))) in complete_walk()
989 status = dentry->d_op->d_weak_revalidate(dentry, nd->flags); in complete_walk()
1017 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq); in set_root()
1041 struct dentry *d; in nd_jump_root()
1043 d = nd->path.dentry; in nd_jump_root()
1052 nd->inode = nd->path.dentry->d_inode; in nd_jump_root()
1081 nd->inode = nd->path.dentry->d_inode; in nd_jump_link()
1193 audit_inode(nd->name, nd->stack[0].link.dentry, 0); in may_follow_link()
1256 struct inode *inode = link->dentry->d_inode; in may_linkat()
1363 struct dentry *mountpoint; in follow_up()
1374 dput(path->dentry); in follow_up()
1375 path->dentry = mountpoint; in follow_up()
1386 struct dentry *mountpoint = m->mnt_mountpoint; in choose_mountpoint_rcu()
1389 if (unlikely(root->dentry == mountpoint && in choose_mountpoint_rcu()
1394 path->dentry = mountpoint; in choose_mountpoint_rcu()
1434 struct dentry *dentry = path->dentry; in follow_automount() local
1449 dentry->d_inode) in follow_automount()
1455 return finish_automount(dentry->d_op->d_automount(path), path); in follow_automount()
1475 ret = path->dentry->d_op->d_manage(path, false); in __traverse_mounts()
1476 flags = smp_load_acquire(&path->dentry->d_flags); in __traverse_mounts()
1484 dput(path->dentry); in __traverse_mounts()
1488 path->dentry = dget(mounted->mnt_root); in __traverse_mounts()
1490 flags = path->dentry->d_flags; in __traverse_mounts()
1501 flags = smp_load_acquire(&path->dentry->d_flags); in __traverse_mounts()
1520 unsigned flags = smp_load_acquire(&path->dentry->d_flags); in traverse_mounts()
1538 dput(path->dentry); in follow_down_one()
1541 path->dentry = dget(mounted->mnt_root); in follow_down_one()
1571 struct dentry *dentry = path->dentry; in __follow_mount_rcu() local
1572 unsigned int flags = dentry->d_flags; in __follow_mount_rcu()
1586 int res = dentry->d_op->d_manage(path, true); in __follow_mount_rcu()
1589 flags = dentry->d_flags; in __follow_mount_rcu()
1593 struct mount *mounted = __lookup_mnt(path->mnt, dentry); in __follow_mount_rcu()
1596 dentry = path->dentry = mounted->mnt.mnt_root; in __follow_mount_rcu()
1598 nd->next_seq = read_seqcount_begin(&dentry->d_seq); in __follow_mount_rcu()
1599 flags = dentry->d_flags; in __follow_mount_rcu()
1613 static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry, in handle_mounts() argument
1620 path->dentry = dentry; in handle_mounts()
1627 path->dentry = dentry; in handle_mounts()
1629 if (!try_to_unlazy_next(nd, dentry)) in handle_mounts()
1640 dput(path->dentry); in handle_mounts()
1651 static struct dentry *lookup_dcache(const struct qstr *name, in lookup_dcache()
1652 struct dentry *dir, in lookup_dcache()
1655 struct dentry *dentry = d_lookup(dir, name); in lookup_dcache() local
1656 if (dentry) { in lookup_dcache()
1657 int error = d_revalidate(dir->d_inode, name, dentry, flags); in lookup_dcache()
1660 d_invalidate(dentry); in lookup_dcache()
1661 dput(dentry); in lookup_dcache()
1665 return dentry; in lookup_dcache()
1677 struct dentry *lookup_one_qstr_excl(const struct qstr *name, in lookup_one_qstr_excl()
1678 struct dentry *base, unsigned int flags) in lookup_one_qstr_excl()
1680 struct dentry *dentry; in lookup_one_qstr_excl() local
1681 struct dentry *old; in lookup_one_qstr_excl()
1684 dentry = lookup_dcache(name, base, flags); in lookup_one_qstr_excl()
1685 if (dentry) in lookup_one_qstr_excl()
1693 dentry = d_alloc(base, name); in lookup_one_qstr_excl()
1694 if (unlikely(!dentry)) in lookup_one_qstr_excl()
1697 old = dir->i_op->lookup(dir, dentry, flags); in lookup_one_qstr_excl()
1699 dput(dentry); in lookup_one_qstr_excl()
1700 dentry = old; in lookup_one_qstr_excl()
1703 if (IS_ERR(dentry)) in lookup_one_qstr_excl()
1704 return dentry; in lookup_one_qstr_excl()
1705 if (d_is_negative(dentry) && !(flags & LOOKUP_CREATE)) { in lookup_one_qstr_excl()
1706 dput(dentry); in lookup_one_qstr_excl()
1709 if (d_is_positive(dentry) && (flags & LOOKUP_EXCL)) { in lookup_one_qstr_excl()
1710 dput(dentry); in lookup_one_qstr_excl()
1713 return dentry; in lookup_one_qstr_excl()
1731 static struct dentry *lookup_fast(struct nameidata *nd) in lookup_fast()
1733 struct dentry *dentry, *parent = nd->path.dentry; in lookup_fast() local
1742 dentry = __d_lookup_rcu(parent, &nd->last, &nd->next_seq); in lookup_fast()
1743 if (unlikely(!dentry)) { in lookup_fast()
1756 status = d_revalidate(nd->inode, &nd->last, dentry, nd->flags); in lookup_fast()
1758 return dentry; in lookup_fast()
1759 if (!try_to_unlazy_next(nd, dentry)) in lookup_fast()
1764 dentry, nd->flags); in lookup_fast()
1766 dentry = __d_lookup(parent, &nd->last); in lookup_fast()
1767 if (unlikely(!dentry)) in lookup_fast()
1769 status = d_revalidate(nd->inode, &nd->last, dentry, nd->flags); in lookup_fast()
1773 d_invalidate(dentry); in lookup_fast()
1774 dput(dentry); in lookup_fast()
1777 return dentry; in lookup_fast()
1781 static struct dentry *__lookup_slow(const struct qstr *name, in __lookup_slow()
1782 struct dentry *dir, in __lookup_slow()
1785 struct dentry *dentry, *old; in __lookup_slow() local
1793 dentry = d_alloc_parallel(dir, name, &wq); in __lookup_slow()
1794 if (IS_ERR(dentry)) in __lookup_slow()
1795 return dentry; in __lookup_slow()
1796 if (unlikely(!d_in_lookup(dentry))) { in __lookup_slow()
1797 int error = d_revalidate(inode, name, dentry, flags); in __lookup_slow()
1800 d_invalidate(dentry); in __lookup_slow()
1801 dput(dentry); in __lookup_slow()
1804 dput(dentry); in __lookup_slow()
1805 dentry = ERR_PTR(error); in __lookup_slow()
1808 old = inode->i_op->lookup(inode, dentry, flags); in __lookup_slow()
1809 d_lookup_done(dentry); in __lookup_slow()
1811 dput(dentry); in __lookup_slow()
1812 dentry = old; in __lookup_slow()
1815 return dentry; in __lookup_slow()
1818 static struct dentry *lookup_slow(const struct qstr *name, in lookup_slow()
1819 struct dentry *dir, in lookup_slow()
1823 struct dentry *res; in lookup_slow()
1918 error = security_inode_follow_link(link->dentry, inode, in pick_link()
1925 const char * (*get)(struct dentry *, struct inode *, in pick_link()
1931 res = get(link->dentry, inode, &last->done); in pick_link()
1933 res = get(link->dentry, inode, &last->done); in pick_link()
1963 struct dentry *dentry) in step_into() argument
1967 int err = handle_mounts(nd, dentry, &path); in step_into()
1971 inode = path.dentry->d_inode; in step_into()
1972 if (likely(!d_is_symlink(path.dentry)) || in step_into()
1977 if (read_seqcount_retry(&path.dentry->d_seq, nd->next_seq)) in step_into()
1982 dput(nd->path.dentry); in step_into()
1993 if (read_seqcount_retry(&path.dentry->d_seq, nd->next_seq)) in step_into()
2002 static struct dentry *follow_dotdot_rcu(struct nameidata *nd) in follow_dotdot_rcu()
2004 struct dentry *parent, *old; in follow_dotdot_rcu()
2008 if (unlikely(nd->path.dentry == nd->path.mnt->mnt_root)) { in follow_dotdot_rcu()
2017 nd->inode = path.dentry->d_inode; in follow_dotdot_rcu()
2024 old = nd->path.dentry; in follow_dotdot_rcu()
2039 return nd->path.dentry; in follow_dotdot_rcu()
2042 static struct dentry *follow_dotdot(struct nameidata *nd) in follow_dotdot()
2044 struct dentry *parent; in follow_dotdot()
2048 if (unlikely(nd->path.dentry == nd->path.mnt->mnt_root)) { in follow_dotdot()
2056 nd->inode = path.dentry->d_inode; in follow_dotdot()
2061 parent = dget_parent(nd->path.dentry); in follow_dotdot()
2071 return dget(nd->path.dentry); in follow_dotdot()
2078 struct dentry *parent; in handle_dots()
2114 struct dentry *dentry; in walk_component() local
2125 dentry = lookup_fast(nd); in walk_component()
2126 if (IS_ERR(dentry)) in walk_component()
2127 return ERR_CAST(dentry); in walk_component()
2128 if (unlikely(!dentry)) { in walk_component()
2129 dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags); in walk_component()
2130 if (IS_ERR(dentry)) in walk_component()
2131 return ERR_CAST(dentry); in walk_component()
2135 return step_into(nd, flags, dentry); in walk_component()
2297 unsigned long a, b, x, y = (unsigned long)nd->path.dentry; in hash_name()
2384 unsigned long hash = init_name_hash(nd->path.dentry); in hash_name()
2466 struct dentry *parent = nd->path.dentry; in link_path_walk()
2507 if (unlikely(!d_can_lookup(nd->path.dentry))) { in link_path_walk()
2542 struct dentry *root = nd->root.dentry; in path_init()
2549 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2576 nd->inode = nd->path.dentry->d_inode; in path_init()
2577 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2581 nd->inode = nd->path.dentry->d_inode; in path_init()
2586 struct dentry *dentry; in path_init() local
2597 dentry = fd_file(f)->f_path.dentry; in path_init()
2599 if (*s && unlikely(!d_can_lookup(dentry))) in path_init()
2604 nd->inode = nd->path.dentry->d_inode; in path_init()
2605 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); in path_init()
2608 nd->inode = nd->path.dentry->d_inode; in path_init()
2636 dget(nd->path.dentry); in handle_lookup_down()
2638 return PTR_ERR(step_into(nd, WALK_NOFOLLOW, nd->path.dentry)); in handle_lookup_down()
2664 if (!d_can_lookup(nd->path.dentry)) in path_lookupat()
2669 nd->path.dentry = NULL; in path_lookupat()
2690 audit_inode(name, path->dentry, in filename_lookup()
2707 nd->path.dentry = NULL; in path_parentat()
2733 audit_inode(name, parent->dentry, AUDIT_INODE_PARENT); in __filename_parentat()
2747 static struct dentry *__kern_path_locked(int dfd, struct filename *name, struct path *path) in __kern_path_locked()
2750 struct dentry *d; in __kern_path_locked()
2759 inode_lock_nested(parent_path.dentry->d_inode, I_MUTEX_PARENT); in __kern_path_locked()
2760 d = lookup_one_qstr_excl(&last, parent_path.dentry, 0); in __kern_path_locked()
2762 inode_unlock(parent_path.dentry->d_inode); in __kern_path_locked()
2765 path->dentry = no_free_ptr(parent_path.dentry); in __kern_path_locked()
2770 struct dentry *kern_path_locked_negative(const char *name, struct path *path) in kern_path_locked_negative()
2774 struct dentry *d; in kern_path_locked_negative()
2783 inode_lock_nested(parent_path.dentry->d_inode, I_MUTEX_PARENT); in kern_path_locked_negative()
2784 d = lookup_one_qstr_excl(&last, parent_path.dentry, LOOKUP_CREATE); in kern_path_locked_negative()
2786 inode_unlock(parent_path.dentry->d_inode); in kern_path_locked_negative()
2789 path->dentry = no_free_ptr(parent_path.dentry); in kern_path_locked_negative()
2794 struct dentry *kern_path_locked(const char *name, struct path *path) in kern_path_locked()
2797 struct dentry *res = __kern_path_locked(AT_FDCWD, filename, path); in kern_path_locked()
2803 struct dentry *user_path_locked_at(int dfd, const char __user *name, struct path *path) in user_path_locked_at()
2806 struct dentry *res = __kern_path_locked(dfd, filename, path); in user_path_locked_at()
2850 int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, in vfs_path_lookup() argument
2855 struct path root = {.mnt = mnt, .dentry = dentry}; in vfs_path_lookup()
2866 static int lookup_noperm_common(struct qstr *qname, struct dentry *base) in lookup_noperm_common()
2896 struct qstr *qname, struct dentry *base) in lookup_one_common()
2920 struct dentry *try_lookup_noperm(struct qstr *name, struct dentry *base) in try_lookup_noperm()
2942 struct dentry *lookup_noperm(struct qstr *name, struct dentry *base) in lookup_noperm()
2944 struct dentry *dentry; in lookup_noperm() local
2953 dentry = lookup_dcache(name, base, 0); in lookup_noperm()
2954 return dentry ? dentry : __lookup_slow(name, base, 0); in lookup_noperm()
2968 struct dentry *lookup_one(struct mnt_idmap *idmap, struct qstr *name, in lookup_one()
2969 struct dentry *base) in lookup_one()
2971 struct dentry *dentry; in lookup_one() local
2980 dentry = lookup_dcache(name, base, 0); in lookup_one()
2981 return dentry ? dentry : __lookup_slow(name, base, 0); in lookup_one()
2996 struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name, in lookup_one_unlocked()
2997 struct dentry *base) in lookup_one_unlocked()
3000 struct dentry *ret; in lookup_one_unlocked()
3030 struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap, in lookup_one_positive_unlocked()
3032 struct dentry *base) in lookup_one_positive_unlocked()
3034 struct dentry *ret = lookup_one_unlocked(idmap, name, base); in lookup_one_positive_unlocked()
3058 struct dentry *lookup_noperm_unlocked(struct qstr *name, struct dentry *base) in lookup_noperm_unlocked()
3060 struct dentry *ret; in lookup_noperm_unlocked()
3082 struct dentry *lookup_noperm_positive_unlocked(struct qstr *name, in lookup_noperm_positive_unlocked()
3083 struct dentry *base) in lookup_noperm_positive_unlocked()
3085 struct dentry *ret; in lookup_noperm_positive_unlocked()
3102 struct dentry *parent = dget_parent(path->dentry); in path_pts()
3103 struct dentry *child; in path_pts()
3110 dput(path->dentry); in path_pts()
3111 path->dentry = parent; in path_pts()
3116 path->dentry = child; in path_pts()
3168 struct dentry *victim, bool isdir) in may_delete()
3220 struct inode *dir, struct dentry *child) in may_create()
3234 static struct dentry *lock_two_directories(struct dentry *p1, struct dentry *p2) in lock_two_directories()
3236 struct dentry *p = p1, *q = p2, *r; in lock_two_directories()
3269 struct dentry *lock_rename(struct dentry *p1, struct dentry *p2) in lock_rename()
3284 struct dentry *lock_rename_child(struct dentry *c1, struct dentry *p2) in lock_rename_child()
3323 void unlock_rename(struct dentry *p1, struct dentry *p2) in unlock_rename()
3390 struct dentry *dentry, umode_t mode, bool want_excl) in vfs_create() argument
3394 error = may_create(idmap, dir, dentry); in vfs_create()
3402 error = security_inode_create(dir, dentry, mode); in vfs_create()
3405 error = dir->i_op->create(idmap, dir, dentry, mode, want_excl); in vfs_create()
3407 fsnotify_create(dir, dentry); in vfs_create()
3412 int vfs_mkobj(struct dentry *dentry, umode_t mode, in vfs_mkobj() argument
3413 int (*f)(struct dentry *, umode_t, void *), in vfs_mkobj() argument
3416 struct inode *dir = dentry->d_parent->d_inode; in vfs_mkobj()
3417 int error = may_create(&nop_mnt_idmap, dir, dentry); in vfs_mkobj()
3423 error = security_inode_create(dir, dentry, mode); in vfs_mkobj()
3426 error = f(dentry, mode, arg); in vfs_mkobj()
3428 fsnotify_create(dir, dentry); in vfs_mkobj()
3442 struct dentry *dentry = path->dentry; in may_open() local
3443 struct inode *inode = dentry->d_inode; in may_open()
3501 struct inode *inode = path->dentry->d_inode; in handle_truncate()
3508 error = do_truncate(idmap, path->dentry, 0, in handle_truncate()
3524 const struct path *dir, struct dentry *dentry, in may_o_create() argument
3527 int error = security_path_mknod(dir, dentry, mode, 0); in may_o_create()
3531 if (!fsuidgid_has_mapping(dir->dentry->d_sb, idmap)) in may_o_create()
3534 error = inode_permission(idmap, dir->dentry->d_inode, in may_o_create()
3539 return security_inode_create(dir->dentry->d_inode, dentry, mode); in may_o_create()
3555 static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry, in atomic_open() argument
3559 struct dentry *const DENTRY_NOT_SET = (void *) -1UL; in atomic_open()
3560 struct inode *dir = nd->path.dentry->d_inode; in atomic_open()
3566 file->f_path.dentry = DENTRY_NOT_SET; in atomic_open()
3568 error = dir->i_op->atomic_open(dir, dentry, file, in atomic_open()
3570 d_lookup_done(dentry); in atomic_open()
3573 if (unlikely(dentry != file->f_path.dentry)) { in atomic_open()
3574 dput(dentry); in atomic_open()
3575 dentry = dget(file->f_path.dentry); in atomic_open()
3577 } else if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { in atomic_open()
3580 if (file->f_path.dentry) { in atomic_open()
3581 dput(dentry); in atomic_open()
3582 dentry = file->f_path.dentry; in atomic_open()
3584 if (unlikely(d_is_negative(dentry))) in atomic_open()
3589 dput(dentry); in atomic_open()
3590 dentry = ERR_PTR(error); in atomic_open()
3592 return dentry; in atomic_open()
3610 static struct dentry *lookup_open(struct nameidata *nd, struct file *file, in lookup_open()
3615 struct dentry *dir = nd->path.dentry; in lookup_open()
3618 struct dentry *dentry; in lookup_open() local
3627 dentry = d_lookup(dir, &nd->last); in lookup_open()
3629 if (!dentry) { in lookup_open()
3630 dentry = d_alloc_parallel(dir, &nd->last, &wq); in lookup_open()
3631 if (IS_ERR(dentry)) in lookup_open()
3632 return dentry; in lookup_open()
3634 if (d_in_lookup(dentry)) in lookup_open()
3637 error = d_revalidate(dir_inode, &nd->last, dentry, nd->flags); in lookup_open()
3642 d_invalidate(dentry); in lookup_open()
3643 dput(dentry); in lookup_open()
3644 dentry = NULL; in lookup_open()
3646 if (dentry->d_inode) { in lookup_open()
3648 return dentry; in lookup_open()
3672 dentry, mode); in lookup_open()
3679 dentry = atomic_open(nd, dentry, file, open_flag, mode); in lookup_open()
3680 if (unlikely(create_error) && dentry == ERR_PTR(-ENOENT)) in lookup_open()
3681 dentry = ERR_PTR(create_error); in lookup_open()
3682 return dentry; in lookup_open()
3685 if (d_in_lookup(dentry)) { in lookup_open()
3686 struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry, in lookup_open()
3688 d_lookup_done(dentry); in lookup_open()
3694 dput(dentry); in lookup_open()
3695 dentry = res; in lookup_open()
3700 if (!dentry->d_inode && (open_flag & O_CREAT)) { in lookup_open()
3702 audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); in lookup_open()
3708 error = dir_inode->i_op->create(idmap, dir_inode, dentry, in lookup_open()
3713 if (unlikely(create_error) && !dentry->d_inode) { in lookup_open()
3717 return dentry; in lookup_open()
3720 dput(dentry); in lookup_open()
3729 static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag) in lookup_fast_for_open()
3731 struct dentry *dentry; in lookup_fast_for_open() local
3745 dentry = lookup_fast(nd); in lookup_fast_for_open()
3746 if (IS_ERR_OR_NULL(dentry)) in lookup_fast_for_open()
3747 return dentry; in lookup_fast_for_open()
3751 if (!dentry->d_inode) { in lookup_fast_for_open()
3753 dput(dentry); in lookup_fast_for_open()
3754 dentry = NULL; in lookup_fast_for_open()
3757 return dentry; in lookup_fast_for_open()
3763 struct dentry *dir = nd->path.dentry; in open_last_lookups()
3766 struct dentry *dentry; in open_last_lookups() local
3778 dentry = lookup_fast_for_open(nd, open_flag); in open_last_lookups()
3779 if (IS_ERR(dentry)) in open_last_lookups()
3780 return ERR_CAST(dentry); in open_last_lookups()
3782 if (likely(dentry)) in open_last_lookups()
3807 dentry = lookup_open(nd, file, op, got_write); in open_last_lookups()
3808 if (!IS_ERR(dentry)) { in open_last_lookups()
3810 fsnotify_create(dir->d_inode, dentry); in open_last_lookups()
3822 if (IS_ERR(dentry)) in open_last_lookups()
3823 return ERR_CAST(dentry); in open_last_lookups()
3826 dput(nd->path.dentry); in open_last_lookups()
3827 nd->path.dentry = dentry; in open_last_lookups()
3834 res = step_into(nd, WALK_TRAILING, dentry); in open_last_lookups()
3858 audit_inode(nd->name, nd->path.dentry, 0); in do_open()
3863 if (d_is_dir(nd->path.dentry)) in do_open()
3866 d_backing_inode(nd->path.dentry)); in do_open()
3870 if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) in do_open()
3879 } else if (d_is_reg(nd->path.dentry) && open_flag & O_TRUNC) { in do_open()
3920 struct dentry *child; in vfs_tmpfile()
3921 struct inode *dir = d_inode(parentpath->dentry); in vfs_tmpfile()
3932 child = d_alloc(parentpath->dentry, &slash_name); in vfs_tmpfile()
3936 file->f_path.dentry = child; in vfs_tmpfile()
4006 audit_inode(nd->name, file->f_path.dentry, 0); in do_tmpfile()
4019 audit_inode(nd->name, path.dentry, 0); in do_o_path()
4090 if (d_is_symlink(root->dentry) && op->intent & LOOKUP_OPEN) in do_file_open_root()
4108 static struct dentry *filename_create(int dfd, struct filename *name, in filename_create()
4111 struct dentry *dentry = ERR_PTR(-EEXIST); in filename_create() local
4139 inode_lock_nested(path->dentry->d_inode, I_MUTEX_PARENT); in filename_create()
4140 dentry = lookup_one_qstr_excl(&last, path->dentry, in filename_create()
4142 if (IS_ERR(dentry)) in filename_create()
4149 return dentry; in filename_create()
4151 dput(dentry); in filename_create()
4152 dentry = ERR_PTR(error); in filename_create()
4154 inode_unlock(path->dentry->d_inode); in filename_create()
4159 return dentry; in filename_create()
4162 struct dentry *kern_path_create(int dfd, const char *pathname, in kern_path_create()
4166 struct dentry *res = filename_create(dfd, filename, path, lookup_flags); in kern_path_create()
4173 void done_path_create(struct path *path, struct dentry *dentry) in done_path_create() argument
4175 if (!IS_ERR(dentry)) in done_path_create()
4176 dput(dentry); in done_path_create()
4177 inode_unlock(path->dentry->d_inode); in done_path_create()
4183 inline struct dentry *user_path_create(int dfd, const char __user *pathname, in user_path_create()
4187 struct dentry *res = filename_create(dfd, filename, path, lookup_flags); in user_path_create()
4211 struct dentry *dentry, umode_t mode, dev_t dev) in vfs_mknod() argument
4214 int error = may_create(idmap, dir, dentry); in vfs_mknod()
4231 error = security_inode_mknod(dir, dentry, mode, dev); in vfs_mknod()
4235 error = dir->i_op->mknod(idmap, dir, dentry, mode, dev); in vfs_mknod()
4237 fsnotify_create(dir, dentry); in vfs_mknod()
4263 struct dentry *dentry; in do_mknodat() local
4272 dentry = filename_create(dfd, name, &path, lookup_flags); in do_mknodat()
4273 error = PTR_ERR(dentry); in do_mknodat()
4274 if (IS_ERR(dentry)) in do_mknodat()
4277 error = security_path_mknod(&path, dentry, in do_mknodat()
4278 mode_strip_umask(path.dentry->d_inode, mode), dev); in do_mknodat()
4285 error = vfs_create(idmap, path.dentry->d_inode, in do_mknodat()
4286 dentry, mode, true); in do_mknodat()
4288 security_path_post_mknod(idmap, dentry); in do_mknodat()
4291 error = vfs_mknod(idmap, path.dentry->d_inode, in do_mknodat()
4292 dentry, mode, new_decode_dev(dev)); in do_mknodat()
4295 error = vfs_mknod(idmap, path.dentry->d_inode, in do_mknodat()
4296 dentry, mode, 0); in do_mknodat()
4300 done_path_create(&path, dentry); in do_mknodat()
4342 struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, in vfs_mkdir()
4343 struct dentry *dentry, umode_t mode) in vfs_mkdir() argument
4347 struct dentry *de; in vfs_mkdir()
4349 error = may_create(idmap, dir, dentry); in vfs_mkdir()
4358 error = security_inode_mkdir(dir, dentry, mode); in vfs_mkdir()
4366 de = dir->i_op->mkdir(idmap, dir, dentry, mode); in vfs_mkdir()
4371 dput(dentry); in vfs_mkdir()
4372 dentry = de; in vfs_mkdir()
4374 fsnotify_mkdir(dir, dentry); in vfs_mkdir()
4375 return dentry; in vfs_mkdir()
4378 dput(dentry); in vfs_mkdir()
4385 struct dentry *dentry; in do_mkdirat() local
4391 dentry = filename_create(dfd, name, &path, lookup_flags); in do_mkdirat()
4392 error = PTR_ERR(dentry); in do_mkdirat()
4393 if (IS_ERR(dentry)) in do_mkdirat()
4396 error = security_path_mkdir(&path, dentry, in do_mkdirat()
4397 mode_strip_umask(path.dentry->d_inode, mode)); in do_mkdirat()
4399 dentry = vfs_mkdir(mnt_idmap(path.mnt), path.dentry->d_inode, in do_mkdirat()
4400 dentry, mode); in do_mkdirat()
4401 if (IS_ERR(dentry)) in do_mkdirat()
4402 error = PTR_ERR(dentry); in do_mkdirat()
4404 done_path_create(&path, dentry); in do_mkdirat()
4439 struct dentry *dentry) in vfs_rmdir() argument
4441 int error = may_delete(idmap, dir, dentry, 1); in vfs_rmdir()
4449 dget(dentry); in vfs_rmdir()
4450 inode_lock(dentry->d_inode); in vfs_rmdir()
4453 if (is_local_mountpoint(dentry) || in vfs_rmdir()
4454 (dentry->d_inode->i_flags & S_KERNEL_FILE)) in vfs_rmdir()
4457 error = security_inode_rmdir(dir, dentry); in vfs_rmdir()
4461 error = dir->i_op->rmdir(dir, dentry); in vfs_rmdir()
4465 shrink_dcache_parent(dentry); in vfs_rmdir()
4466 dentry->d_inode->i_flags |= S_DEAD; in vfs_rmdir()
4467 dont_mount(dentry); in vfs_rmdir()
4468 detach_mounts(dentry); in vfs_rmdir()
4471 inode_unlock(dentry->d_inode); in vfs_rmdir()
4472 dput(dentry); in vfs_rmdir()
4474 d_delete_notify(dir, dentry); in vfs_rmdir()
4482 struct dentry *dentry; in do_rmdir() local
4508 inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT); in do_rmdir()
4509 dentry = lookup_one_qstr_excl(&last, path.dentry, lookup_flags); in do_rmdir()
4510 error = PTR_ERR(dentry); in do_rmdir()
4511 if (IS_ERR(dentry)) in do_rmdir()
4513 error = security_path_rmdir(&path, dentry); in do_rmdir()
4516 error = vfs_rmdir(mnt_idmap(path.mnt), path.dentry->d_inode, dentry); in do_rmdir()
4518 dput(dentry); in do_rmdir()
4520 inode_unlock(path.dentry->d_inode); in do_rmdir()
4564 struct dentry *dentry, struct inode **delegated_inode) in vfs_unlink() argument
4566 struct inode *target = dentry->d_inode; in vfs_unlink()
4567 int error = may_delete(idmap, dir, dentry, 0); in vfs_unlink()
4578 else if (is_local_mountpoint(dentry)) in vfs_unlink()
4581 error = security_inode_unlink(dir, dentry); in vfs_unlink()
4586 error = dir->i_op->unlink(dir, dentry); in vfs_unlink()
4588 dont_mount(dentry); in vfs_unlink()
4589 detach_mounts(dentry); in vfs_unlink()
4597 if (!error && dentry->d_flags & DCACHE_NFSFS_RENAMED) { in vfs_unlink()
4598 fsnotify_unlink(dir, dentry); in vfs_unlink()
4601 d_delete_notify(dir, dentry); in vfs_unlink()
4617 struct dentry *dentry; in do_unlinkat() local
4637 inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT); in do_unlinkat()
4638 dentry = lookup_one_qstr_excl(&last, path.dentry, lookup_flags); in do_unlinkat()
4639 error = PTR_ERR(dentry); in do_unlinkat()
4640 if (!IS_ERR(dentry)) { in do_unlinkat()
4645 inode = dentry->d_inode; in do_unlinkat()
4647 error = security_path_unlink(&path, dentry); in do_unlinkat()
4650 error = vfs_unlink(mnt_idmap(path.mnt), path.dentry->d_inode, in do_unlinkat()
4651 dentry, &delegated_inode); in do_unlinkat()
4653 dput(dentry); in do_unlinkat()
4655 inode_unlock(path.dentry->d_inode); in do_unlinkat()
4677 if (d_is_dir(dentry)) in do_unlinkat()
4715 struct dentry *dentry, const char *oldname) in vfs_symlink() argument
4719 error = may_create(idmap, dir, dentry); in vfs_symlink()
4726 error = security_inode_symlink(dir, dentry, oldname); in vfs_symlink()
4730 error = dir->i_op->symlink(idmap, dir, dentry, oldname); in vfs_symlink()
4732 fsnotify_create(dir, dentry); in vfs_symlink()
4740 struct dentry *dentry; in do_symlinkat() local
4749 dentry = filename_create(newdfd, to, &path, lookup_flags); in do_symlinkat()
4750 error = PTR_ERR(dentry); in do_symlinkat()
4751 if (IS_ERR(dentry)) in do_symlinkat()
4754 error = security_path_symlink(&path, dentry, from->name); in do_symlinkat()
4756 error = vfs_symlink(mnt_idmap(path.mnt), path.dentry->d_inode, in do_symlinkat()
4757 dentry, from->name); in do_symlinkat()
4758 done_path_create(&path, dentry); in do_symlinkat()
4806 int vfs_link(struct dentry *old_dentry, struct mnt_idmap *idmap, in vfs_link()
4807 struct inode *dir, struct dentry *new_dentry, in vfs_link()
4882 struct dentry *new_dentry; in do_linkat()
4921 error = security_path_link(old_path.dentry, &new_path, new_dentry); in do_linkat()
4924 error = vfs_link(old_path.dentry, idmap, new_path.dentry->d_inode, in do_linkat()
5012 struct dentry *old_dentry = rd->old_dentry; in vfs_rename()
5013 struct dentry *new_dentry = rd->new_dentry; in vfs_rename()
5172 struct dentry *old_dentry, *new_dentry; in do_renameat2()
5173 struct dentry *trap; in do_renameat2()
5224 trap = lock_rename(new_path.dentry, old_path.dentry); in do_renameat2()
5230 old_dentry = lookup_one_qstr_excl(&old_last, old_path.dentry, in do_renameat2()
5235 new_dentry = lookup_one_qstr_excl(&new_last, new_path.dentry, in do_renameat2()
5270 rd.old_parent = old_path.dentry; in do_renameat2()
5273 rd.new_parent = new_path.dentry; in do_renameat2()
5284 unlock_rename(new_path.dentry, old_path.dentry); in do_renameat2()
5351 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen) in vfs_readlink() argument
5353 struct inode *inode = d_inode(dentry); in vfs_readlink()
5363 return inode->i_op->readlink(dentry, buffer, buflen); in vfs_readlink()
5365 if (!d_is_symlink(dentry)) in vfs_readlink()
5375 link = inode->i_op->get_link(dentry, inode, &done); in vfs_readlink()
5396 const char *vfs_get_link(struct dentry *dentry, struct delayed_call *done) in vfs_get_link() argument
5399 struct inode *inode = d_inode(dentry); in vfs_get_link()
5401 if (d_is_symlink(dentry)) { in vfs_get_link()
5402 res = ERR_PTR(security_inode_readlink(dentry)); in vfs_get_link()
5404 res = inode->i_op->get_link(dentry, inode, done); in vfs_get_link()
5411 static char *__page_get_link(struct dentry *dentry, struct inode *inode, in __page_get_link() argument
5417 if (!dentry) { in __page_get_link()
5435 const char *page_get_link_raw(struct dentry *dentry, struct inode *inode, in page_get_link_raw() argument
5438 return __page_get_link(dentry, inode, callback); in page_get_link_raw()
5453 const char *page_get_link(struct dentry *dentry, struct inode *inode, in page_get_link() argument
5456 char *kaddr = __page_get_link(dentry, inode, callback); in page_get_link()
5484 int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) in page_readlink() argument
5490 link = page_get_link(dentry, d_inode(dentry), &done); in page_readlink()