xattr_trusted.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * JFFS2 -- Journalling Flash File System, Version 2.
  3. *
  4. * Copyright © 2006 NEC Corporation
  5. *
  6. * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
  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. int flags)
  21. {
  22. return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED,
  23. name, buffer, size);
  24. }
  25. static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
  26. struct dentry *unused, struct inode *inode,
  27. const char *name, const void *buffer,
  28. size_t size, int flags)
  29. {
  30. return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED,
  31. name, buffer, size, flags);
  32. }
  33. static bool jffs2_trusted_listxattr(struct dentry *dentry)
  34. {
  35. return capable(CAP_SYS_ADMIN);
  36. }
  37. const struct xattr_handler jffs2_trusted_xattr_handler = {
  38. .prefix = XATTR_TRUSTED_PREFIX,
  39. .list = jffs2_trusted_listxattr,
  40. .set = jffs2_trusted_setxattr,
  41. .get = jffs2_trusted_getxattr
  42. };