xattr_trusted.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * linux/fs/ext4/xattr_trusted.c
  3. * Handler for trusted extended attributes.
  4. *
  5. * Copyright (C) 2003 by Andreas Gruenbacher, <[email protected]>
  6. */
  7. #include <linux/string.h>
  8. #include <linux/capability.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_trusted_list(struct dentry *dentry)
  15. {
  16. return capable(CAP_SYS_ADMIN);
  17. }
  18. static int
  19. ext4_xattr_trusted_get(const struct xattr_handler *handler,
  20. struct dentry *unused, struct inode *inode,
  21. const char *name, void *buffer, size_t size)
  22. {
  23. return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED,
  24. name, buffer, size);
  25. }
  26. static int
  27. ext4_xattr_trusted_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. return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED,
  33. name, value, size, flags);
  34. }
  35. const struct xattr_handler ext4_xattr_trusted_handler = {
  36. .prefix = XATTR_TRUSTED_PREFIX,
  37. .list = ext4_xattr_trusted_list,
  38. .get = ext4_xattr_trusted_get,
  39. .set = ext4_xattr_trusted_set,
  40. };