xattr_user.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 *dentry, const char *name,
  20. void *buffer, size_t size)
  21. {
  22. if (!test_opt(dentry->d_sb, XATTR_USER))
  23. return -EOPNOTSUPP;
  24. return ext4_xattr_get(d_inode(dentry), 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 *dentry, const char *name,
  30. const void *value, size_t size, int flags)
  31. {
  32. if (!test_opt(dentry->d_sb, XATTR_USER))
  33. return -EOPNOTSUPP;
  34. return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_USER,
  35. name, value, size, flags);
  36. }
  37. const struct xattr_handler ext4_xattr_user_handler = {
  38. .prefix = XATTR_USER_PREFIX,
  39. .list = ext4_xattr_user_list,
  40. .get = ext4_xattr_user_get,
  41. .set = ext4_xattr_user_set,
  42. };