]>
Commit | Line | Data |
---|---|---|
f3f86c75 | 1 | /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ |
2 | /* For copying and distribution information, please see the file */ | |
3 | /* <mit-copyright.h>. */ | |
4 | ||
5 | #include <mit-copyright.h> | |
6 | #include <stdio.h> | |
7 | ||
8 | char *malloc(), *strsave(); | |
9 | ||
10 | struct np { | |
11 | struct np *next; /* this must be the first field */ | |
12 | int id; | |
13 | char *dir; | |
14 | }; | |
15 | struct np **nfsphys = NULL; | |
16 | ||
17 | int match_phys(mach, directory) | |
18 | int mach; | |
19 | char *directory; | |
20 | { | |
21 | struct np *p, *n; | |
22 | ||
23 | if (nfsphys == NULL) | |
24 | ## { | |
25 | ## int id, maxmach, mid; | |
26 | ## char dir[65]; | |
27 | ||
28 | printf("Building NFSphys table\n"); | |
29 | ## range of n is nfsphys | |
30 | ## retrieve (maxmach = max(machine.mach_id)) | |
31 | maxmach++; | |
32 | nfsphys = (struct np **) malloc(maxmach * sizeof(struct np *)); | |
33 | bzero(nfsphys, maxmach * sizeof(struct np *)); | |
34 | ## retrieve (id = n.nfsphys_id, mid = n.mach_id, dir = n.#dir) | |
35 | ## sort by #dir:d { | |
36 | n = (struct np *) malloc(sizeof(struct np)); | |
37 | n->next = NULL; | |
38 | n->id = id; | |
39 | n->dir = strsave(strtrim(dir)); | |
40 | p = (struct np *)&nfsphys[mid]; | |
41 | while (p->next) | |
42 | p = p->next; | |
43 | p->next = n; | |
44 | ## } | |
45 | ## } | |
46 | ||
47 | if ((n = nfsphys[mach]) == NULL) | |
48 | return(0); | |
49 | while (n) { | |
50 | if (!strncmp(directory, n->dir, strlen(n->dir))) | |
51 | return(n->id); | |
52 | n = n->next; | |
53 | } | |
54 | return(0); | |
55 | } | |
56 | ||
57 | ||
58 | ##int match_filsys(mach, device, user) | |
59 | ##int mach; | |
60 | ##char *device; | |
61 | ##int user; | |
62 | ##{ | |
63 | ## int mid, fid; | |
64 | ## char dev[33]; | |
65 | ||
66 | ## repeat retrieve (fid = f.filsys_id, mid = f.mach_id, dev = n.#device) | |
67 | ## where f.label = u.login and n.nfsphys_id = f.phys_id and | |
68 | ## u.users_id = @user | |
69 | if (mid == mach && !strcmp(device, strtrim(dev))) | |
70 | return(fid); | |
71 | fid = 0; | |
72 | ## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and | |
73 | ## f.name = @device | |
74 | if (fid == 0) { | |
75 | ## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and | |
76 | ## f.phys_id = n.nfsphys_id and n.#device = @device | |
77 | } | |
78 | return(fid); | |
79 | ##} |