]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bucket.h
`buckettools -c' now uses fastbufs for output.
[libucw.git] / lib / bucket.h
index ac14a6ddb01c99c070054b023140dd1798bb850d..b6f584a8f63d7365c0ccb5e8cd7788b72bfc8226 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Sherlock Library -- Object Buckets
  *
- *     (c) 2001--2003 Martin Mares <mj@ucw.cz>
+ *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -17,7 +17,9 @@
  *
  * Locking: Each operation on the pool is protected by a flock.
  *
- * The buckets emulate non-seekable fastbuf streams.
+ * The buckets emulate fastbuf streams. Read streams act as normal files,
+ * but there can be only one write stream which is non-seekable and you
+ * also shouldn't open new read streams when writing.
  *
  * fork()'ing if you don't have any bucket open is safe.
  */
@@ -64,7 +66,6 @@ int obuck_find_next(struct obuck_header *hdrp, int full);
 
 /* Reading current bucket */
 struct fastbuf *obuck_fetch(void);
-void obuck_fetch_end(struct fastbuf *b);
 
 /* Creating buckets */
 struct fastbuf *obuck_create(u32 type);
@@ -83,6 +84,13 @@ static inline sh_off_t obuck_get_pos(oid_t oid)
   return ((sh_off_t) oid) << OBUCK_SHIFT;
 }
 
+/* Calculate size of bucket which contains given amount of data */
+
+static inline uns obuck_bucket_size(uns len)
+{
+  return ALIGN(sizeof(struct obuck_header) + len + 4, OBUCK_ALIGN);
+}
+
 /* Shaking down bucket file */
 void obuck_shakedown(int (*kibitz)(struct obuck_header *old, oid_t new, byte *buck));