Wrapfs: use vfs xattr helpers
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 4 Nov 2015 05:29:06 +0000 (00:29 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 4 Nov 2015 05:29:06 +0000 (00:29 -0500)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/wrapfs/inode.c
fs/wrapfs/wrapfs.h

index 8f6d0e56b77e7655898437c8e14378ef34889b59..989c68cc74667d9dc6cf2788c9160b9e8fee73b5 100644 (file)
@@ -444,14 +444,15 @@ wrapfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 
        wrapfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
-       if (!lower_dentry->d_inode->i_op ||
-           !lower_dentry->d_inode->i_op->setxattr) {
-               err = -EINVAL;
+       if (!lower_dentry->d_inode->i_op->setxattr) {
+               err = -EOPNOTSUPP;
                goto out;
        }
-
-       err = lower_dentry->d_inode->i_op->setxattr(lower_dentry,
-                                                   name, value, size, flags);
+       err = vfs_setxattr(lower_dentry, name, value, size, flags);
+       if (err)
+               goto out;
+       fsstack_copy_attr_all(dentry->d_inode,
+                             lower_path.dentry->d_inode);
 out:
        wrapfs_put_lower_path(dentry, &lower_path);
        return err;
@@ -467,14 +468,15 @@ wrapfs_getxattr(struct dentry *dentry, const char *name, void *buffer,
 
        wrapfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
-       if (!lower_dentry->d_inode->i_op ||
-           !lower_dentry->d_inode->i_op->getxattr) {
-               err = -EINVAL;
+       if (!lower_dentry->d_inode->i_op->getxattr) {
+               err = -EOPNOTSUPP;
                goto out;
        }
-
-       err = lower_dentry->d_inode->i_op->getxattr(lower_dentry,
-                                                   name, buffer, size);
+       err = vfs_getxattr(lower_dentry, name, buffer, size);
+       if (err)
+               goto out;
+       fsstack_copy_attr_atime(dentry->d_inode,
+                               lower_path.dentry->d_inode);
 out:
        wrapfs_put_lower_path(dentry, &lower_path);
        return err;
@@ -489,14 +491,15 @@ wrapfs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 
        wrapfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
-       if (!lower_dentry->d_inode->i_op ||
-           !lower_dentry->d_inode->i_op->listxattr) {
-               err = -EINVAL;
+       if (!lower_dentry->d_inode->i_op->listxattr) {
+               err = -EOPNOTSUPP;
                goto out;
        }
-
-       err = lower_dentry->d_inode->i_op->listxattr(lower_dentry,
-                                                    buffer, buffer_size);
+       err = vfs_listxattr(lower_dentry, buffer, buffer_size);
+       if (err)
+               goto out;
+       fsstack_copy_attr_atime(dentry->d_inode,
+                               lower_path.dentry->d_inode);
 out:
        wrapfs_put_lower_path(dentry, &lower_path);
        return err;
@@ -511,18 +514,20 @@ wrapfs_removexattr(struct dentry *dentry, const char *name)
 
        wrapfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
-       if (!lower_dentry->d_inode->i_op ||
-           !lower_dentry->d_inode->i_op->removexattr) {
-               err = -EINVAL;
+       if (!lower_dentry->d_inode->i_op->removexattr) {
+               err = -EOPNOTSUPP;
                goto out;
        }
-
-       err = lower_dentry->d_inode->i_op->removexattr(lower_dentry,
-                                                      name);
+       err = vfs_removexattr(lower_dentry, name);
+       if (err)
+               goto out;
+       fsstack_copy_attr_all(dentry->d_inode,
+                             lower_path.dentry->d_inode);
 out:
        wrapfs_put_lower_path(dentry, &lower_path);
        return err;
 }
+
 const struct inode_operations wrapfs_symlink_iops = {
        .readlink       = wrapfs_readlink,
        .permission     = wrapfs_permission,
index e0b4294fceb06a91c631b4f88b5be4d0075f415c..6a439aa1aec23e63b69e5d263e62f29dbd9205d3 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/uaccess.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/xattr.h>
 
 /* the file system name */
 #define WRAPFS_NAME "wrapfs"