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(struct dentry *dentry, const char *name, void *buffer, size_t size,
  10. int handler_flags)
  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(struct dentry *dentry, const char *name, const void *buffer,
  20. size_t size, int flags, int handler_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(struct dentry *dentry, char *list, size_t list_size,
  29. const char *name, size_t name_len, int handler_flags)
  30. {
  31. const size_t len = name_len + 1;
  32. if (!reiserfs_xattrs_user(dentry->d_sb))
  33. return 0;
  34. if (list && len <= list_size) {
  35. memcpy(list, name, name_len);
  36. list[name_len] = '\0';
  37. }
  38. return len;
  39. }
  40. const struct xattr_handler reiserfs_xattr_user_handler = {
  41. .prefix = XATTR_USER_PREFIX,
  42. .get = user_get,
  43. .set = user_set,
  44. .list = user_list,
  45. };