xattr.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*-------------------------------------------------------------------------*
  2. * File: fs/jffs2/xattr.c
  3. * XATTR support on JFFS2 FileSystem
  4. *
  5. * Implemented by KaiGai Kohei <kaigai@ak.jp.nec.com>
  6. * Copyright (C) 2006 NEC Corporation
  7. *
  8. * For licensing information, see the file 'LICENCE' in the jffs2 directory.
  9. *-------------------------------------------------------------------------*/
  10. #ifndef _JFFS2_FS_XATTR_H_
  11. #define _JFFS2_FS_XATTR_H_
  12. #include <linux/xattr.h>
  13. #include <linux/list.h>
  14. #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
  15. #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
  16. struct jffs2_xattr_datum
  17. {
  18. void *always_null;
  19. u8 class;
  20. u8 flags;
  21. u16 xprefix; /* see JFFS2_XATTR_PREFIX_* */
  22. struct jffs2_raw_node_ref *node;
  23. struct list_head xindex; /* chained from c->xattrindex[n] */
  24. uint32_t refcnt; /* # of xattr_ref refers this */
  25. uint32_t xid;
  26. uint32_t version;
  27. uint32_t data_crc;
  28. uint32_t hashkey;
  29. char *xname; /* XATTR name without prefix */
  30. uint32_t name_len; /* length of xname */
  31. char *xvalue; /* XATTR value */
  32. uint32_t value_len; /* length of xvalue */
  33. };
  34. struct jffs2_inode_cache; /* forward refence */
  35. struct jffs2_xattr_ref
  36. {
  37. void *always_null;
  38. u8 class;
  39. u8 flags; /* Currently unused */
  40. u16 unused;
  41. struct jffs2_raw_node_ref *node;
  42. union {
  43. struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
  44. uint32_t ino; /* only used in scanning/building */
  45. };
  46. union {
  47. struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */
  48. uint32_t xid; /* only used in sccanning/building */
  49. };
  50. struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
  51. };
  52. #ifdef CONFIG_JFFS2_FS_XATTR
  53. extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
  54. extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
  55. extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
  56. extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
  57. uint32_t xid, uint32_t version);
  58. extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  59. extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  60. extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
  61. extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
  62. extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
  63. extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
  64. char *buffer, size_t size);
  65. extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
  66. const char *buffer, size_t size, int flags);
  67. extern struct xattr_handler *jffs2_xattr_handlers[];
  68. extern struct xattr_handler jffs2_user_xattr_handler;
  69. extern struct xattr_handler jffs2_trusted_xattr_handler;
  70. extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
  71. #define jffs2_getxattr generic_getxattr
  72. #define jffs2_setxattr generic_setxattr
  73. #define jffs2_removexattr generic_removexattr
  74. #else
  75. #define jffs2_init_xattr_subsystem(c)
  76. #define jffs2_build_xattr_subsystem(c)
  77. #define jffs2_clear_xattr_subsystem(c)
  78. #define jffs2_xattr_delete_inode(c, ic)
  79. #define jffs2_xattr_free_inode(c, ic)
  80. #define jffs2_verify_xattr(c) (1)
  81. #define jffs2_xattr_handlers NULL
  82. #define jffs2_listxattr NULL
  83. #define jffs2_getxattr NULL
  84. #define jffs2_setxattr NULL
  85. #define jffs2_removexattr NULL
  86. #endif /* CONFIG_JFFS2_FS_XATTR */
  87. #ifdef CONFIG_JFFS2_FS_SECURITY
  88. extern int jffs2_init_security(struct inode *inode, struct inode *dir);
  89. extern struct xattr_handler jffs2_security_xattr_handler;
  90. #else
  91. #define jffs2_init_security(inode,dir) (0)
  92. #endif /* CONFIG_JFFS2_FS_SECURITY */
  93. #endif /* _JFFS2_FS_XATTR_H_ */