]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bucket.h
Oops, the card array was reversed!
[libucw.git] / lib / bucket.h
index 7cc5d76c4932847217e364456f536a17d0a52ba3..24e7ae00d13c1a5d810a2eae38559de8960aa7ab 100644 (file)
@@ -2,6 +2,9 @@
  *     Sherlock Library -- Object Buckets
  *
  *     (c) 2001 Martin Mares <mj@ucw.cz>
  *     Sherlock Library -- Object Buckets
  *
  *     (c) 2001 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 /*
  */
 
 /*
@@ -24,6 +27,7 @@ extern byte *obuck_name;      /* Internal, for use by buckettool only! */
 #define OBUCK_INCOMPLETE_MAGIC 0xdeadfeel
 #define OBUCK_TRAILER 0xfeedcafe
 #define OBUCK_OID_DELETED (~(oid_t)0)
 #define OBUCK_INCOMPLETE_MAGIC 0xdeadfeel
 #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,6 +42,9 @@ struct fastbuf;
 void obuck_init(int writeable);        /* Initialize the bucket module */
 void obuck_cleanup(void);      /* Clean up the bucket module */
 void obuck_sync(void);         /* Flush all buffers to disk */
 void obuck_init(int writeable);        /* Initialize the bucket module */
 void obuck_cleanup(void);      /* Clean up the bucket module */
 void obuck_sync(void);         /* Flush all buffers to disk */
+void obuck_lock_read(void);    /* Explicit locking to make sure other threads don't touch buckets now */
+void obuck_lock_write(void);
+void obuck_unlock(void);
 
 /* Searching for buckets */
 void obuck_find_by_oid(struct obuck_header *hdrp);
 
 /* Searching for buckets */
 void obuck_find_by_oid(struct obuck_header *hdrp);
@@ -54,3 +61,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));