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, <[email protected]>
  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 user_namespace *mnt_userns,
  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 ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER,
  37. name, value, size, flags);
  38. }
  39. const struct xattr_handler ext2_xattr_user_handler = {
  40. .prefix = XATTR_USER_PREFIX,
  41. .list = ext2_xattr_user_list,
  42. .get = ext2_xattr_user_get,
  43. .set = ext2_xattr_user_set,
  44. };