]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bucket.h
If have GET_O and GET_P, we should have PUT_O and PUT_P as well.
[libucw.git] / lib / bucket.h
index 23ac48bb2f46637d108f9d6f460284ff56adf5c1..759ef0e4761e4b035d8242a7bc57339bdb4f1280 100644 (file)
  * fork()'ing if you don't have any bucket open is safe.
  */
 
  * fork()'ing if you don't have any bucket open is safe.
  */
 
+extern byte *obuck_name;       /* Internal, for use by buckettool only! */
+
 #define OBUCK_SHIFT 7
 #define OBUCK_ALIGN (1<<OBUCK_SHIFT)
 #define OBUCK_MAGIC 0xdeadf00d
 #define OBUCK_SHIFT 7
 #define OBUCK_ALIGN (1<<OBUCK_SHIFT)
 #define OBUCK_MAGIC 0xdeadf00d
+#define OBUCK_INCOMPLETE_MAGIC 0xdeadfeel
 #define OBUCK_TRAILER 0xfeedcafe
 #define OBUCK_OID_DELETED (~(oid_t)0)
 #define OBUCK_TRAILER 0xfeedcafe
 #define OBUCK_OID_DELETED (~(oid_t)0)
+#define OBUCK_OID_FIRST_SPECIAL (~(oid_t)0xffff)
 
 struct obuck_header {
   u32 magic;                   /* OBUCK_MAGIC should dwell here */
 
 struct obuck_header {
   u32 magic;                   /* OBUCK_MAGIC should dwell here */
@@ -38,8 +42,8 @@ void obuck_sync(void);                /* Flush all buffers to disk */
 
 /* Searching for buckets */
 void obuck_find_by_oid(struct obuck_header *hdrp);
 
 /* Searching for buckets */
 void obuck_find_by_oid(struct obuck_header *hdrp);
-int obuck_find_first(struct obuck_header *hdrp);
-int obuck_find_next(struct obuck_header *hdrp);
+int obuck_find_first(struct obuck_header *hdrp, int full);
+int obuck_find_next(struct obuck_header *hdrp, int full);
 
 /* Reading current bucket */
 struct fastbuf *obuck_fetch(void);
 
 /* Reading current bucket */
 struct fastbuf *obuck_fetch(void);
@@ -51,3 +55,13 @@ void obuck_create_end(struct fastbuf *b, struct obuck_header *hdrp);
 
 /* Deleting buckets */
 void obuck_delete(oid_t oid);
 
 /* Deleting buckets */
 void obuck_delete(oid_t oid);
+
+/* Convert bucket ID to file position (for size limitations etc.) */
+
+static inline sh_off_t obuck_get_pos(oid_t oid)
+{
+  return ((sh_off_t) oid) << OBUCK_SHIFT;
+}
+
+/* Shaking down bucket file */
+void obuck_shakedown(int (*kibitz)(struct obuck_header *old, oid_t new, byte *buck));