2 * Copyright (C) 1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-11-30 08:33:13 adam
8 * Started work on commit facility.
20 void cf_commit (CFile cf)
24 struct CFile_ph_bucket *p;
26 if (cf->bucket_in_memory)
28 logf (LOG_FATAL, "Cannot commit potential dirty cache");
31 p = xmalloc (sizeof(*p));
32 hash_bytes = cf->head.hash_size * sizeof(int);
33 bucket_no = (hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
34 if (lseek (cf->hash_fd, bucket_no * HASH_BSIZE, SEEK_SET) < 0)
36 logf (LOG_FATAL|LOG_ERRNO, "seek commit");
39 for (; bucket_no < cf->head.next_bucket; bucket_no++)
41 r = read (cf->hash_fd, p, HASH_BSIZE);
44 logf (LOG_FATAL, "read commit hash");
47 for (i = 0; i<HASH_BUCKET && p->vno[i]; i++)
49 if (lseek (cf->block_fd, p->vno[i]*cf->head.block_size,
52 logf (LOG_FATAL, "lseek commit block");
55 r = read (cf->block_fd, cf->iobuf, cf->head.block_size);
56 if (r != cf->head.block_size)
58 logf (LOG_FATAL, "read commit block");
61 mf_write (cf->mf, p->no[i], 0, 0, cf->iobuf);