xattr_user.c 1.5 KB

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