]> andersk Git - moira.git/blame - dbck/phase3.pc
Command line printer manipulation client, and build goo.
[moira.git] / dbck / phase3.pc
CommitLineData
7ac48069 1/* $Id$
68bbc9c3 2 *
7ac48069 3 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
5 * <mit-copyright.h>.
68bbc9c3 6 */
7
8#include <mit-copyright.h>
7ac48069 9#include <moira.h>
68bbc9c3 10#include "dbck.h"
11
7ac48069 12#include <stdio.h>
13
14RCSID("$Header$");
68bbc9c3 15
7ac48069 16void empty_list_check(int id, void *list, void *hint);
17void unref_string_check(int id, void *string, void *hint);
18void noclu_mach_check(int id, void *machine, void *hint);
68bbc9c3 19
7ac48069 20void empty_list_check(int id, void *list, void *hint)
68bbc9c3 21{
7ac48069 22 struct list *l = list;
5eaef520 23 if (l->members == 0 && l->list_id != 0)
24 printf("Warning: List %s is empty\n", l->name);
68bbc9c3 25}
26
27
28/* Used by other parts of the program to check that a string_id is good.
5eaef520 29 * This returns the stringif it is, or NULL if it is not, and as a side effect
68bbc9c3 30 * increments the string reference count.
31 */
32
5eaef520 33struct string *string_check(int id)
68bbc9c3 34{
44d12d58 35 struct string *s;
68bbc9c3 36
5eaef520 37 s = (struct string *) hash_lookup(strings, id);
38 if (!s)
39 return s;
40 s->refc++;
41 return s;
68bbc9c3 42}
43
44
7ac48069 45void unref_string_check(int id, void *string, void *hint)
68bbc9c3 46{
7ac48069 47 struct string *s = string;
48
5eaef520 49 if (s->refc == 0)
50 {
51 printf("Unreferenced string %s id %d\n", s->name, id);
52 if (single_fix("Delete", 1))
53 single_delete("strings", "string_id", id);
68bbc9c3 54 }
55}
56
ab05f33a 57/* This test was disabled because the MIT Moira server, which
5eaef520 58 * initially only managed host information for workstations and
ab05f33a 59 * servers in the Athena Computing Environment, has been extended to
60 * manage all hosts in the MIT.EDU domain (but not subdomains).
61 */
7ac48069 62void noclu_mach_check(int id, void *machine, void *hint)
68bbc9c3 63{
7ac48069 64 struct machine *m = machine;
65
5eaef520 66 if (m->clucount == 0 && m->mach_id != 0)
67 printf("Warning: machine %s is not in any clusters\n", m->name);
68bbc9c3 68}
68bbc9c3 69
7ac48069 70void phase3(void)
208a4f4a 71{
5eaef520 72 printf("Phase 3 - Finding unused objects\n");
68bbc9c3 73
5eaef520 74 if (warn)
75 {
76#ifndef ATHENA
77 dprintf("Checking machines...\n");
78 hash_step(machines, noclu_mach_check, NULL);
79#endif
80 dprintf("Checking lists...\n");
81 hash_step(lists, empty_list_check, NULL);
68bbc9c3 82 }
83
5eaef520 84 dprintf("Checking strings...\n");
85 hash_step(strings, unref_string_check, NULL);
208a4f4a 86}
68bbc9c3 87
This page took 1.278824 seconds and 5 git commands to generate.