xattr_user.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 *dentry, const char *name,
  19. void *buffer, size_t size)
  20. {
  21. if (!test_opt(dentry->d_sb, XATTR_USER))
  22. return -EOPNOTSUPP;
  23. return ext2_xattr_get(d_inode(dentry), 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 *dentry, const char *name,
  29. const void *value, size_t size, int flags)
  30. {
  31. if (!test_opt(dentry->d_sb, XATTR_USER))
  32. return -EOPNOTSUPP;
  33. return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_USER,
  34. name, value, size, flags);
  35. }
  36. const struct xattr_handler ext2_xattr_user_handler = {
  37. .prefix = XATTR_USER_PREFIX,
  38. .list = ext2_xattr_user_list,
  39. .get = ext2_xattr_user_get,
  40. .set = ext2_xattr_user_set,
  41. };