Skip to content
Browse files

removexattr vop support added

  • Loading branch information...
1 parent 1bb5317 commit 307b521700f2c03c7e7bebae72c7d9ffad8507f0 Rohan Puri committed Nov 18, 2010
Showing with 24 additions and 1 deletion.
  1. +1 −1 module/lzfs_vnops.c
  2. +14 −0 module/lzfs_xattr.c
  3. +9 −0 module/lzfs_xattr_user.c
View
2 module/lzfs_vnops.c
@@ -1082,7 +1082,7 @@ const struct inode_operations zfs_inode_operations = {
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.listxattr = lzfs_listxattr,
- .removexattr = generic_removexattr,
+ .removexattr = lzfs_removexattr,
};
const struct file_operations zfs_file_operations = {
View
14 module/lzfs_xattr.c
@@ -156,6 +156,20 @@ lzfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
return err;
}
+int
+lzfs_removexattr(struct dentry *dentry, const char *name)
+{
+ struct inode *inode = dentry->d_inode;
+ struct xattr_handler *handler;
+
+ handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+
+ if (!handler)
+ return -EOPNOTSUPP;
+
+ return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
+}
+
struct xattr_handler *lzfs_xattr_handlers[] = {
&lzfs_xattr_user_handler,
// &lzfs_xattr_trusted_handler,
View
9 module/lzfs_xattr_user.c
@@ -44,12 +44,20 @@ lzfs_xattr_user_set(struct inode *inode, const char *name,
.uio_segflg = UIO_SYSSPACE,
};
+
dvp = LZFS_ITOV(inode);
err = zfs_lookup(dvp, NULL, &vp, NULL, LOOKUP_XATTR | CREATE_XATTR_DIR,
NULL, (struct cred *) cred, NULL, NULL, NULL);
if(err) {
return -err;
}
+
+ if(!value) {
+ err =zfs_remove(vp, (char *) name,
+ (struct cred *)cred, NULL, 0);
+ return -err;
+ }
+
vap = kmalloc(sizeof(vattr_t), GFP_KERNEL);
ASSERT(vap != NULL);
@@ -63,6 +71,7 @@ lzfs_xattr_user_set(struct inode *inode, const char *name,
xattr_name = kzalloc(strlen(name) + 6, GFP_KERNEL);
xattr_name = strncpy(xattr_name, "user.", 5);
xattr_name = strncat(xattr_name, name, strlen(name));
+
err = zfs_create(vp, xattr_name, vap, 0, 0644,
&xvp, (struct cred *)cred, 0, NULL, NULL);
kfree(vap);

0 comments on commit 307b521

Please sign in to comment.
Something went wrong with that request. Please try again.