xattr_user.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/fs/ext2/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/init.h>
  9. #include <linux/string.h>
  10. #include "ext2.h"
  11. #include "xattr.h"
  12. static bool
  13. ext2_xattr_user_list(struct dentry *dentry)
  14. {
  15. return test_opt(dentry->d_sb, XATTR_USER);
  16. }
  17. static int
  18. ext2_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 ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER,
  25. name, buffer, size);
  26. }
  27. static int
  28. ext2_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 ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER,
  36. name, value, size, flags);
  37. }
  38. const struct xattr_handler ext2_xattr_user_handler = {
  39. .prefix = XATTR_USER_PREFIX,
  40. .list = ext2_xattr_user_list,
  41. .get = ext2_xattr_user_get,
  42. .set = ext2_xattr_user_set,
  43. };