Lines Matching refs:dentry
24 static int ovl_set_redirect(struct dentry *dentry, bool samedir);
26 int ovl_cleanup(struct inode *wdir, struct dentry *wdentry) in ovl_cleanup()
45 struct dentry *ovl_lookup_temp(struct dentry *workdir) in ovl_lookup_temp()
47 struct dentry *temp; in ovl_lookup_temp()
65 static struct dentry *ovl_whiteout(struct ovl_fs *ofs) in ovl_whiteout()
68 struct dentry *whiteout; in ovl_whiteout()
69 struct dentry *workdir = ofs->workdir; in ovl_whiteout()
110 struct dentry *dentry) in ovl_cleanup_and_whiteout() argument
113 struct dentry *whiteout; in ovl_cleanup_and_whiteout()
122 if (d_is_dir(dentry)) in ovl_cleanup_and_whiteout()
125 err = ovl_do_rename(wdir, whiteout, dir, dentry, flags); in ovl_cleanup_and_whiteout()
129 ovl_cleanup(wdir, dentry); in ovl_cleanup_and_whiteout()
140 int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode) in ovl_mkdir_real()
143 struct dentry *d, *dentry = *newdentry; in ovl_mkdir_real() local
145 err = ovl_do_mkdir(dir, dentry, mode); in ovl_mkdir_real()
149 if (likely(!d_unhashed(dentry))) in ovl_mkdir_real()
157 d = lookup_one_len(dentry->d_name.name, dentry->d_parent, in ovl_mkdir_real()
158 dentry->d_name.len); in ovl_mkdir_real()
161 dentry, err); in ovl_mkdir_real()
164 dput(dentry); in ovl_mkdir_real()
170 struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry, in ovl_create_real()
226 struct dentry *ovl_create_temp(struct dentry *workdir, struct ovl_cattr *attr) in ovl_create_temp()
232 static int ovl_set_opaque_xerr(struct dentry *dentry, struct dentry *upper, in ovl_set_opaque_xerr() argument
235 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_set_opaque_xerr()
240 ovl_dentry_set_opaque(dentry); in ovl_set_opaque_xerr()
245 static int ovl_set_opaque(struct dentry *dentry, struct dentry *upperdentry) in ovl_set_opaque() argument
252 return ovl_set_opaque_xerr(dentry, upperdentry, -EIO); in ovl_set_opaque()
260 static int ovl_instantiate(struct dentry *dentry, struct inode *inode, in ovl_instantiate() argument
261 struct dentry *newdentry, bool hardlink) in ovl_instantiate()
268 ovl_dir_modified(dentry->d_parent, false); in ovl_instantiate()
269 ovl_dentry_set_upper_alias(dentry); in ovl_instantiate()
270 ovl_dentry_update_reval(dentry, newdentry, in ovl_instantiate()
286 inode = ovl_get_inode(dentry->d_sb, &oip); in ovl_instantiate()
297 d_instantiate(dentry, inode); in ovl_instantiate()
300 dentry); in ovl_instantiate()
305 d_drop(dentry); in ovl_instantiate()
310 static bool ovl_type_merge(struct dentry *dentry) in ovl_type_merge() argument
312 return OVL_TYPE_MERGE(ovl_path_type(dentry)); in ovl_type_merge()
315 static bool ovl_type_origin(struct dentry *dentry) in ovl_type_origin() argument
317 return OVL_TYPE_ORIGIN(ovl_path_type(dentry)); in ovl_type_origin()
320 static int ovl_create_upper(struct dentry *dentry, struct inode *inode, in ovl_create_upper() argument
323 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_create_upper()
324 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_create_upper()
326 struct dentry *newdentry; in ovl_create_upper()
334 lookup_one_len(dentry->d_name.name, in ovl_create_upper()
336 dentry->d_name.len), in ovl_create_upper()
342 if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry) && in ovl_create_upper()
345 ovl_set_opaque(dentry, newdentry); in ovl_create_upper()
348 err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink); in ovl_create_upper()
361 static struct dentry *ovl_clear_empty(struct dentry *dentry, in ovl_clear_empty() argument
364 struct dentry *workdir = ovl_workdir(dentry); in ovl_clear_empty()
366 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_clear_empty()
369 struct dentry *upper; in ovl_clear_empty()
370 struct dentry *opaquedir; in ovl_clear_empty()
381 ovl_path_upper(dentry, &upperpath); in ovl_clear_empty()
390 upper = upperpath.dentry; in ovl_clear_empty()
399 err = ovl_copy_xattr(dentry->d_sb, upper, opaquedir); in ovl_clear_empty()
403 err = ovl_set_opaque(dentry, opaquedir); in ovl_clear_empty()
422 d_drop(dentry); in ovl_clear_empty()
435 static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name, in ovl_set_upper_acl()
460 static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, in ovl_create_over_whiteout() argument
463 struct dentry *workdir = ovl_workdir(dentry); in ovl_create_over_whiteout()
465 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_create_over_whiteout()
467 struct dentry *upper; in ovl_create_over_whiteout()
468 struct dentry *newdentry; in ovl_create_over_whiteout()
477 err = posix_acl_create(dentry->d_parent->d_inode, in ovl_create_over_whiteout()
487 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_create_over_whiteout()
488 dentry->d_name.len); in ovl_create_over_whiteout()
531 err = ovl_set_opaque(dentry, newdentry); in ovl_create_over_whiteout()
546 err = ovl_instantiate(dentry, inode, newdentry, hardlink); in ovl_create_over_whiteout()
568 static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, in ovl_create_or_link() argument
574 struct dentry *parent = dentry->d_parent; in ovl_create_or_link()
580 old_cred = ovl_override_creds(dentry->d_sb); in ovl_create_or_link()
598 err = security_dentry_create_files_as(dentry, in ovl_create_or_link()
599 attr->mode, &dentry->d_name, old_cred, in ovl_create_or_link()
609 if (!ovl_dentry_is_whiteout(dentry)) in ovl_create_or_link()
610 err = ovl_create_upper(dentry, inode, attr); in ovl_create_or_link()
612 err = ovl_create_over_whiteout(dentry, inode, attr); in ovl_create_or_link()
619 static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, in ovl_create_object() argument
629 err = ovl_want_write(dentry); in ovl_create_object()
635 inode = ovl_new_inode(dentry->d_sb, mode, rdev); in ovl_create_object()
643 inode_init_owner(&init_user_ns, inode, dentry->d_parent->d_inode, mode); in ovl_create_object()
646 err = ovl_create_or_link(dentry, inode, &attr, false); in ovl_create_object()
648 if (inode != d_inode(dentry)) in ovl_create_object()
652 ovl_drop_write(dentry); in ovl_create_object()
658 struct dentry *dentry, umode_t mode, bool excl) in ovl_create() argument
660 return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); in ovl_create()
664 struct dentry *dentry, umode_t mode) in ovl_mkdir() argument
666 return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL); in ovl_mkdir()
670 struct dentry *dentry, umode_t mode, dev_t rdev) in ovl_mknod() argument
676 return ovl_create_object(dentry, mode, rdev, NULL); in ovl_mknod()
680 struct dentry *dentry, const char *link) in ovl_symlink() argument
682 return ovl_create_object(dentry, S_IFLNK, 0, link); in ovl_symlink()
685 static int ovl_set_link_redirect(struct dentry *dentry) in ovl_set_link_redirect() argument
690 old_cred = ovl_override_creds(dentry->d_sb); in ovl_set_link_redirect()
691 err = ovl_set_redirect(dentry, false); in ovl_set_link_redirect()
697 static int ovl_link(struct dentry *old, struct inode *newdir, in ovl_link()
698 struct dentry *new) in ovl_link()
741 static bool ovl_matches_upper(struct dentry *dentry, struct dentry *upper) in ovl_matches_upper() argument
743 return d_inode(ovl_dentry_upper(dentry)) == d_inode(upper); in ovl_matches_upper()
746 static int ovl_remove_and_whiteout(struct dentry *dentry, in ovl_remove_and_whiteout() argument
749 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_remove_and_whiteout()
750 struct dentry *workdir = ovl_workdir(dentry); in ovl_remove_and_whiteout()
751 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_remove_and_whiteout()
752 struct dentry *upper; in ovl_remove_and_whiteout()
753 struct dentry *opaquedir = NULL; in ovl_remove_and_whiteout()
760 opaquedir = ovl_clear_empty(dentry, list); in ovl_remove_and_whiteout()
770 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_remove_and_whiteout()
771 dentry->d_name.len); in ovl_remove_and_whiteout()
778 (!opaquedir && ovl_dentry_upper(dentry) && in ovl_remove_and_whiteout()
779 !ovl_matches_upper(dentry, upper))) { in ovl_remove_and_whiteout()
787 ovl_dir_modified(dentry->d_parent, true); in ovl_remove_and_whiteout()
789 d_drop(dentry); in ovl_remove_and_whiteout()
800 static int ovl_remove_upper(struct dentry *dentry, bool is_dir, in ovl_remove_upper() argument
803 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_remove_upper()
805 struct dentry *upper; in ovl_remove_upper()
806 struct dentry *opaquedir = NULL; in ovl_remove_upper()
810 opaquedir = ovl_clear_empty(dentry, list); in ovl_remove_upper()
817 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_remove_upper()
818 dentry->d_name.len); in ovl_remove_upper()
825 (!opaquedir && !ovl_matches_upper(dentry, upper))) in ovl_remove_upper()
832 ovl_dir_modified(dentry->d_parent, ovl_type_origin(dentry)); in ovl_remove_upper()
841 d_drop(dentry); in ovl_remove_upper()
851 static bool ovl_pure_upper(struct dentry *dentry) in ovl_pure_upper() argument
853 return !ovl_dentry_lower(dentry) && in ovl_pure_upper()
854 !ovl_test_flag(OVL_WHITEOUTS, d_inode(dentry)); in ovl_pure_upper()
857 static void ovl_drop_nlink(struct dentry *dentry) in ovl_drop_nlink() argument
859 struct inode *inode = d_inode(dentry); in ovl_drop_nlink()
860 struct dentry *alias; in ovl_drop_nlink()
865 if (alias != dentry && !d_unhashed(alias)) in ovl_drop_nlink()
879 static int ovl_do_remove(struct dentry *dentry, bool is_dir) in ovl_do_remove() argument
883 struct dentry *upperdentry; in ovl_do_remove()
884 bool lower_positive = ovl_lower_positive(dentry); in ovl_do_remove()
888 if (is_dir && (lower_positive || !ovl_pure_upper(dentry))) { in ovl_do_remove()
889 err = ovl_check_empty_dir(dentry, &list); in ovl_do_remove()
894 err = ovl_want_write(dentry); in ovl_do_remove()
898 err = ovl_copy_up(dentry->d_parent); in ovl_do_remove()
902 err = ovl_nlink_start(dentry); in ovl_do_remove()
906 old_cred = ovl_override_creds(dentry->d_sb); in ovl_do_remove()
908 err = ovl_remove_upper(dentry, is_dir, &list); in ovl_do_remove()
910 err = ovl_remove_and_whiteout(dentry, &list); in ovl_do_remove()
914 clear_nlink(dentry->d_inode); in ovl_do_remove()
916 ovl_drop_nlink(dentry); in ovl_do_remove()
918 ovl_nlink_end(dentry); in ovl_do_remove()
926 upperdentry = ovl_dentry_upper(dentry); in ovl_do_remove()
928 ovl_copyattr(d_inode(upperdentry), d_inode(dentry)); in ovl_do_remove()
931 ovl_drop_write(dentry); in ovl_do_remove()
937 static int ovl_unlink(struct inode *dir, struct dentry *dentry) in ovl_unlink() argument
939 return ovl_do_remove(dentry, false); in ovl_unlink()
942 static int ovl_rmdir(struct inode *dir, struct dentry *dentry) in ovl_rmdir() argument
944 return ovl_do_remove(dentry, true); in ovl_rmdir()
947 static bool ovl_type_merge_or_lower(struct dentry *dentry) in ovl_type_merge_or_lower() argument
949 enum ovl_path_type type = ovl_path_type(dentry); in ovl_type_merge_or_lower()
954 static bool ovl_can_move(struct dentry *dentry) in ovl_can_move() argument
956 return ovl_redirect_dir(dentry->d_sb) || in ovl_can_move()
957 !d_is_dir(dentry) || !ovl_type_merge_or_lower(dentry); in ovl_can_move()
960 static char *ovl_get_redirect(struct dentry *dentry, bool abs_redirect) in ovl_get_redirect() argument
963 struct dentry *d, *tmp; in ovl_get_redirect()
967 ret = kstrndup(dentry->d_name.name, dentry->d_name.len, in ovl_get_redirect()
978 for (d = dget(dentry); !IS_ROOT(d);) { in ovl_get_redirect()
1020 static bool ovl_need_absolute_redirect(struct dentry *dentry, bool samedir) in ovl_need_absolute_redirect() argument
1022 struct dentry *lowerdentry; in ovl_need_absolute_redirect()
1027 if (d_is_dir(dentry)) in ovl_need_absolute_redirect()
1043 lowerdentry = ovl_dentry_lower(dentry); in ovl_need_absolute_redirect()
1047 static int ovl_set_redirect(struct dentry *dentry, bool samedir) in ovl_set_redirect() argument
1050 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_set_redirect()
1051 const char *redirect = ovl_dentry_get_redirect(dentry); in ovl_set_redirect()
1052 bool absolute_redirect = ovl_need_absolute_redirect(dentry, samedir); in ovl_set_redirect()
1057 redirect = ovl_get_redirect(dentry, absolute_redirect); in ovl_set_redirect()
1061 err = ovl_check_setxattr(ofs, ovl_dentry_upper(dentry), in ovl_set_redirect()
1065 spin_lock(&dentry->d_lock); in ovl_set_redirect()
1066 ovl_dentry_set_redirect(dentry, redirect); in ovl_set_redirect()
1067 spin_unlock(&dentry->d_lock); in ovl_set_redirect()
1079 struct dentry *old, struct inode *newdir, in ovl_rename()
1080 struct dentry *new, unsigned int flags) in ovl_rename()
1083 struct dentry *old_upperdir; in ovl_rename()
1084 struct dentry *new_upperdir; in ovl_rename()
1085 struct dentry *olddentry; in ovl_rename()
1086 struct dentry *newdentry; in ovl_rename()
1087 struct dentry *trap; in ovl_rename()
1096 struct dentry *opaquedir = NULL; in ovl_rename()