xattr_user.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_user_getxattr(struct inode *inode, const char *name,
  18. void *buffer, size_t size)
  19. {
  20. if (!strcmp(name, ""))
  21. return -EINVAL;
  22. return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size);
  23. }
  24. static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer,
  25. size_t size, int flags)
  26. {
  27. if (!strcmp(name, ""))
  28. return -EINVAL;
  29. return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size, flags);
  30. }
  31. static size_t jffs2_user_listxattr(struct inode *inode, char *list, size_t list_size,
  32. const char *name, size_t name_len)
  33. {
  34. size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1;
  35. if (list && retlen <= list_size) {
  36. strcpy(list, XATTR_USER_PREFIX);
  37. strcpy(list + XATTR_USER_PREFIX_LEN, name);
  38. }
  39. return retlen;
  40. }
  41. struct xattr_handler jffs2_user_xattr_handler = {
  42. .prefix = XATTR_USER_PREFIX,
  43. .list = jffs2_user_listxattr,
  44. .set = jffs2_user_setxattr,
  45. .get = jffs2_user_getxattr
  46. };