vfs: Remove {get,set,remove}xattr inode operations
[cascardo/linux.git] / fs / fuse / dir.c
index cca7b04..dbf77fe 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 #include <linux/namei.h>
 #include <linux/slab.h>
+#include <linux/xattr.h>
 
 static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx)
 {
@@ -146,7 +147,7 @@ static void fuse_invalidate_entry(struct dentry *entry)
 }
 
 static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args,
-                            u64 nodeid, struct qstr *name,
+                            u64 nodeid, const struct qstr *name,
                             struct fuse_entry_out *outarg)
 {
        memset(outarg, 0, sizeof(struct fuse_entry_out));
@@ -282,7 +283,7 @@ int fuse_valid_type(int m)
                S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
 }
 
-int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name,
+int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
                     struct fuse_entry_out *outarg, struct inode **inode)
 {
        struct fuse_conn *fc = get_fuse_conn_super(sb);
@@ -634,7 +635,7 @@ static int fuse_symlink(struct inode *dir, struct dentry *entry,
        return create_new_entry(fc, &args, dir, entry, S_IFLNK);
 }
 
-static inline void fuse_update_ctime(struct inode *inode)
+void fuse_update_ctime(struct inode *inode)
 {
        if (!IS_NOCMTIME(inode)) {
                inode->i_ctime = current_fs_time(inode->i_sb);
@@ -955,6 +956,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
        if (!dir)
                goto unlock;
 
+       name->hash = full_name_hash(dir, name->name, name->len);
        entry = d_lookup(dir, name);
        dput(dir);
        if (!entry)
@@ -1204,7 +1206,7 @@ static int fuse_direntplus_link(struct file *file,
 
        fc = get_fuse_conn(dir);
 
-       name.hash = full_name_hash(name.name, name.len);
+       name.hash = full_name_hash(parent, name.name, name.len);
        dentry = d_lookup(parent, &name);
        if (!dentry) {
 retry:
@@ -1723,152 +1725,6 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
        return fuse_update_attributes(inode, stat, NULL, NULL);
 }
 
-static int fuse_setxattr(struct dentry *unused, struct inode *inode,
-                        const char *name, const void *value,
-                        size_t size, int flags)
-{
-       struct fuse_conn *fc = get_fuse_conn(inode);
-       FUSE_ARGS(args);
-       struct fuse_setxattr_in inarg;
-       int err;
-
-       if (fc->no_setxattr)
-               return -EOPNOTSUPP;
-
-       memset(&inarg, 0, sizeof(inarg));
-       inarg.size = size;
-       inarg.flags = flags;
-       args.in.h.opcode = FUSE_SETXATTR;
-       args.in.h.nodeid = get_node_id(inode);
-       args.in.numargs = 3;
-       args.in.args[0].size = sizeof(inarg);
-       args.in.args[0].value = &inarg;
-       args.in.args[1].size = strlen(name) + 1;
-       args.in.args[1].value = name;
-       args.in.args[2].size = size;
-       args.in.args[2].value = value;
-       err = fuse_simple_request(fc, &args);
-       if (err == -ENOSYS) {
-               fc->no_setxattr = 1;
-               err = -EOPNOTSUPP;
-       }
-       if (!err) {
-               fuse_invalidate_attr(inode);
-               fuse_update_ctime(inode);
-       }
-       return err;
-}
-
-static ssize_t fuse_getxattr(struct dentry *entry, struct inode *inode,
-                            const char *name, void *value, size_t size)
-{
-       struct fuse_conn *fc = get_fuse_conn(inode);
-       FUSE_ARGS(args);
-       struct fuse_getxattr_in inarg;
-       struct fuse_getxattr_out outarg;
-       ssize_t ret;
-
-       if (fc->no_getxattr)
-               return -EOPNOTSUPP;
-
-       memset(&inarg, 0, sizeof(inarg));
-       inarg.size = size;
-       args.in.h.opcode = FUSE_GETXATTR;
-       args.in.h.nodeid = get_node_id(inode);
-       args.in.numargs = 2;
-       args.in.args[0].size = sizeof(inarg);
-       args.in.args[0].value = &inarg;
-       args.in.args[1].size = strlen(name) + 1;
-       args.in.args[1].value = name;
-       /* This is really two different operations rolled into one */
-       args.out.numargs = 1;
-       if (size) {
-               args.out.argvar = 1;
-               args.out.args[0].size = size;
-               args.out.args[0].value = value;
-       } else {
-               args.out.args[0].size = sizeof(outarg);
-               args.out.args[0].value = &outarg;
-       }
-       ret = fuse_simple_request(fc, &args);
-       if (!ret && !size)
-               ret = outarg.size;
-       if (ret == -ENOSYS) {
-               fc->no_getxattr = 1;
-               ret = -EOPNOTSUPP;
-       }
-       return ret;
-}
-
-static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
-{
-       struct inode *inode = d_inode(entry);
-       struct fuse_conn *fc = get_fuse_conn(inode);
-       FUSE_ARGS(args);
-       struct fuse_getxattr_in inarg;
-       struct fuse_getxattr_out outarg;
-       ssize_t ret;
-
-       if (!fuse_allow_current_process(fc))
-               return -EACCES;
-
-       if (fc->no_listxattr)
-               return -EOPNOTSUPP;
-
-       memset(&inarg, 0, sizeof(inarg));
-       inarg.size = size;
-       args.in.h.opcode = FUSE_LISTXATTR;
-       args.in.h.nodeid = get_node_id(inode);
-       args.in.numargs = 1;
-       args.in.args[0].size = sizeof(inarg);
-       args.in.args[0].value = &inarg;
-       /* This is really two different operations rolled into one */
-       args.out.numargs = 1;
-       if (size) {
-               args.out.argvar = 1;
-               args.out.args[0].size = size;
-               args.out.args[0].value = list;
-       } else {
-               args.out.args[0].size = sizeof(outarg);
-               args.out.args[0].value = &outarg;
-       }
-       ret = fuse_simple_request(fc, &args);
-       if (!ret && !size)
-               ret = outarg.size;
-       if (ret == -ENOSYS) {
-               fc->no_listxattr = 1;
-               ret = -EOPNOTSUPP;
-       }
-       return ret;
-}
-
-static int fuse_removexattr(struct dentry *entry, const char *name)
-{
-       struct inode *inode = d_inode(entry);
-       struct fuse_conn *fc = get_fuse_conn(inode);
-       FUSE_ARGS(args);
-       int err;
-
-       if (fc->no_removexattr)
-               return -EOPNOTSUPP;
-
-       args.in.h.opcode = FUSE_REMOVEXATTR;
-       args.in.h.nodeid = get_node_id(inode);
-       args.in.numargs = 1;
-       args.in.args[0].size = strlen(name) + 1;
-       args.in.args[0].value = name;
-       err = fuse_simple_request(fc, &args);
-       if (err == -ENOSYS) {
-               fc->no_removexattr = 1;
-               err = -EOPNOTSUPP;
-       }
-       if (!err) {
-               fuse_invalidate_attr(inode);
-               fuse_update_ctime(inode);
-       }
-       return err;
-}
-
 static const struct inode_operations fuse_dir_inode_operations = {
        .lookup         = fuse_lookup,
        .mkdir          = fuse_mkdir,
@@ -1883,10 +1739,7 @@ static const struct inode_operations fuse_dir_inode_operations = {
        .mknod          = fuse_mknod,
        .permission     = fuse_permission,
        .getattr        = fuse_getattr,
-       .setxattr       = fuse_setxattr,
-       .getxattr       = fuse_getxattr,
        .listxattr      = fuse_listxattr,
-       .removexattr    = fuse_removexattr,
 };
 
 static const struct file_operations fuse_dir_operations = {
@@ -1904,10 +1757,7 @@ static const struct inode_operations fuse_common_inode_operations = {
        .setattr        = fuse_setattr,
        .permission     = fuse_permission,
        .getattr        = fuse_getattr,
-       .setxattr       = fuse_setxattr,
-       .getxattr       = fuse_getxattr,
        .listxattr      = fuse_listxattr,
-       .removexattr    = fuse_removexattr,
 };
 
 static const struct inode_operations fuse_symlink_inode_operations = {
@@ -1915,10 +1765,7 @@ static const struct inode_operations fuse_symlink_inode_operations = {
        .get_link       = fuse_get_link,
        .readlink       = generic_readlink,
        .getattr        = fuse_getattr,
-       .setxattr       = fuse_setxattr,
-       .getxattr       = fuse_getxattr,
        .listxattr      = fuse_listxattr,
-       .removexattr    = fuse_removexattr,
 };
 
 void fuse_init_common(struct inode *inode)