xattr_trusted.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * JFFS2 -- Journalling Flash File System, Version 2.
  3. *
  4. * Copyright © 2006 NEC Corporation
  5. *
  6. * Created by KaiGai Kohei <[email protected]>
  7. *
  8. * For licensing information, see the file 'LICENCE' in this directory.
  9. *
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/fs.h>
  13. #include <linux/jffs2.h>
  14. #include <linux/xattr.h>
  15. #include <linux/mtd/mtd.h>
  16. #include "nodelist.h"
  17. static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
  18. struct dentry *unused, struct inode *inode,
  19. const char *name, void *buffer, size_t size)
  20. {
  21. return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED,
  22. name, buffer, size);
  23. }
  24. static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
  25. struct dentry *unused, struct inode *inode,
  26. const char *name, const void *buffer,
  27. size_t size, int flags)
  28. {
  29. return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED,
  30. name, buffer, size, flags);
  31. }
  32. static bool jffs2_trusted_listxattr(struct dentry *dentry)
  33. {
  34. return capable(CAP_SYS_ADMIN);
  35. }
  36. const struct xattr_handler jffs2_trusted_xattr_handler = {
  37. .prefix = XATTR_TRUSTED_PREFIX,
  38. .list = jffs2_trusted_listxattr,
  39. .set = jffs2_trusted_setxattr,
  40. .get = jffs2_trusted_getxattr
  41. };