]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/overlayfs/inode.c
Merge branch 'd_real' into overlayfs-next
[mirror_ubuntu-bionic-kernel.git] / fs / overlayfs / inode.c
index c831c2e5f803f26d553264b3a2fc2abbe38803e9..d554e86abbe365c82ca3413e3295715295fe7ad5 100644 (file)
@@ -80,6 +80,9 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
                                goto out_drop_write;
                }
 
+               if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
+                       attr->ia_valid &= ~ATTR_MODE;
+
                inode_lock(upperdentry->d_inode);
                err = notify_change(upperdentry, attr, NULL);
                if (!err)
@@ -348,36 +351,25 @@ static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
        return true;
 }
 
-struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
+int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags)
 {
-       int err;
+       int err = 0;
        struct path realpath;
        enum ovl_path_type type;
 
-       if (d_is_dir(dentry))
-               return d_backing_inode(dentry);
-
        type = ovl_path_real(dentry, &realpath);
        if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
                err = ovl_want_write(dentry);
-               if (err)
-                       return ERR_PTR(err);
-
-               if (file_flags & O_TRUNC)
-                       err = ovl_copy_up_truncate(dentry);
-               else
-                       err = ovl_copy_up(dentry);
-               ovl_drop_write(dentry);
-               if (err)
-                       return ERR_PTR(err);
-
-               ovl_path_upper(dentry, &realpath);
+               if (!err) {
+                       if (file_flags & O_TRUNC)
+                               err = ovl_copy_up_truncate(dentry);
+                       else
+                               err = ovl_copy_up(dentry);
+                       ovl_drop_write(dentry);
+               }
        }
 
-       if (realpath.dentry->d_flags & DCACHE_OP_SELECT_INODE)
-               return realpath.dentry->d_op->d_select_inode(realpath.dentry, file_flags);
-
-       return d_backing_inode(realpath.dentry);
+       return err;
 }
 
 static const struct inode_operations ovl_file_inode_operations = {
@@ -410,12 +402,11 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
        if (!inode)
                return NULL;
 
-       mode &= S_IFMT;
-
        inode->i_ino = get_next_ino();
        inode->i_mode = mode;
        inode->i_flags |= S_NOATIME | S_NOCMTIME;
 
+       mode &= S_IFMT;
        switch (mode) {
        case S_IFDIR:
                inode->i_private = oe;