diff options
Diffstat (limited to 'fs/overlayfs/dir.c')
-rw-r--r-- | fs/overlayfs/dir.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 8ffc4b980f1b..d139405d2bfa 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c | |||
@@ -19,7 +19,7 @@ void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) | |||
19 | int err; | 19 | int err; |
20 | 20 | ||
21 | dget(wdentry); | 21 | dget(wdentry); |
22 | if (S_ISDIR(wdentry->d_inode->i_mode)) | 22 | if (d_is_dir(wdentry)) |
23 | err = ovl_do_rmdir(wdir, wdentry); | 23 | err = ovl_do_rmdir(wdir, wdentry); |
24 | else | 24 | else |
25 | err = ovl_do_unlink(wdir, wdentry); | 25 | err = ovl_do_unlink(wdir, wdentry); |
@@ -118,14 +118,14 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry, | |||
118 | 118 | ||
119 | static int ovl_set_opaque(struct dentry *upperdentry) | 119 | static int ovl_set_opaque(struct dentry *upperdentry) |
120 | { | 120 | { |
121 | return ovl_do_setxattr(upperdentry, ovl_opaque_xattr, "y", 1, 0); | 121 | return ovl_do_setxattr(upperdentry, OVL_XATTR_OPAQUE, "y", 1, 0); |
122 | } | 122 | } |
123 | 123 | ||
124 | static void ovl_remove_opaque(struct dentry *upperdentry) | 124 | static void ovl_remove_opaque(struct dentry *upperdentry) |
125 | { | 125 | { |
126 | int err; | 126 | int err; |
127 | 127 | ||
128 | err = ovl_do_removexattr(upperdentry, ovl_opaque_xattr); | 128 | err = ovl_do_removexattr(upperdentry, OVL_XATTR_OPAQUE); |
129 | if (err) { | 129 | if (err) { |
130 | pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n", | 130 | pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n", |
131 | upperdentry->d_name.name, err); | 131 | upperdentry->d_name.name, err); |
@@ -152,7 +152,7 @@ static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
152 | * correct link count. nlink=1 seems to pacify 'find' and | 152 | * correct link count. nlink=1 seems to pacify 'find' and |
153 | * other utilities. | 153 | * other utilities. |
154 | */ | 154 | */ |
155 | if (type == OVL_PATH_MERGE) | 155 | if (OVL_TYPE_MERGE(type)) |
156 | stat->nlink = 1; | 156 | stat->nlink = 1; |
157 | 157 | ||
158 | return 0; | 158 | return 0; |
@@ -506,7 +506,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) | |||
506 | struct dentry *opaquedir = NULL; | 506 | struct dentry *opaquedir = NULL; |
507 | int err; | 507 | int err; |
508 | 508 | ||
509 | if (is_dir) { | 509 | if (is_dir && OVL_TYPE_MERGE_OR_LOWER(ovl_path_type(dentry))) { |
510 | opaquedir = ovl_check_empty_and_clear(dentry); | 510 | opaquedir = ovl_check_empty_and_clear(dentry); |
511 | err = PTR_ERR(opaquedir); | 511 | err = PTR_ERR(opaquedir); |
512 | if (IS_ERR(opaquedir)) | 512 | if (IS_ERR(opaquedir)) |
@@ -630,7 +630,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir) | |||
630 | goto out_drop_write; | 630 | goto out_drop_write; |
631 | 631 | ||
632 | type = ovl_path_type(dentry); | 632 | type = ovl_path_type(dentry); |
633 | if (type == OVL_PATH_PURE_UPPER) { | 633 | if (OVL_TYPE_PURE_UPPER(type)) { |
634 | err = ovl_remove_upper(dentry, is_dir); | 634 | err = ovl_remove_upper(dentry, is_dir); |
635 | } else { | 635 | } else { |
636 | const struct cred *old_cred; | 636 | const struct cred *old_cred; |
@@ -693,7 +693,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, | |||
693 | bool new_create = false; | 693 | bool new_create = false; |
694 | bool cleanup_whiteout = false; | 694 | bool cleanup_whiteout = false; |
695 | bool overwrite = !(flags & RENAME_EXCHANGE); | 695 | bool overwrite = !(flags & RENAME_EXCHANGE); |
696 | bool is_dir = S_ISDIR(old->d_inode->i_mode); | 696 | bool is_dir = d_is_dir(old); |
697 | bool new_is_dir = false; | 697 | bool new_is_dir = false; |
698 | struct dentry *opaquedir = NULL; | 698 | struct dentry *opaquedir = NULL; |
699 | const struct cred *old_cred = NULL; | 699 | const struct cred *old_cred = NULL; |
@@ -712,7 +712,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, | |||
712 | /* Don't copy up directory trees */ | 712 | /* Don't copy up directory trees */ |
713 | old_type = ovl_path_type(old); | 713 | old_type = ovl_path_type(old); |
714 | err = -EXDEV; | 714 | err = -EXDEV; |
715 | if ((old_type == OVL_PATH_LOWER || old_type == OVL_PATH_MERGE) && is_dir) | 715 | if (OVL_TYPE_MERGE_OR_LOWER(old_type) && is_dir) |
716 | goto out; | 716 | goto out; |
717 | 717 | ||
718 | if (new->d_inode) { | 718 | if (new->d_inode) { |
@@ -720,30 +720,30 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, | |||
720 | if (err) | 720 | if (err) |
721 | goto out; | 721 | goto out; |
722 | 722 | ||
723 | if (S_ISDIR(new->d_inode->i_mode)) | 723 | if (d_is_dir(new)) |
724 | new_is_dir = true; | 724 | new_is_dir = true; |
725 | 725 | ||
726 | new_type = ovl_path_type(new); | 726 | new_type = ovl_path_type(new); |
727 | err = -EXDEV; | 727 | err = -EXDEV; |
728 | if (!overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) | 728 | if (!overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir) |
729 | goto out; | 729 | goto out; |
730 | 730 | ||
731 | err = 0; | 731 | err = 0; |
732 | if (new_type == OVL_PATH_LOWER && old_type == OVL_PATH_LOWER) { | 732 | if (!OVL_TYPE_UPPER(new_type) && !OVL_TYPE_UPPER(old_type)) { |
733 | if (ovl_dentry_lower(old)->d_inode == | 733 | if (ovl_dentry_lower(old)->d_inode == |
734 | ovl_dentry_lower(new)->d_inode) | 734 | ovl_dentry_lower(new)->d_inode) |
735 | goto out; | 735 | goto out; |
736 | } | 736 | } |
737 | if (new_type != OVL_PATH_LOWER && old_type != OVL_PATH_LOWER) { | 737 | if (OVL_TYPE_UPPER(new_type) && OVL_TYPE_UPPER(old_type)) { |
738 | if (ovl_dentry_upper(old)->d_inode == | 738 | if (ovl_dentry_upper(old)->d_inode == |
739 | ovl_dentry_upper(new)->d_inode) | 739 | ovl_dentry_upper(new)->d_inode) |
740 | goto out; | 740 | goto out; |
741 | } | 741 | } |
742 | } else { | 742 | } else { |
743 | if (ovl_dentry_is_opaque(new)) | 743 | if (ovl_dentry_is_opaque(new)) |
744 | new_type = OVL_PATH_UPPER; | 744 | new_type = __OVL_PATH_UPPER; |
745 | else | 745 | else |
746 | new_type = OVL_PATH_PURE_UPPER; | 746 | new_type = __OVL_PATH_UPPER | __OVL_PATH_PURE; |
747 | } | 747 | } |
748 | 748 | ||
749 | err = ovl_want_write(old); | 749 | err = ovl_want_write(old); |
@@ -763,8 +763,8 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, | |||
763 | goto out_drop_write; | 763 | goto out_drop_write; |
764 | } | 764 | } |
765 | 765 | ||
766 | old_opaque = old_type != OVL_PATH_PURE_UPPER; | 766 | old_opaque = !OVL_TYPE_PURE_UPPER(old_type); |
767 | new_opaque = new_type != OVL_PATH_PURE_UPPER; | 767 | new_opaque = !OVL_TYPE_PURE_UPPER(new_type); |
768 | 768 | ||
769 | if (old_opaque || new_opaque) { | 769 | if (old_opaque || new_opaque) { |
770 | err = -ENOMEM; | 770 | err = -ENOMEM; |
@@ -787,7 +787,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, | |||
787 | old_cred = override_creds(override_cred); | 787 | old_cred = override_creds(override_cred); |
788 | } | 788 | } |
789 | 789 | ||
790 | if (overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) { | 790 | if (overwrite && OVL_TYPE_MERGE_OR_LOWER(new_type) && new_is_dir) { |
791 | opaquedir = ovl_check_empty_and_clear(new); | 791 | opaquedir = ovl_check_empty_and_clear(new); |
792 | err = PTR_ERR(opaquedir); | 792 | err = PTR_ERR(opaquedir); |
793 | if (IS_ERR(opaquedir)) { | 793 | if (IS_ERR(opaquedir)) { |