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_init_reval(dentry, newdentry); in ovl_instantiate()
285 inode = ovl_get_inode(dentry->d_sb, &oip); in ovl_instantiate()
296 d_instantiate(dentry, inode); in ovl_instantiate()
299 dentry); in ovl_instantiate()
304 d_drop(dentry); in ovl_instantiate()
309 static bool ovl_type_merge(struct dentry *dentry) in ovl_type_merge() argument
311 return OVL_TYPE_MERGE(ovl_path_type(dentry)); in ovl_type_merge()
314 static bool ovl_type_origin(struct dentry *dentry) in ovl_type_origin() argument
316 return OVL_TYPE_ORIGIN(ovl_path_type(dentry)); in ovl_type_origin()
319 static int ovl_create_upper(struct dentry *dentry, struct inode *inode, in ovl_create_upper() argument
322 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_create_upper()
323 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_create_upper()
325 struct dentry *newdentry; in ovl_create_upper()
333 lookup_one_len(dentry->d_name.name, in ovl_create_upper()
335 dentry->d_name.len), in ovl_create_upper()
341 if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry) && in ovl_create_upper()
344 ovl_set_opaque(dentry, newdentry); in ovl_create_upper()
347 err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink); in ovl_create_upper()
360 static struct dentry *ovl_clear_empty(struct dentry *dentry, in ovl_clear_empty() argument
363 struct dentry *workdir = ovl_workdir(dentry); in ovl_clear_empty()
365 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_clear_empty()
368 struct dentry *upper; in ovl_clear_empty()
369 struct dentry *opaquedir; in ovl_clear_empty()
380 ovl_path_upper(dentry, &upperpath); in ovl_clear_empty()
389 upper = upperpath.dentry; in ovl_clear_empty()
398 err = ovl_copy_xattr(dentry->d_sb, upper, opaquedir); in ovl_clear_empty()
402 err = ovl_set_opaque(dentry, opaquedir); in ovl_clear_empty()
421 d_drop(dentry); in ovl_clear_empty()
434 static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name, in ovl_set_upper_acl()
459 static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, in ovl_create_over_whiteout() argument
462 struct dentry *workdir = ovl_workdir(dentry); in ovl_create_over_whiteout()
464 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_create_over_whiteout()
466 struct dentry *upper; in ovl_create_over_whiteout()
467 struct dentry *newdentry; in ovl_create_over_whiteout()
476 err = posix_acl_create(dentry->d_parent->d_inode, in ovl_create_over_whiteout()
486 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_create_over_whiteout()
487 dentry->d_name.len); in ovl_create_over_whiteout()
530 err = ovl_set_opaque(dentry, newdentry); in ovl_create_over_whiteout()
545 err = ovl_instantiate(dentry, inode, newdentry, hardlink); in ovl_create_over_whiteout()
567 static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, in ovl_create_or_link() argument
573 struct dentry *parent = dentry->d_parent; in ovl_create_or_link()
579 old_cred = ovl_override_creds(dentry->d_sb); in ovl_create_or_link()
611 err = security_dentry_create_files_as(dentry, in ovl_create_or_link()
612 attr->mode, &dentry->d_name, in ovl_create_or_link()
623 if (!ovl_dentry_is_whiteout(dentry)) in ovl_create_or_link()
624 err = ovl_create_upper(dentry, inode, attr); in ovl_create_or_link()
626 err = ovl_create_over_whiteout(dentry, inode, attr); in ovl_create_or_link()
629 ovl_revert_creds(dentry->d_sb, old_cred ?: hold_cred); in ovl_create_or_link()
635 static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, in ovl_create_object() argument
645 err = ovl_want_write(dentry); in ovl_create_object()
651 inode = ovl_new_inode(dentry->d_sb, mode, rdev); in ovl_create_object()
659 inode_init_owner(&init_user_ns, inode, dentry->d_parent->d_inode, mode); in ovl_create_object()
662 err = ovl_create_or_link(dentry, inode, &attr, false); in ovl_create_object()
664 if (inode != d_inode(dentry)) in ovl_create_object()
668 ovl_drop_write(dentry); in ovl_create_object()
674 struct dentry *dentry, umode_t mode, bool excl) in ovl_create() argument
676 return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); in ovl_create()
680 struct dentry *dentry, umode_t mode) in ovl_mkdir() argument
682 return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL); in ovl_mkdir()
686 struct dentry *dentry, umode_t mode, dev_t rdev) in ovl_mknod() argument
692 return ovl_create_object(dentry, mode, rdev, NULL); in ovl_mknod()
696 struct dentry *dentry, const char *link) in ovl_symlink() argument
698 return ovl_create_object(dentry, S_IFLNK, 0, link); in ovl_symlink()
701 static int ovl_set_link_redirect(struct dentry *dentry) in ovl_set_link_redirect() argument
706 old_cred = ovl_override_creds(dentry->d_sb); in ovl_set_link_redirect()
707 err = ovl_set_redirect(dentry, false); in ovl_set_link_redirect()
708 ovl_revert_creds(dentry->d_sb, old_cred); in ovl_set_link_redirect()
713 static int ovl_link(struct dentry *old, struct inode *newdir, in ovl_link()
714 struct dentry *new) in ovl_link()
757 static bool ovl_matches_upper(struct dentry *dentry, struct dentry *upper) in ovl_matches_upper() argument
759 return d_inode(ovl_dentry_upper(dentry)) == d_inode(upper); in ovl_matches_upper()
762 static int ovl_remove_and_whiteout(struct dentry *dentry, in ovl_remove_and_whiteout() argument
765 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_remove_and_whiteout()
766 struct dentry *workdir = ovl_workdir(dentry); in ovl_remove_and_whiteout()
767 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_remove_and_whiteout()
768 struct dentry *upper; in ovl_remove_and_whiteout()
769 struct dentry *opaquedir = NULL; in ovl_remove_and_whiteout()
776 opaquedir = ovl_clear_empty(dentry, list); in ovl_remove_and_whiteout()
786 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_remove_and_whiteout()
787 dentry->d_name.len); in ovl_remove_and_whiteout()
794 (!opaquedir && ovl_dentry_upper(dentry) && in ovl_remove_and_whiteout()
795 !ovl_matches_upper(dentry, upper))) { in ovl_remove_and_whiteout()
803 ovl_dir_modified(dentry->d_parent, true); in ovl_remove_and_whiteout()
805 d_drop(dentry); in ovl_remove_and_whiteout()
816 static int ovl_remove_upper(struct dentry *dentry, bool is_dir, in ovl_remove_upper() argument
819 struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent); in ovl_remove_upper()
821 struct dentry *upper; in ovl_remove_upper()
822 struct dentry *opaquedir = NULL; in ovl_remove_upper()
826 opaquedir = ovl_clear_empty(dentry, list); in ovl_remove_upper()
833 upper = lookup_one_len(dentry->d_name.name, upperdir, in ovl_remove_upper()
834 dentry->d_name.len); in ovl_remove_upper()
841 (!opaquedir && !ovl_matches_upper(dentry, upper))) in ovl_remove_upper()
848 ovl_dir_modified(dentry->d_parent, ovl_type_origin(dentry)); in ovl_remove_upper()
857 d_drop(dentry); in ovl_remove_upper()
867 static bool ovl_pure_upper(struct dentry *dentry) in ovl_pure_upper() argument
869 return !ovl_dentry_lower(dentry) && in ovl_pure_upper()
870 !ovl_test_flag(OVL_WHITEOUTS, d_inode(dentry)); in ovl_pure_upper()
873 static void ovl_drop_nlink(struct dentry *dentry) in ovl_drop_nlink() argument
875 struct inode *inode = d_inode(dentry); in ovl_drop_nlink()
876 struct dentry *alias; in ovl_drop_nlink()
881 if (alias != dentry && !d_unhashed(alias)) in ovl_drop_nlink()
895 static int ovl_do_remove(struct dentry *dentry, bool is_dir) in ovl_do_remove() argument
899 bool lower_positive = ovl_lower_positive(dentry); in ovl_do_remove()
903 if (is_dir && (lower_positive || !ovl_pure_upper(dentry))) { in ovl_do_remove()
904 err = ovl_check_empty_dir(dentry, &list); in ovl_do_remove()
909 err = ovl_want_write(dentry); in ovl_do_remove()
913 err = ovl_copy_up(dentry->d_parent); in ovl_do_remove()
917 err = ovl_nlink_start(dentry); in ovl_do_remove()
921 old_cred = ovl_override_creds(dentry->d_sb); in ovl_do_remove()
923 err = ovl_remove_upper(dentry, is_dir, &list); in ovl_do_remove()
925 err = ovl_remove_and_whiteout(dentry, &list); in ovl_do_remove()
926 ovl_revert_creds(dentry->d_sb, old_cred); in ovl_do_remove()
929 clear_nlink(dentry->d_inode); in ovl_do_remove()
931 ovl_drop_nlink(dentry); in ovl_do_remove()
933 ovl_nlink_end(dentry); in ovl_do_remove()
941 if (ovl_dentry_upper(dentry)) in ovl_do_remove()
942 ovl_copyattr(d_inode(dentry)); in ovl_do_remove()
945 ovl_drop_write(dentry); in ovl_do_remove()
951 static int ovl_unlink(struct inode *dir, struct dentry *dentry) in ovl_unlink() argument
953 return ovl_do_remove(dentry, false); in ovl_unlink()
956 static int ovl_rmdir(struct inode *dir, struct dentry *dentry) in ovl_rmdir() argument
958 return ovl_do_remove(dentry, true); in ovl_rmdir()
961 static bool ovl_type_merge_or_lower(struct dentry *dentry) in ovl_type_merge_or_lower() argument
963 enum ovl_path_type type = ovl_path_type(dentry); in ovl_type_merge_or_lower()
968 static bool ovl_can_move(struct dentry *dentry) in ovl_can_move() argument
970 return ovl_redirect_dir(dentry->d_sb) || in ovl_can_move()
971 !d_is_dir(dentry) || !ovl_type_merge_or_lower(dentry); in ovl_can_move()
974 static char *ovl_get_redirect(struct dentry *dentry, bool abs_redirect) in ovl_get_redirect() argument
977 struct dentry *d, *tmp; in ovl_get_redirect()
981 ret = kstrndup(dentry->d_name.name, dentry->d_name.len, in ovl_get_redirect()
992 for (d = dget(dentry); !IS_ROOT(d);) { in ovl_get_redirect()
1034 static bool ovl_need_absolute_redirect(struct dentry *dentry, bool samedir) in ovl_need_absolute_redirect() argument
1036 struct dentry *lowerdentry; in ovl_need_absolute_redirect()
1041 if (d_is_dir(dentry)) in ovl_need_absolute_redirect()
1057 lowerdentry = ovl_dentry_lower(dentry); in ovl_need_absolute_redirect()
1061 static int ovl_set_redirect(struct dentry *dentry, bool samedir) in ovl_set_redirect() argument
1064 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_set_redirect()
1065 const char *redirect = ovl_dentry_get_redirect(dentry); in ovl_set_redirect()
1066 bool absolute_redirect = ovl_need_absolute_redirect(dentry, samedir); in ovl_set_redirect()
1071 redirect = ovl_get_redirect(dentry, absolute_redirect); in ovl_set_redirect()
1075 err = ovl_check_setxattr(ofs, ovl_dentry_upper(dentry), in ovl_set_redirect()
1079 spin_lock(&dentry->d_lock); in ovl_set_redirect()
1080 ovl_dentry_set_redirect(dentry, redirect); in ovl_set_redirect()
1081 spin_unlock(&dentry->d_lock); in ovl_set_redirect()
1093 struct dentry *old, struct inode *newdir, in ovl_rename()
1094 struct dentry *new, unsigned int flags) in ovl_rename()
1097 struct dentry *old_upperdir; in ovl_rename()
1098 struct dentry *new_upperdir; in ovl_rename()
1099 struct dentry *olddentry; in ovl_rename()
1100 struct dentry *newdentry; in ovl_rename()
1101 struct dentry *trap; in ovl_rename()
1110 struct dentry *opaquedir = NULL; in ovl_rename()