layout.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef NTDB_TEST_LAYOUT_H
  2. #define NTDB_TEST_LAYOUT_H
  3. #include "../private.h"
  4. struct ntdb_layout *new_ntdb_layout(void);
  5. void ntdb_layout_add_freetable(struct ntdb_layout *layout);
  6. void ntdb_layout_add_free(struct ntdb_layout *layout, ntdb_len_t len,
  7. unsigned ftable);
  8. void ntdb_layout_add_used(struct ntdb_layout *layout,
  9. NTDB_DATA key, NTDB_DATA data,
  10. ntdb_len_t extra);
  11. void ntdb_layout_add_capability(struct ntdb_layout *layout,
  12. uint64_t type,
  13. bool write_breaks,
  14. bool check_breaks,
  15. bool open_breaks,
  16. ntdb_len_t extra);
  17. #if 0 /* FIXME: Allow allocation of subtables */
  18. void ntdb_layout_add_hashtable(struct ntdb_layout *layout,
  19. int htable_parent, /* -1 == toplevel */
  20. unsigned int bucket,
  21. ntdb_len_t extra);
  22. #endif
  23. /* freefn is needed if we're using failtest_free. */
  24. struct ntdb_context *ntdb_layout_get(struct ntdb_layout *layout,
  25. void (*freefn)(void *),
  26. union ntdb_attribute *attr);
  27. void ntdb_layout_write(struct ntdb_layout *layout, void (*freefn)(void *),
  28. union ntdb_attribute *attr, const char *filename);
  29. void ntdb_layout_free(struct ntdb_layout *layout);
  30. enum layout_type {
  31. FREETABLE, FREE, DATA, CAPABILITY
  32. };
  33. /* Shared by all union members. */
  34. struct tle_base {
  35. enum layout_type type;
  36. ntdb_off_t off;
  37. };
  38. struct tle_freetable {
  39. struct tle_base base;
  40. };
  41. struct tle_free {
  42. struct tle_base base;
  43. ntdb_len_t len;
  44. unsigned ftable_num;
  45. };
  46. struct tle_used {
  47. struct tle_base base;
  48. NTDB_DATA key;
  49. NTDB_DATA data;
  50. ntdb_len_t extra;
  51. };
  52. struct tle_capability {
  53. struct tle_base base;
  54. uint64_t type;
  55. ntdb_len_t extra;
  56. };
  57. union ntdb_layout_elem {
  58. struct tle_base base;
  59. struct tle_freetable ftable;
  60. struct tle_free free;
  61. struct tle_used used;
  62. struct tle_capability capability;
  63. };
  64. struct ntdb_layout {
  65. unsigned int num_elems;
  66. union ntdb_layout_elem *elem;
  67. };
  68. #include "helprun-layout.h"
  69. #endif /* NTDB_TEST_LAYOUT_H */