xattr_user.c 1.4 KB

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