xattr.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #ifndef _JFFS2_FS_XATTR_H_
  12. #define _JFFS2_FS_XATTR_H_
  13. #include <linux/xattr.h>
  14. #include <linux/list.h>
  15. #define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
  16. #define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
  17. #define JFFS2_XFLAGS_DEAD (0x40) /* This datum is already dead */
  18. #define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
  19. struct jffs2_xattr_datum
  20. {
  21. void *always_null;
  22. struct jffs2_raw_node_ref *node;
  23. uint8_t class;
  24. uint8_t flags;
  25. uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
  26. struct list_head xindex; /* chained from c->xattrindex[n] */
  27. atomic_t refcnt; /* # of xattr_ref refers this */
  28. uint32_t xid;
  29. uint32_t version;
  30. uint32_t data_crc;
  31. uint32_t hashkey;
  32. char *xname; /* XATTR name without prefix */
  33. uint32_t name_len; /* length of xname */
  34. char *xvalue; /* XATTR value */
  35. uint32_t value_len; /* length of xvalue */
  36. };
  37. struct jffs2_inode_cache;
  38. struct jffs2_xattr_ref
  39. {
  40. void *always_null;
  41. struct jffs2_raw_node_ref *node;
  42. uint8_t class;
  43. uint8_t flags; /* Currently unused */
  44. u16 unused;
  45. uint32_t xseqno;
  46. union {
  47. struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
  48. uint32_t ino; /* only used in scanning/building */
  49. };
  50. union {
  51. struct jffs2_xattr_datum *xd; /* reference to jffs2_xattr_datum */
  52. uint32_t xid; /* only used in sccanning/building */
  53. };
  54. struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
  55. };
  56. #define XREF_DELETE_MARKER (0x00000001)
  57. static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
  58. {
  59. return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
  60. }
  61. #ifdef CONFIG_JFFS2_FS_XATTR
  62. extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
  63. extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c);
  64. extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c);
  65. extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
  66. uint32_t xid, uint32_t version);
  67. extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  68. extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  69. extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
  70. extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
  71. struct jffs2_raw_node_ref *raw);
  72. extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
  73. struct jffs2_raw_node_ref *raw);
  74. extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
  75. extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
  76. extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
  77. extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
  78. char *buffer, size_t size);
  79. extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
  80. const char *buffer, size_t size, int flags);
  81. extern const struct xattr_handler *jffs2_xattr_handlers[];
  82. extern const struct xattr_handler jffs2_user_xattr_handler;
  83. extern const struct xattr_handler jffs2_trusted_xattr_handler;
  84. extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
  85. #define jffs2_getxattr generic_getxattr
  86. #define jffs2_setxattr generic_setxattr
  87. #define jffs2_removexattr generic_removexattr
  88. #else
  89. #define jffs2_init_xattr_subsystem(c)
  90. #define jffs2_build_xattr_subsystem(c)
  91. #define jffs2_clear_xattr_subsystem(c)
  92. #define jffs2_xattr_do_crccheck_inode(c, ic)
  93. #define jffs2_xattr_delete_inode(c, ic)
  94. #define jffs2_xattr_free_inode(c, ic)
  95. #define jffs2_verify_xattr(c) (1)
  96. #define jffs2_xattr_handlers NULL
  97. #define jffs2_listxattr NULL
  98. #define jffs2_getxattr NULL
  99. #define jffs2_setxattr NULL
  100. #define jffs2_removexattr NULL
  101. #endif /* CONFIG_JFFS2_FS_XATTR */
  102. #ifdef CONFIG_JFFS2_FS_SECURITY
  103. extern int jffs2_init_security(struct inode *inode, struct inode *dir,
  104. const struct qstr *qstr);
  105. extern const struct xattr_handler jffs2_security_xattr_handler;
  106. #else
  107. #define jffs2_init_security(inode,dir,qstr) (0)
  108. #endif /* CONFIG_JFFS2_FS_SECURITY */
  109. #endif /* _JFFS2_FS_XATTR_H_ */