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.
19 extern byte *obuck_name; /* Internal, for use by buckettool only! */
22 #define OBUCK_ALIGN (1<<OBUCK_SHIFT)
23 #define OBUCK_MAGIC 0xdeadf00d
24 #define OBUCK_INCOMPLETE_MAGIC 0xdeadfeel
25 #define OBUCK_TRAILER 0xfeedcafe
26 #define OBUCK_OID_DELETED (~(oid_t)0)
29 u32 magic; /* OBUCK_MAGIC should dwell here */
30 oid_t oid; /* ID of this object or OBUCK_OID_DELETED */
31 u32 length; /* Length of compressed data in the bucket */
32 u32 orig_length; /* Length of uncompressed data */
33 /* Bucket data continue here */
38 void obuck_init(int writeable); /* Initialize the bucket module */
39 void obuck_cleanup(void); /* Clean up the bucket module */
40 void obuck_sync(void); /* Flush all buffers to disk */
42 /* Searching for buckets */
43 void obuck_find_by_oid(struct obuck_header *hdrp);
44 int obuck_find_first(struct obuck_header *hdrp, int full);
45 int obuck_find_next(struct obuck_header *hdrp, int full);
47 /* Reading current bucket */
48 struct fastbuf *obuck_fetch(void);
49 void obuck_fetch_end(struct fastbuf *b);
51 /* Creating buckets */
52 struct fastbuf *obuck_create(void);
53 void obuck_create_end(struct fastbuf *b, struct obuck_header *hdrp);
55 /* Deleting buckets */
56 void obuck_delete(oid_t oid);