2 * Copyright (C) 1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.8 1996-02-07 14:03:49 adam
8 * Work on flat indexed shadow files.
10 * Revision 1.7 1996/02/07 10:08:46 adam
11 * Work on flat shadow (not finished yet).
13 * Revision 1.6 1995/12/15 12:36:53 adam
14 * Moved hash file information to union.
15 * Renamed commit files.
17 * Revision 1.5 1995/12/12 15:57:55 adam
18 * Implemented mf_unlink. cf_unlink uses mf_unlink.
20 * Revision 1.4 1995/12/11 09:03:55 adam
21 * New function: cf_unlink.
22 * New member of commit file head: state (0) deleted, (1) hash file.
24 * Revision 1.3 1995/12/01 16:24:29 adam
25 * Commit files use separate meta file area.
27 * Revision 1.2 1995/12/01 11:37:24 adam
28 * Cached/commit files implemented as meta-files.
30 * Revision 1.1 1995/11/30 08:33:13 adam
31 * Started work on commit facility.
42 void cf_unlink (CFile cf)
44 if (cf->bucket_in_memory)
46 logf (LOG_FATAL, "Cannot unlink potential dirty cache");
51 mf_unlink (cf->block_mf);
52 mf_unlink (cf->hash_mf);
56 static void cf_commit_hash (CFile cf)
60 struct CFile_ph_bucket *p;
62 p = xmalloc (sizeof(*p));
63 hash_bytes = cf->head.hash_size * sizeof(int);
64 bucket_no = cf->head.first_bucket;
65 for (; bucket_no < cf->head.next_bucket; bucket_no++)
67 if (!mf_read (cf->hash_mf, bucket_no, 0, 0, p))
69 logf (LOG_FATAL, "read commit hash");
72 for (i = 0; i<HASH_BUCKET && p->vno[i]; i++)
74 if (!mf_read (cf->block_mf, p->vno[i], 0, 0, cf->iobuf))
76 logf (LOG_FATAL, "read commit block");
79 mf_write (cf->rmf, p->no[i], 0, 0, cf->iobuf);
85 static void cf_commit_flat (CFile cf)
91 fp = xmalloc (HASH_BSIZE);
92 for (hno = cf->head.next_bucket; hno < cf->head.flat_bucket; hno++)
94 mf_read (cf->hash_mf, hno, 0, 0, fp);
95 for (i = 0; i < (HASH_BSIZE/sizeof(int)); i++)
99 if (!mf_read (cf->block_mf, fp[i], 0, 0, cf->iobuf))
101 logf (LOG_FATAL, "read commit block at %d (->%d)",
105 mf_write (cf->rmf, vno, 0, 0, cf->iobuf);
113 void cf_commit (CFile cf)
116 if (cf->bucket_in_memory)
118 logf (LOG_FATAL, "Cannot commit potential dirty cache");
121 if (cf->head.state == 1)
123 else if (cf->head.state == 2)