xattr_user.c 1.2 KB

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