- lseek(bf->fd, no * bf->block_size + offset, 0);
- return(write(bf->fd, buf, num ? num : bf->block_size));
+ if (bf->cf)
+ return cf_write (bf->cf, no, offset, num, buf);
+ return mf_write (bf->mf, no, offset, num, buf);
+}
+
+void bf_commit (const char *name)
+{
+ FILE *inf;
+ int block_size;
+ char path[256];
+ MFile mf;
+ CFile cf;
+ int first_time;
+
+ if (!(inf = fopen (name, "r")))
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "cannot open commit %s", name);
+ exit (1);
+ }
+ while (fscanf (inf, "%s %d", path, &block_size) == 1)
+ {
+ mf = mf_open(0, path, block_size, 1);
+ cf = cf_open(mf, name, path, block_size, 0, &first_time);
+
+ cf_commit (cf);
+
+ cf_close (cf);
+ mf_close (mf);
+ }
+ fclose (inf);