xattr_user.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "hfsplus_fs.h"
  9. #include "xattr.h"
  10. static int hfsplus_user_getxattr(struct dentry *dentry, const char *name,
  11. void *buffer, size_t size, int type)
  12. {
  13. char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0};
  14. size_t len = strlen(name);
  15. if (!strcmp(name, ""))
  16. return -EINVAL;
  17. if (len + XATTR_USER_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN)
  18. return -EOPNOTSUPP;
  19. strcpy(xattr_name, XATTR_USER_PREFIX);
  20. strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name);
  21. return hfsplus_getxattr(dentry, xattr_name, buffer, size);
  22. }
  23. static int hfsplus_user_setxattr(struct dentry *dentry, const char *name,
  24. const void *buffer, size_t size, int flags, int type)
  25. {
  26. char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0};
  27. size_t len = strlen(name);
  28. if (!strcmp(name, ""))
  29. return -EINVAL;
  30. if (len + XATTR_USER_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN)
  31. return -EOPNOTSUPP;
  32. strcpy(xattr_name, XATTR_USER_PREFIX);
  33. strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name);
  34. return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
  35. }
  36. static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list,
  37. size_t list_size, const char *name, size_t name_len, int type)
  38. {
  39. /*
  40. * This method is not used.
  41. * It is used hfsplus_listxattr() instead of generic_listxattr().
  42. */
  43. return -EOPNOTSUPP;
  44. }
  45. const struct xattr_handler hfsplus_xattr_user_handler = {
  46. .prefix = XATTR_USER_PREFIX,
  47. .list = hfsplus_user_listxattr,
  48. .get = hfsplus_user_getxattr,
  49. .set = hfsplus_user_setxattr,
  50. };