xattr_user.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 (!reiserfs_xattrs_user(dentry->d_sb))
  13. return -EOPNOTSUPP;
  14. return reiserfs_xattr_get(d_inode(dentry),
  15. xattr_full_name(handler, name),
  16. 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 (!reiserfs_xattrs_user(dentry->d_sb))
  23. return -EOPNOTSUPP;
  24. return reiserfs_xattr_set(d_inode(dentry),
  25. xattr_full_name(handler, name),
  26. 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. };