2 * Sherlock Library -- Object Buckets
4 * (c) 2001 Martin Mares <mj@ucw.cz>
8 * Format: The object pool is merely a sequence of object buckets.
9 * Each bucket starts with struct obuck_header and it's padded
10 * by zeros to a multiple of OBUCK_ALIGN bytes.
12 * Locking: Each operation on the pool is protected by a flock.
14 * The buckets emulate non-seekable fastbuf streams.
16 * fork()'ing if you don't have any bucket open is safe.
20 #define OBUCK_ALIGN (1<<OBUCK_SHIFT)
21 #define OBUCK_MAGIC 0xdeadf00d
22 #define OBUCK_TRAILER 0xfeedcafe
23 #define OBUCK_OID_DELETED (~(oid_t)0)
26 u32 magic; /* OBUCK_MAGIC should dwell here */
27 oid_t oid; /* ID of this object or OBUCK_OID_DELETED */
28 u32 length; /* Length of compressed data in the bucket */
29 u32 orig_length; /* Length of uncompressed data */
30 /* Bucket data continue here */
35 void obuck_init(int writeable); /* Initialize the bucket module */
36 void obuck_cleanup(void); /* Clean up the bucket module */
37 void obuck_sync(void); /* Flush all buffers to disk */
39 /* Searching for buckets */
40 void obuck_find_by_oid(struct obuck_header *hdrp);
41 int obuck_find_first(struct obuck_header *hdrp);
42 int obuck_find_next(struct obuck_header *hdrp);
44 /* Reading current bucket */
45 struct fastbuf *obuck_fetch(void);
46 void obuck_fetch_end(struct fastbuf *b);
48 /* Creating buckets */
49 struct fastbuf *obuck_create(void);
50 void obuck_create_end(struct fastbuf *b, struct obuck_header *hdrp);
52 /* Deleting buckets */
53 void obuck_delete(oid_t oid);