summary.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * JFFS2 -- Journalling Flash File System, Version 2.
  3. *
  4. * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
  5. * Zoltan Sogor <weth@inf.u-szeged.hu>,
  6. * Patrik Kluba <pajko@halom.u-szeged.hu>,
  7. * University of Szeged, Hungary
  8. *
  9. * For licensing information, see the file 'LICENCE' in this directory.
  10. *
  11. * $Id: summary.h,v 1.2 2005/09/26 11:37:21 havasi Exp $
  12. *
  13. */
  14. #ifndef JFFS2_SUMMARY_H
  15. #define JFFS2_SUMMARY_H
  16. #include <linux/uio.h>
  17. #include <linux/jffs2.h>
  18. #define BLK_STATE_ALLFF 0
  19. #define BLK_STATE_CLEAN 1
  20. #define BLK_STATE_PARTDIRTY 2
  21. #define BLK_STATE_CLEANMARKER 3
  22. #define BLK_STATE_ALLDIRTY 4
  23. #define BLK_STATE_BADBLOCK 5
  24. #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
  25. #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
  26. #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
  27. #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
  28. #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
  29. /* Summary structures used on flash */
  30. struct jffs2_sum_unknown_flash
  31. {
  32. jint16_t nodetype; /* node type */
  33. };
  34. struct jffs2_sum_inode_flash
  35. {
  36. jint16_t nodetype; /* node type */
  37. jint32_t inode; /* inode number */
  38. jint32_t version; /* inode version */
  39. jint32_t offset; /* offset on jeb */
  40. jint32_t totlen; /* record length */
  41. } __attribute__((packed));
  42. struct jffs2_sum_dirent_flash
  43. {
  44. jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
  45. jint32_t totlen; /* record length */
  46. jint32_t offset; /* offset on jeb */
  47. jint32_t pino; /* parent inode */
  48. jint32_t version; /* dirent version */
  49. jint32_t ino; /* == zero for unlink */
  50. uint8_t nsize; /* dirent name size */
  51. uint8_t type; /* dirent type */
  52. uint8_t name[0]; /* dirent name */
  53. } __attribute__((packed));
  54. struct jffs2_sum_xattr_flash
  55. {
  56. jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
  57. jint32_t xid; /* xattr identifier */
  58. jint32_t version; /* version number */
  59. jint32_t offset; /* offset on jeb */
  60. jint32_t totlen; /* node length */
  61. } __attribute__((packed));
  62. struct jffs2_sum_xref_flash
  63. {
  64. jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
  65. jint32_t offset; /* offset on jeb */
  66. } __attribute__((packed));
  67. union jffs2_sum_flash
  68. {
  69. struct jffs2_sum_unknown_flash u;
  70. struct jffs2_sum_inode_flash i;
  71. struct jffs2_sum_dirent_flash d;
  72. struct jffs2_sum_xattr_flash x;
  73. struct jffs2_sum_xref_flash r;
  74. };
  75. /* Summary structures used in the memory */
  76. struct jffs2_sum_unknown_mem
  77. {
  78. union jffs2_sum_mem *next;
  79. jint16_t nodetype; /* node type */
  80. };
  81. struct jffs2_sum_inode_mem
  82. {
  83. union jffs2_sum_mem *next;
  84. jint16_t nodetype; /* node type */
  85. jint32_t inode; /* inode number */
  86. jint32_t version; /* inode version */
  87. jint32_t offset; /* offset on jeb */
  88. jint32_t totlen; /* record length */
  89. } __attribute__((packed));
  90. struct jffs2_sum_dirent_mem
  91. {
  92. union jffs2_sum_mem *next;
  93. jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
  94. jint32_t totlen; /* record length */
  95. jint32_t offset; /* ofset on jeb */
  96. jint32_t pino; /* parent inode */
  97. jint32_t version; /* dirent version */
  98. jint32_t ino; /* == zero for unlink */
  99. uint8_t nsize; /* dirent name size */
  100. uint8_t type; /* dirent type */
  101. uint8_t name[0]; /* dirent name */
  102. } __attribute__((packed));
  103. struct jffs2_sum_xattr_mem
  104. {
  105. union jffs2_sum_mem *next;
  106. jint16_t nodetype;
  107. jint32_t xid;
  108. jint32_t version;
  109. jint32_t offset;
  110. jint32_t totlen;
  111. } __attribute__((packed));
  112. struct jffs2_sum_xref_mem
  113. {
  114. union jffs2_sum_mem *next;
  115. jint16_t nodetype;
  116. jint32_t offset;
  117. } __attribute__((packed));
  118. union jffs2_sum_mem
  119. {
  120. struct jffs2_sum_unknown_mem u;
  121. struct jffs2_sum_inode_mem i;
  122. struct jffs2_sum_dirent_mem d;
  123. struct jffs2_sum_xattr_mem x;
  124. struct jffs2_sum_xref_mem r;
  125. };
  126. /* Summary related information stored in superblock */
  127. struct jffs2_summary
  128. {
  129. uint32_t sum_size; /* collected summary information for nextblock */
  130. uint32_t sum_num;
  131. uint32_t sum_padded;
  132. union jffs2_sum_mem *sum_list_head;
  133. union jffs2_sum_mem *sum_list_tail;
  134. jint32_t *sum_buf; /* buffer for writing out summary */
  135. };
  136. /* Summary marker is stored at the end of every sumarized erase block */
  137. struct jffs2_sum_marker
  138. {
  139. jint32_t offset; /* offset of the summary node in the jeb */
  140. jint32_t magic; /* == JFFS2_SUM_MAGIC */
  141. };
  142. #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
  143. #ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */
  144. #define jffs2_sum_active() (1)
  145. int jffs2_sum_init(struct jffs2_sb_info *c);
  146. void jffs2_sum_exit(struct jffs2_sb_info *c);
  147. void jffs2_sum_disable_collecting(struct jffs2_summary *s);
  148. int jffs2_sum_is_disabled(struct jffs2_summary *s);
  149. void jffs2_sum_reset_collected(struct jffs2_summary *s);
  150. void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
  151. int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
  152. unsigned long count, uint32_t to);
  153. int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
  154. int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
  155. int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
  156. int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
  157. int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
  158. int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
  159. int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
  160. struct jffs2_raw_summary *summary, uint32_t sumlen,
  161. uint32_t *pseudo_random);
  162. #else /* SUMMARY DISABLED */
  163. #define jffs2_sum_active() (0)
  164. #define jffs2_sum_init(a) (0)
  165. #define jffs2_sum_exit(a)
  166. #define jffs2_sum_disable_collecting(a)
  167. #define jffs2_sum_is_disabled(a) (0)
  168. #define jffs2_sum_reset_collected(a)
  169. #define jffs2_sum_add_kvec(a,b,c,d) (0)
  170. #define jffs2_sum_move_collected(a,b)
  171. #define jffs2_sum_write_sumnode(a) (0)
  172. #define jffs2_sum_add_padding_mem(a,b)
  173. #define jffs2_sum_add_inode_mem(a,b,c)
  174. #define jffs2_sum_add_dirent_mem(a,b,c)
  175. #define jffs2_sum_add_xattr_mem(a,b,c)
  176. #define jffs2_sum_add_xref_mem(a,b,c)
  177. #define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
  178. #endif /* CONFIG_JFFS2_SUMMARY */
  179. #endif /* JFFS2_SUMMARY_H */