xattr_user.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "reiserfs.h"
  2. #include <linux/errno.h>
  3. #include <linux/fs.h>
  4. #include <linux/pagemap.h>
  5. #include <linux/xattr.h>
  6. #include "xattr.h"
  7. #include <linux/uaccess.h>
  8. static int
  9. user_get(const struct xattr_handler *handler, struct dentry *dentry,
  10. const char *name, void *buffer, size_t size)
  11. {
  12. if (strlen(name) < sizeof(XATTR_USER_PREFIX))
  13. return -EINVAL;
  14. if (!reiserfs_xattrs_user(dentry->d_sb))
  15. return -EOPNOTSUPP;
  16. return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
  17. }
  18. static int
  19. user_set(const struct xattr_handler *handler, struct dentry *dentry,
  20. const char *name, const void *buffer, size_t size, int flags)
  21. {
  22. if (strlen(name) < sizeof(XATTR_USER_PREFIX))
  23. return -EINVAL;
  24. if (!reiserfs_xattrs_user(dentry->d_sb))
  25. return -EOPNOTSUPP;
  26. return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
  27. }
  28. static size_t user_list(const struct xattr_handler *handler,
  29. struct dentry *dentry, char *list, size_t list_size,
  30. const char *name, size_t name_len)
  31. {
  32. const size_t len = name_len + 1;
  33. if (!reiserfs_xattrs_user(dentry->d_sb))
  34. return 0;
  35. if (list && len <= list_size) {
  36. memcpy(list, name, name_len);
  37. list[name_len] = '\0';
  38. }
  39. return len;
  40. }
  41. const struct xattr_handler reiserfs_xattr_user_handler = {
  42. .prefix = XATTR_USER_PREFIX,
  43. .get = user_get,
  44. .set = user_set,
  45. .list = user_list,
  46. };