3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
11 static char phase4_qc_rcsid[] = "$Header$";
14 count_boxes(id, u, boxes)
21 if (u->potype == 'P') {
22 if (i = (int) hash_lookup(boxes, u->pobox_id))
23 hash_store(boxes, u->pobox_id, i+1);
25 printf("User %s(%s) has pobox on non-POP server %d\n",
26 u->fullname, u->login, u->pobox_id);
27 printf("Not fixing this error\n");
33 ##check_box_counts(id, cnt, counts)
37 ## int oldval, rowcount;
39 oldval = (int) hash_lookup(counts, id);
42 printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
43 ((struct machine *) hash_lookup(machines, id))->name,
45 if (single_fix("Update", 1)) {
46 ## range of s is serverhosts
47 ## replace s (value1 = cnt) where
48 ## s.service = "POP" and s.mach_id = id
49 ## inquire_equel(rowcount = "rowcount")
51 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
53 printf("Not fixed\n");
54 modified("serverhosts");
60 ##check_nfs_counts(id, n, hint)
67 if (n->allocated != val) {
68 printf("Count wrong on NFSphys %s:%s; is %d in db, counted %d\n",
69 ((struct machine *) hash_lookup(machines, n->mach_id))->name,
70 n->dir, n->allocated, val);
71 if (single_fix("Update", 1)) {
72 ## replace nfsphys (allocated = val) where nfsphys.nfsphys_id = id
73 ## inquire_equel(rowcount = "rowcount")
75 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
77 printf("Not fixed\n");
86 struct hash *boxes, *counts;
89 printf("Phase 4 - Checking counts\n");
91 dprintf("Doing POBoxes...\n");
92 boxes = create_hash(10);
93 counts = create_hash(10);
94 ## retrieve (id = serverhosts.mach_id, cnt = serverhosts.value1)
95 ## where serverhosts.service = "POP" {
96 hash_store(boxes, id, 1);
97 hash_store(counts, id, cnt);
99 hash_step(users, count_boxes, boxes);
100 hash_step(boxes, check_box_counts, counts);
102 dprintf("Doing NFSphys...\n");
103 hash_step(nfsphys, check_nfs_counts, 0);
109 ## int id, status, id2, id3;
110 ## char name[33], last[17], first[17], buf[257];
111 struct save_queue *sq;
116 dprintf("Loading users...\n");
117 users = create_hash(10000);
118 ## range of u is users
119 ## retrieve (id = u.users_id, name = u.login, last = u.#last,
120 ## first = u.#first, status = u.#status, buf = u.potype,
121 ## id2 = u.pop_id, id3 = u.box_id)
122 ## where u.potype = "POP" {
123 u = (struct user *) malloc(sizeof(struct user));
124 strcpy(u->login, strtrim(name));
126 sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
127 u->fullname = strsave(buf);
140 hash_store(users, id, u);
143 dprintf("Loading machines...\n");
144 machines = create_hash(1000);
145 ## range of m is machine
146 ## retrieve (id = m.mach_id, name = m.#name) {
147 m = (struct machine *) malloc(sizeof(struct machine));
148 strcpy(m->name, strtrim(name));
150 hash_store(machines, id, m);
153 dprintf("Loading nfsphys...\n");
154 nfsphys = create_hash(500);
155 ## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
156 ## id2 = nfsphys.mach_id, id3 = nfsphys.allocated) {
157 n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
158 strcpy(n->dir, strtrim(name));
163 hash_store(nfsphys, id, n);
166 dprintf("Counting quotas...\n");
167 ## retrieve (id = nfsquota.phys_id, id2 = nfsquota.quota) {
168 if (n = (struct nfsphys *) hash_lookup(nfsphys, id)) {