+
+void bf_commitClean (BFiles bfs, const char *spec)
+{
+ FILE *inf;
+ int block_size;
+ char path[256];
+ MFile mf;
+ CFile cf;
+ int mustDisable = 0;
+ int firstTime;
+
+ if (!bfs->commit_area)
+ {
+ bf_cache (bfs, spec);
+ mustDisable = 1;
+ }
+
+ if (!(inf = open_cache (bfs, "rb")))
+ return ;
+ while (fscanf (inf, "%s %d", path, &block_size) == 2)
+ {
+ mf = mf_open (bfs->register_area, path, block_size, 0);
+ cf = cf_open (mf, bfs->commit_area, path, block_size, 1, &firstTime);
+ cf_unlink (cf);
+ cf_close (cf);
+ mf_close (mf);
+ }
+ fclose (inf);
+ unlink_cache (bfs);
+ if (mustDisable)
+ bf_cache (bfs, 0);
+}
+
+int bf_alloc(BFile bf, int no, zint *blocks)
+{
+ int i;
+ assert(bf->alloc_buf);
+ bf->header_dirty = 1;
+ for (i = 0; i < no; i++)
+ {
+ if (!bf->free_list)
+ blocks[i] = bf->last_block++;
+ else
+ {
+ char buf[16];
+ const char *cp = buf;
+ memset(buf, '\0', sizeof(buf));
+
+ blocks[i] = bf->free_list;
+ if (!bf_read(bf, bf->free_list, 0, sizeof(buf), buf))
+ {
+ yaz_log(YLOG_WARN, "Bad freelist entry " ZINT_FORMAT,
+ bf->free_list);
+ exit(1);
+ }
+ zebra_zint_decode(&cp, &bf->free_list);
+ }
+ }
+ return 0;
+}
+
+int bf_free(BFile bf, int no, const zint *blocks)
+{
+ int i;
+ assert(bf->alloc_buf);
+ bf->header_dirty = 1;
+ for (i = 0; i < no; i++)
+ {
+ char buf[16];
+ char *cp = buf;
+ memset(buf, '\0', sizeof(buf));
+ zebra_zint_encode(&cp, bf->free_list);
+ bf->free_list = blocks[i];
+ bf_write(bf, bf->free_list, 0, sizeof(buf), buf);
+ }
+ return 0;
+}
+
+int bfs_register_directory_stat(BFiles bfs, int no, const char **directory,
+ double *used_bytes, double *max_bytes)
+{
+ return mf_area_directory_stat(bfs->register_area, no, directory,
+ used_bytes, max_bytes);
+}
+
+
+int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory,
+ double *used_bytes, double *max_bytes)
+{
+ if (!bfs->commit_area)
+ return 0;
+ return mf_area_directory_stat(bfs->commit_area, no, directory,
+ used_bytes, max_bytes);
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+