xattr_user.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * linux/fs/hfsplus/xattr_user.c
  3. *
  4. * Vyacheslav Dubeyko <slava@dubeyko.com>
  5. *
  6. * Handler for user extended attributes.
  7. */
  8. #include <linux/nls.h>
  9. #include "hfsplus_fs.h"
  10. #include "xattr.h"
  11. static int hfsplus_user_getxattr(struct dentry *dentry, const char *name,
  12. void *buffer, size_t size, int type)
  13. {
  14. char *xattr_name;
  15. int res;
  16. if (!strcmp(name, ""))
  17. return -EINVAL;
  18. xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
  19. GFP_KERNEL);
  20. if (!xattr_name)
  21. return -ENOMEM;
  22. strcpy(xattr_name, XATTR_USER_PREFIX);
  23. strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name);
  24. res = hfsplus_getxattr(dentry, xattr_name, buffer, size);
  25. kfree(xattr_name);
  26. return res;
  27. }
  28. static int hfsplus_user_setxattr(struct dentry *dentry, const char *name,
  29. const void *buffer, size_t size, int flags, int type)
  30. {
  31. char *xattr_name;
  32. int res;
  33. if (!strcmp(name, ""))
  34. return -EINVAL;
  35. xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
  36. GFP_KERNEL);
  37. if (!xattr_name)
  38. return -ENOMEM;
  39. strcpy(xattr_name, XATTR_USER_PREFIX);
  40. strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name);
  41. res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
  42. kfree(xattr_name);
  43. return res;
  44. }
  45. static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list,
  46. size_t list_size, const char *name, size_t name_len, int type)
  47. {
  48. /*
  49. * This method is not used.
  50. * It is used hfsplus_listxattr() instead of generic_listxattr().
  51. */
  52. return -EOPNOTSUPP;
  53. }
  54. const struct xattr_handler hfsplus_xattr_user_handler = {
  55. .prefix = XATTR_USER_PREFIX,
  56. .list = hfsplus_user_listxattr,
  57. .get = hfsplus_user_getxattr,
  58. .set = hfsplus_user_setxattr,
  59. };