xattr_trusted.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * linux/fs/ext4/xattr_trusted.c
  3. * Handler for trusted extended attributes.
  4. *
  5. * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
  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 *dentry, const char *name, void *buffer,
  21. size_t size)
  22. {
  23. return ext4_xattr_get(d_inode(dentry), 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 *dentry, const char *name,
  29. const void *value, size_t size, int flags)
  30. {
  31. return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_TRUSTED,
  32. name, value, size, flags);
  33. }
  34. const struct xattr_handler ext4_xattr_trusted_handler = {
  35. .prefix = XATTR_TRUSTED_PREFIX,
  36. .list = ext4_xattr_trusted_list,
  37. .get = ext4_xattr_trusted_get,
  38. .set = ext4_xattr_trusted_set,
  39. };