|
|
1.1 root 1: # include <ingres.h>
2: # include <version.h>
3: # include <access.h>
4: # include <sccs.h>
5:
6: SCCSID(@(#)checkadmin.c 7.1 2/5/81)
7:
8: /*
9: ** CHECKADMIN -- check admin file version, etc.
10: **
11: ** The checks for database version code and whatnot are
12: ** factored out into this routine. When this routine returns,
13: ** the admin file should be legible to this program.
14: ** If the admin file is not legible, it will syserr.
15: **
16: ** Parameters:
17: ** fd -- open file descriptor for admin file. Only
18: ** read access is required.
19: **
20: ** Returns:
21: ** nothing if ok.
22: ** not at all (or via syserr) if not ok.
23: **
24: ** Side Effects:
25: ** The Admin.adhdr struct will be filled in.
26: */
27:
28: checkadmin(fd)
29: register int fd;
30: {
31: register int i;
32: register int k;
33:
34: i = ((char *) &Admin.adhdr.adversion) - ((char *) &Admin.adhdr);
35: if (read(fd, (char *) &Admin.adhdr, i) != i)
36: syserr("readadmin: admin read err 1");
37: if (!bitset(A_NEWFMT, Admin.adhdr.adflags))
38: syserr("readadmin: cannot use old databases");
39:
40: /* read in remainder of admin header */
41: i = sizeof Admin.adhdr;
42: if (Admin.adhdr.adlength < i)
43: i = Admin.adhdr.adlength;
44: i -= ((char *) &Admin.adhdr.adversion) - ((char *) &Admin.adhdr);
45: if (i <= 0)
46: syserr("readadmin: adlen=%d, hdrsz=%d, ct=%d", Admin.adhdr.adlength, sizeof Admin.adhdr, i);
47: if ((k = read(fd, (char *) &Admin.adhdr.adversion, i)) != i)
48: syserr("readadmin: admin read err 2, i=%d k=%d", i, k);
49:
50: /* check versions here */
51: if (Admin.adhdr.adversion != DBVERCODE)
52: syserr("cannot handle code %d databases (current code is %d)",
53: Admin.adhdr.adversion, DBVERCODE);
54: if (Admin.adhdr.adreldsz != sizeof Admin.adreld)
55: syserr("checkadmin: descriptor size mismatch, dec=%d, actual=%d",
56: Admin.adhdr.adreldsz, sizeof Admin.adreld);
57:
58: /* get to beginning of descriptors */
59: if (lseek(fd, (long) Admin.adhdr.adlength, 0) < 0)
60: syserr("checkadmin: seek");
61:
62: /* read the descriptors */
63: if (read(fd, (char *) &Admin.adreld, Admin.adhdr.adreldsz) != Admin.adhdr.adreldsz)
64: syserr("checkadmin: reld read sz=%d", Admin.adhdr.adreldsz);
65: if (read(fd, (char *) &Admin.adattd, Admin.adhdr.adattdsz) != Admin.adhdr.adattdsz)
66: syserr("checkadmin: attd read sz=%d", Admin.adhdr.adattdsz);
67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.