xattr_user.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/fs/ext2/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/init.h>
  8. #include <linux/string.h>
  9. #include "ext2.h"
  10. #include "xattr.h"
  11. static bool
  12. ext2_xattr_user_list(struct dentry *dentry)
  13. {
  14. return test_opt(dentry->d_sb, XATTR_USER);
  15. }
  16. static int
  17. ext2_xattr_user_get(const struct xattr_handler *handler,
  18. struct dentry *unused, struct inode *inode,
  19. const char *name, void *buffer, size_t size)
  20. {
  21. if (!test_opt(inode->i_sb, XATTR_USER))
  22. return -EOPNOTSUPP;
  23. return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER,
  24. name, buffer, size);
  25. }
  26. static int
  27. ext2_xattr_user_set(const struct xattr_handler *handler,
  28. struct dentry *unused, struct inode *inode,
  29. const char *name, const void *value,
  30. size_t size, int flags)
  31. {
  32. if (!test_opt(inode->i_sb, XATTR_USER))
  33. return -EOPNOTSUPP;
  34. return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER,
  35. name, value, size, flags);
  36. }
  37. const struct xattr_handler ext2_xattr_user_handler = {
  38. .prefix = XATTR_USER_PREFIX,
  39. .list = ext2_xattr_user_list,
  40. .get = ext2_xattr_user_get,
  41. .set = ext2_xattr_user_set,
  42. };