15 char buf[1024], junk[129];
16 ## int cell, quota, cnt, mach, oquota, id, who;
17 ## char name[81], type[9], volume[81], path[129], quotas[33];
18 ## char oname[129],otype[9];
19 char **arg = argv, *first_indir(), *second_indir(), *course_indir();
23 while (++arg - argv < argc) {
27 debug = atoi((*arg)[2] ? *arg+2 : *++arg);
30 fprintf(stderr, "Usage: %s [-d level] [inputfile]\n",
35 input = fopen(*arg, "r");
37 fprintf(stderr, "Unable to open in put file %s\n", *arg);
44 setenv("ING_SET", "set printqry");
48 if (debug) { printf("Opening database..."); fflush(stdout);}
51 if (debug) printf("done.\n");
53 ## range of f is filesys
54 ## range of m is machine
55 ## range of q is #quota
56 ## retrieve (cell = machine.mach_id) where machine.#name="ATHENA.MIT.EDU"
57 ## retrieve (who = users.users_id) where users.login="root"
59 while (!feof(input)) {
60 fgets(buf, sizeof(buf), input);
61 if (sscanf(buf, "%s %s %s %s %s %s %s %s %s %s %s %s",
62 name, type, junk, junk, junk, junk,
63 quotas, junk, junk, junk, junk, junk) < 12) {
64 fprintf(stderr, "unable to parse line: %s\n", buf);
68 if (!strcmp(type, "HOMEDIR")) {
69 sprintf(path, "/afs/athena.mit.edu/user/%s/%s/%s",
70 first_indir(name), second_indir(name), name);
71 } else if (!strcmp(type, "COURSE")) {
72 sprintf(path, "/afs/athena.mit.edu/course/%s/%s",
73 course_indir(name), name);
74 } else if (!strcmp(type, "ACTIVITY")) {
75 sprintf(path, "/afs/athena.mit.edu/activity/%s/%s",
76 first_indir(name), name);
77 } else if (!strcmp(type, "APROJ")) {
78 sprintf(path, "/afs/athena.mit.edu/astaff/project/%s",
80 } else if (!strcmp(type, "PROJECT")) {
81 sprintf(path, "/afs/athena.mit.edu/project/%s",
83 } else if (!strcmp(type, "AREF")) {
84 sprintf(path, "/afs/athena.mit.edu/astaff/reference/%s",
86 } else if (!strcmp(type, "REF")) {
87 sprintf(path, "/afs/athena.mit.edu/reference/%s",
89 } else if (!strcmp(type, "CONTRIB")) {
90 sprintf(path, "/afs/athena.mit.edu/contrib/%s",
92 } else if (!strcmp(type, "SW")) {
93 sprintf(path, "/afs/athena.mit.edu/software/%s",
95 } else if (!strcmp(type, "SYSTEM")) {
96 sprintf(path, "/afs/athena.mit.edu/system/%s",
99 fprintf(stderr, "Don't know how to deal with type %s\n", type);
102 ## repeat retrieve (otype = f.#type, mach = f.mach_id, oname = f.#name)
103 ## where f.label = @name {
105 printf("changing FS %s (%s, %s on %d) to (AFS, %s)\n",
106 name, type, oname, mach, path);
108 ## repeat replace f (phys_id=0, #type="AFS", mach_id=cell,
109 ## #name=@path, modtime=date("now"),
110 ## modby=who, modwith="migrate")
111 ## where f.label = @name
112 ## repeat retrieve (type = q.#type, id=q.entity_id, oquota=q.#quota)
113 ## where q.filsys_id = f.filsys_id and f.label=@name {
114 printf("removing quota (%d (%s %d) on %s)\n",
115 oquota, type, id, name);
117 ## repeat delete q where q.filsys_id = f.filsys_id and f.label=@name
118 printf("adding quota of %d on %s\n", quota, name);
119 ## repeat append #quota (filsys_id = f.filsys_id, #type="ANY",
120 ## entity_id=0, phys_id=0,
121 ## #quota=@quota, modtime=date("now"),
122 ## modby=who, modwith="migrate")
123 ## where f.label= @name
128 ## replace tblstats (updates = tblstats.updates + cnt,
129 ## modtime = date("now"))
130 ## where tblstats.tbl = "filesys"
131 ## replace tblstats (updates = tblstats.updates + cnt,
132 ## modtime = date("now"))
133 ## where tblstats.tbl = "quota"
136 if (debug) printf("Done.\n");
141 char *first_indir(name)
146 if (islower(name[0]))
147 sprintf(buf, "%c", name[0]);
149 sprintf(buf, "other");
153 char *second_indir(name)
158 if (islower(name[1]))
159 sprintf(buf, "%c", name[1]);
161 sprintf(buf, "other");
165 char *course_indir(name)
172 for (src = name; *src && isdigit(*src); src++)
176 strcpy(buf, "other");
187 fprintf(stderr, "An ingres error ocurred, code %d\n", *num);
190 fprintf(stderr, "Deadlock**************************\n");
193 fprintf(stderr, "Aborting\n");