xattr_trusted.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/fs/ext4/xattr_trusted.c
  4. * Handler for trusted extended attributes.
  5. *
  6. * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
  7. */
  8. #include <linux/string.h>
  9. #include <linux/capability.h>
  10. #include <linux/fs.h>
  11. #include "ext4_jbd2.h"
  12. #include "ext4.h"
  13. #include "xattr.h"
  14. static bool
  15. ext4_xattr_trusted_list(struct dentry *dentry)
  16. {
  17. return capable(CAP_SYS_ADMIN);
  18. }
  19. static int
  20. ext4_xattr_trusted_get(const struct xattr_handler *handler,
  21. struct dentry *unused, struct inode *inode,
  22. const char *name, void *buffer, size_t size)
  23. {
  24. return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED,
  25. name, buffer, size);
  26. }
  27. static int
  28. ext4_xattr_trusted_set(const struct xattr_handler *handler,
  29. struct dentry *unused, struct inode *inode,
  30. const char *name, const void *value,
  31. size_t size, int flags)
  32. {
  33. return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED,
  34. name, value, size, flags);
  35. }
  36. const struct xattr_handler ext4_xattr_trusted_handler = {
  37. .prefix = XATTR_TRUSTED_PREFIX,
  38. .list = ext4_xattr_trusted_list,
  39. .get = ext4_xattr_trusted_get,
  40. .set = ext4_xattr_trusted_set,
  41. };