xattr_user.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/fs/ext4/xattr_user.c
  3. * Handler for extended user attributes.
  4. *
  5. * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
  6. */
  7. #include <linux/string.h>
  8. #include <linux/fs.h>
  9. #include "ext4_jbd2.h"
  10. #include "ext4.h"
  11. #include "xattr.h"
  12. static bool
  13. ext4_xattr_user_list(struct dentry *dentry)
  14. {
  15. return test_opt(dentry->d_sb, XATTR_USER);
  16. }
  17. static int
  18. ext4_xattr_user_get(const struct xattr_handler *handler,
  19. struct dentry *unused, struct inode *inode,
  20. const char *name, void *buffer, size_t size)
  21. {
  22. if (!test_opt(inode->i_sb, XATTR_USER))
  23. return -EOPNOTSUPP;
  24. return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER,
  25. name, buffer, size);
  26. }
  27. static int
  28. ext4_xattr_user_set(const struct xattr_handler *handler,
  29. struct dentry *unused, struct inode *inode,
  30. const char *name, const void *value,
  31. size_t size, int flags)
  32. {
  33. if (!test_opt(inode->i_sb, XATTR_USER))
  34. return -EOPNOTSUPP;
  35. return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER,
  36. name, value, size, flags);
  37. }
  38. const struct xattr_handler ext4_xattr_user_handler = {
  39. .prefix = XATTR_USER_PREFIX,
  40. .list = ext4_xattr_user_list,
  41. .get = ext4_xattr_user_get,
  42. .set = ext4_xattr_user_set,
  43. };