+ if (bf->cf)
+ return cf_write (bf->cf, no, offset, num, buf);
+ return mf_write (bf->mf, no, offset, num, buf);
+}
+
+int bf_commitExists (void)
+{
+ FILE *inf;
+
+ inf = open_cache ("r");
+ if (inf)
+ {
+ fclose (inf);
+ return 1;
+ }
+ return 0;
+}
+
+void bf_commitExec (void)
+{
+ FILE *inf;
+ int block_size;
+ char path[256];
+ MFile mf;
+ CFile cf;
+ int first_time;
+
+ assert (commit_area);
+ if (!(inf = open_cache ("r")))
+ {
+ logf (LOG_LOG, "No commit file");
+ return ;
+ }
+ while (fscanf (inf, "%s %d", path, &block_size) == 2)
+ {
+ mf = mf_open (0, path, block_size, 1);
+ cf = cf_open (mf, commit_area, path, block_size, 0, &first_time);
+
+ cf_commit (cf);
+
+ cf_close (cf);
+ mf_close (mf);
+ }
+ fclose (inf);
+}
+
+void bf_commitClean (void)
+{
+ FILE *inf;
+ int block_size;
+ char path[256];
+ MFile mf;
+ CFile cf;
+ int mustDisable = 0;
+ int firstTime;
+
+ if (!commit_area)
+ {
+ bf_cache (1);
+ mustDisable = 1;
+ }
+
+ if (!(inf = open_cache ("r")))
+ return ;
+ while (fscanf (inf, "%s %d", path, &block_size) == 2)
+ {
+ mf = mf_open (0, path, block_size, 0);
+ cf = cf_open (mf, commit_area, path, block_size, 1, &firstTime);
+ cf_unlink (cf);
+ cf_close (cf);
+ mf_close (mf);
+ }
+ fclose (inf);
+ unlink_cache ();
+ if (mustDisable)
+ bf_cache (0);