]>
Commit | Line | Data |
---|---|---|
402461ad | 1 | #if (!defined(lint) && !defined(SABER)) |
08345b74 | 2 | static char rcsid_module_c[] = "$Header$"; |
402461ad | 3 | #endif |
08345b74 | 4 | |
8defc06b | 5 | /* This is the file attach.c for the MOIRA Client, which allows a nieve |
6 | * user to quickly and easily maintain most parts of the MOIRA database. | |
08345b74 | 7 | * It Contains: Functions for maintaining data used by Hesiod |
8 | * to map courses/projects/users to their file systems, | |
9 | * and maintain filesys info. | |
10 | * | |
11 | * Created: 5/4/88 | |
12 | * By: Chris D. Peterson | |
08345b74 | 13 | * |
14 | * $Source$ | |
15 | * $Author$ | |
16 | * $Header$ | |
17 | * | |
0a2c64cb | 18 | * Copyright 1988 by the Massachusetts Institute of Technology. |
08345b74 | 19 | * |
20 | * For further information on copyright and distribution | |
21 | * see the file mit-copyright.h | |
22 | */ | |
23 | ||
08345b74 | 24 | #include <stdio.h> |
f071d8a7 | 25 | #include <string.h> |
8defc06b | 26 | #include <moira.h> |
27 | #include <moira_site.h> | |
08345b74 | 28 | #include <menu.h> |
7cb7d352 | 29 | #include <sys/types.h> |
30 | #include <sys/stat.h> | |
b7e66e09 | 31 | #include <ctype.h> |
08345b74 | 32 | |
461c03b6 | 33 | #include "mit-copyright.h" |
0a2c64cb | 34 | #include "defs.h" |
35 | #include "f_defs.h" | |
461c03b6 | 36 | #include "globals.h" |
461c03b6 | 37 | |
08345b74 | 38 | #define FS_ALIAS_TYPE "FILESYS" |
39 | ||
461c03b6 | 40 | #define LABEL 0 |
41 | #define MACHINE 1 | |
42 | #define GROUP 2 | |
43 | #define ALIAS 3 | |
08345b74 | 44 | |
9e2516d6 | 45 | #define NO_MACHINE ("\\[NONE\\]") /* C will remove one of the /'s here, |
46 | * and the other quotes the [ for | |
47 | * ingres' regexp facility. */ | |
b3197763 | 48 | #define NO_MACHINE_BAD ("[NONE]") |
9e2516d6 | 49 | |
1104552d | 50 | #define DEFAULT_TYPE ("AFS") |
85ca828a | 51 | #define DEFAULT_MACHINE DEFAULT_NONE |
52 | #define DEFAULT_PACK DEFAULT_NONE | |
7f6743f7 | 53 | #define DEFAULT_ACCESS ("w") |
85ca828a | 54 | #define DEFAULT_COMMENTS DEFAULT_COMMENT |
55 | #define DEFAULT_OWNER (user) | |
56 | #define DEFAULT_OWNERS (user) | |
57 | #define DEFAULT_CREATE DEFAULT_YES | |
7f6743f7 | 58 | #define DEFAULT_L_TYPE ("PROJECT") |
7cb7d352 | 59 | #define DEFAULT_CELL ("athena.mit.edu") |
85ca828a | 60 | |
61 | /* Function Name: SetDefaults | |
62 | * Description: sets the default values for filesystem additions. | |
63 | * Arguments: info - an array of char pointers to recieve defaults. | |
64 | * Returns: char ** (this array, now filled). | |
65 | */ | |
66 | ||
67 | static char ** | |
68 | SetDefaults(info, name) | |
69 | char ** info; | |
70 | char * name; | |
71 | { | |
7cce48da | 72 | char buf[BUFSIZ]; |
73 | ||
85ca828a | 74 | info[FS_NAME] = Strsave(name); |
75 | info[FS_TYPE] = Strsave(DEFAULT_TYPE); | |
76 | info[FS_MACHINE] = Strsave(DEFAULT_MACHINE); | |
77 | info[FS_PACK] = Strsave(DEFAULT_PACK); | |
7cce48da | 78 | sprintf(buf, "/mit/%s", name); |
79 | info[FS_M_POINT] = Strsave(buf); | |
85ca828a | 80 | info[FS_ACCESS] = Strsave(DEFAULT_ACCESS); |
81 | info[FS_COMMENTS] = Strsave(DEFAULT_COMMENTS); | |
82 | info[FS_OWNER] = Strsave(DEFAULT_OWNER); | |
83 | info[FS_OWNERS] = Strsave(DEFAULT_OWNERS); | |
84 | info[FS_CREATE] = Strsave(DEFAULT_CREATE); | |
85 | info[FS_L_TYPE] = Strsave(DEFAULT_L_TYPE); | |
86 | info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL; | |
87 | return(info); | |
88 | } | |
89 | ||
08345b74 | 90 | /* Function Name: GetFSInfo |
91 | * Description: Stores the info in a queue. | |
92 | * Arguments: type - type of information to get. | |
93 | * name - name of the item to get information on. | |
94 | * Returns: a pointer to the first element in the queue. | |
95 | */ | |
96 | ||
402461ad | 97 | static struct qelem * |
08345b74 | 98 | GetFSInfo(type, name) |
99 | int type; | |
100 | char *name; | |
101 | { | |
102 | int stat; | |
103 | struct qelem * elem = NULL; | |
85ca828a | 104 | char * args[5]; |
08345b74 | 105 | |
106 | switch (type) { | |
461c03b6 | 107 | case LABEL: |
8defc06b | 108 | if ( (stat = do_mr_query("get_filesys_by_label", 1, &name, |
14f99d7d | 109 | StoreInfo, (char *)&elem)) != 0) { |
9777ade9 | 110 | com_err(program_name, stat, " in GetFSInfo"); |
08345b74 | 111 | return(NULL); |
112 | } | |
113 | break; | |
461c03b6 | 114 | case MACHINE: |
8defc06b | 115 | if ( (stat = do_mr_query("get_filesys_by_machine", 1, &name, |
14f99d7d | 116 | StoreInfo, (char *)&elem)) != 0) { |
9777ade9 | 117 | com_err(program_name, stat, " in GetFSInfo"); |
08345b74 | 118 | return(NULL); |
119 | } | |
120 | break; | |
461c03b6 | 121 | case GROUP: |
8defc06b | 122 | if ( (stat = do_mr_query("get_filesys_by_group", 1, &name, |
14f99d7d | 123 | StoreInfo, (char *)&elem)) != 0) { |
9777ade9 | 124 | com_err(program_name, stat, " in GetFSInfo"); |
08345b74 | 125 | return(NULL); |
126 | } | |
127 | break; | |
461c03b6 | 128 | case ALIAS: |
85ca828a | 129 | args[ALIAS_NAME] = name; |
130 | args[ALIAS_TYPE] = FS_ALIAS_TYPE; | |
131 | args[ALIAS_TRANS] = "*"; | |
8defc06b | 132 | if ( (stat = do_mr_query("get_alias", 3, args, StoreInfo, |
14f99d7d | 133 | (char *) &elem)) != 0) { |
461c03b6 | 134 | com_err(program_name, stat, " in get_alias."); |
08345b74 | 135 | return(NULL); |
136 | } | |
137 | } | |
138 | ||
139 | return(QueueTop(elem)); | |
140 | } | |
141 | ||
85ca828a | 142 | /* Function Name: PrintFSAlias |
143 | * Description: Prints a filesystem alias | |
144 | * Arguments: info - an array contains the strings of info. | |
402461ad | 145 | * Returns: the name of the filesys - used be QueryLoop(). |
85ca828a | 146 | */ |
147 | ||
402461ad | 148 | static char * |
85ca828a | 149 | PrintFSAlias(info) |
150 | char ** info; | |
151 | { | |
152 | char buf[BUFSIZ]; | |
153 | ||
154 | sprintf(buf,"Alias: %-25s Filesystem: %s",info[ALIAS_NAME], | |
155 | info[ALIAS_TRANS]); | |
156 | Put_message(buf); | |
402461ad | 157 | return(info[ALIAS_NAME]); |
85ca828a | 158 | } |
159 | ||
9e2516d6 | 160 | static int fsgCount = 1; |
161 | ||
162 | static char * | |
163 | PrintFSGMembers(info) | |
164 | char ** info; | |
165 | { | |
166 | char print_buf[BUFSIZ]; | |
167 | ||
168 | sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)", fsgCount++, info[0], info[1]); | |
169 | Put_message(print_buf); | |
170 | return(info[0]); | |
171 | } | |
172 | ||
173 | ||
08345b74 | 174 | /* Function Name: PrintFSInfo |
175 | * Description: Prints the filesystem information. | |
176 | * Arguments: info - a pointer to the filesystem information. | |
177 | * Returns: none. | |
178 | */ | |
179 | ||
402461ad | 180 | static char * |
461c03b6 | 181 | PrintFSInfo(info) |
08345b74 | 182 | char ** info; |
183 | { | |
184 | char print_buf[BUFSIZ]; | |
9e2516d6 | 185 | |
85ca828a | 186 | FORMFEED; |
9e2516d6 | 187 | |
b4b1f800 | 188 | if (!strcmp(info[FS_TYPE], "FSGROUP") || !strcmp(info[FS_TYPE], "MUL")) { |
9e2516d6 | 189 | int stat; |
190 | struct qelem *elem = NULL; | |
191 | ||
b4b1f800 | 192 | if (!strcmp(info[FS_TYPE], "MUL")) |
193 | sprintf(print_buf,"%20s Multiple Filesystem: %s", " ", info[FS_NAME]); | |
194 | else | |
195 | sprintf(print_buf,"%20s Filesystem Group: %s", " ", info[FS_NAME]); | |
b3197763 | 196 | Put_message(print_buf); |
197 | ||
9777ade9 | 198 | sprintf(print_buf,"Comments: %s",info[FS_COMMENTS]); |
9e2516d6 | 199 | Put_message(print_buf); |
200 | sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME], | |
201 | info[FS_MODWITH]); | |
202 | Put_message(print_buf); | |
203 | Put_message("Containing the filesystems (in order):"); | |
8defc06b | 204 | if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME], |
9e2516d6 | 205 | StoreInfo, (char *)&elem)) != 0) { |
8defc06b | 206 | if (stat == MR_NO_MATCH) |
9e2516d6 | 207 | Put_message(" [no members]"); |
208 | else | |
9777ade9 | 209 | com_err(program_name, stat, " in PrintFSInfo"); |
9e2516d6 | 210 | } else { |
211 | fsgCount = 1; | |
212 | Loop(QueueTop(elem), (void *) PrintFSGMembers); | |
213 | FreeQueue(elem); | |
214 | } | |
215 | } else { | |
b3197763 | 216 | sprintf(print_buf,"%20s Filesystem: %s", " ", info[FS_NAME]); |
217 | Put_message(print_buf); | |
9e2516d6 | 218 | sprintf(print_buf,"Type: %-40s Machine: %-15s", |
219 | info[FS_TYPE], info[FS_MACHINE]); | |
220 | Put_message(print_buf); | |
221 | sprintf(print_buf,"Default Access: %-2s Packname: %-17s Mountpoint %s ", | |
222 | info[FS_ACCESS], info[FS_PACK], info[FS_M_POINT]); | |
223 | Put_message(print_buf); | |
9777ade9 | 224 | sprintf(print_buf,"Comments: %s",info[FS_COMMENTS]); |
9e2516d6 | 225 | Put_message(print_buf); |
226 | sprintf(print_buf, "User Ownership: %-30s Group Ownership: %s", | |
227 | info[FS_OWNER], info[FS_OWNERS]); | |
228 | Put_message(print_buf); | |
03e8157a | 229 | sprintf(print_buf, "Update Fileserver: %-27s Locker Type: %s", |
9e2516d6 | 230 | atoi(info[FS_CREATE]) ? "ON" : "OFF", |
231 | info[FS_L_TYPE]); | |
232 | Put_message(print_buf); | |
233 | sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME], | |
234 | info[FS_MODWITH]); | |
235 | Put_message(print_buf); | |
236 | } | |
402461ad | 237 | return(info[FS_NAME]); |
08345b74 | 238 | } |
239 | ||
7cb7d352 | 240 | |
241 | char *canonicalize_cell(c) | |
242 | char *c; | |
243 | { | |
244 | struct stat stbuf; | |
245 | char path[512]; | |
246 | int count; | |
247 | ||
248 | sprintf(path, "/afs/%s", c); | |
249 | if (lstat(path, &stbuf) || !stbuf.st_mode&S_IFLNK) | |
250 | return(c); | |
251 | count = readlink(path, path, sizeof(path)); | |
252 | if (count < 1) return(c); | |
253 | path[count] = 0; | |
254 | free(c); | |
255 | return(strsave(path)); | |
256 | } | |
257 | ||
258 | ||
259 | int GetAliasValue(argc, argv, retval) | |
260 | int argc; | |
261 | char **argv; | |
262 | char **retval; | |
263 | { | |
264 | *retval = strsave(argv[2]); | |
265 | return(MR_CONT); | |
266 | } | |
267 | ||
08345b74 | 268 | /* Function Name: AskFSInfo. |
269 | * Description: This function askes the user for information about a | |
270 | * machine and saves it into a structure. | |
271 | * Arguments: info - a pointer the the structure to put the | |
272 | * info into. | |
273 | * name - add a newname field? (T/F) | |
274 | * Returns: none. | |
275 | */ | |
276 | ||
402461ad | 277 | static char ** |
461c03b6 | 278 | AskFSInfo(info, name) |
08345b74 | 279 | char ** info; |
280 | Bool name; | |
281 | { | |
4423dd45 | 282 | char temp_buf[BUFSIZ], *newname, access_type[32]; |
7cb7d352 | 283 | int fsgroup = 0, newdefaults = 0; |
08345b74 | 284 | |
402461ad | 285 | Put_message(""); |
286 | sprintf(temp_buf, "Changing Attributes of filesystem %s.", | |
85ca828a | 287 | info[FS_NAME]); |
08345b74 | 288 | Put_message(temp_buf); |
402461ad | 289 | Put_message(""); |
08345b74 | 290 | |
291 | if (name) { | |
292 | newname = Strsave(info[FS_NAME]); | |
44b10c87 | 293 | if (GetValueFromUser("The new name for this filesystem", |
294 | &newname) == SUB_ERROR) | |
295 | return(NULL); | |
08345b74 | 296 | } |
297 | ||
7cb7d352 | 298 | strcpy(temp_buf, info[FS_TYPE]); |
44b10c87 | 299 | if (GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]) == |
300 | SUB_ERROR) | |
301 | return(NULL); | |
b4b1f800 | 302 | if (!strcasecmp(info[FS_TYPE], "FSGROUP") || |
303 | !strcasecmp(info[FS_TYPE], "MUL")) | |
9e2516d6 | 304 | fsgroup++; |
7cb7d352 | 305 | if (strcasecmp(info[FS_TYPE], temp_buf)) |
306 | newdefaults++; | |
307 | if (fsgroup) { | |
9e2516d6 | 308 | free(info[FS_MACHINE]); |
309 | info[FS_MACHINE] = Strsave(NO_MACHINE); | |
310 | } else { | |
b3197763 | 311 | if (!strcmp(info[FS_MACHINE], NO_MACHINE_BAD)) { |
312 | free(info[FS_MACHINE]); | |
313 | info[FS_MACHINE] = Strsave(NO_MACHINE); | |
314 | } | |
7cb7d352 | 315 | if (!strcasecmp(info[FS_TYPE], "AFS")) { |
316 | if (!name || newdefaults) { | |
317 | free(info[FS_MACHINE]); | |
318 | info[FS_MACHINE] = strsave(DEFAULT_CELL); | |
319 | } | |
320 | if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) == | |
321 | SUB_ERROR) | |
322 | return(NULL); | |
323 | info[FS_MACHINE] = canonicalize_cell(info[FS_MACHINE]); | |
324 | } else { | |
325 | if (GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]) == | |
326 | SUB_ERROR) | |
327 | return(NULL); | |
328 | info[FS_MACHINE] = canonicalize_hostname(info[FS_MACHINE]); | |
329 | } | |
9e2516d6 | 330 | } |
331 | if (!fsgroup) { | |
7cb7d352 | 332 | if (!strcasecmp(info[FS_TYPE], "AFS")) { |
333 | char *path, *args[3], *p; | |
334 | int status, depth, i; | |
335 | if (GetTypeFromUser("Filesystem's lockertype", "lockertype", | |
336 | &info[FS_L_TYPE]) == SUB_ERROR) | |
337 | return(NULL); | |
338 | if (!name || newdefaults) { | |
339 | free(info[FS_PACK]); | |
340 | lowercase(info[FS_MACHINE]); | |
341 | sprintf(temp_buf, "%s:%s", info[FS_MACHINE], info[FS_L_TYPE]); | |
342 | args[0] = temp_buf; | |
343 | args[1] = "AFSPATH"; | |
344 | args[2] = "*"; | |
345 | path = "???"; | |
346 | status = do_mr_query("get_alias", 3, args, | |
347 | GetAliasValue, &path); | |
348 | if (status == MR_SUCCESS) { | |
f071d8a7 | 349 | p = strchr(path, ':'); |
7cb7d352 | 350 | if (p) { |
351 | *p = 0; | |
352 | depth = atoi(++p); | |
353 | } else | |
354 | depth = 0; | |
355 | sprintf(temp_buf, "/afs/%s/%s", info[FS_MACHINE], path); | |
b7e66e09 | 356 | if (depth >= 0) { |
357 | for (p=info[FS_NAME]; *p&&(p-info[FS_NAME])<depth; p++) { | |
358 | if (islower(*p)) { | |
359 | strcat(temp_buf, "/x"); | |
360 | temp_buf[strlen(temp_buf)-1] = *p; | |
d678d80c | 361 | } else { |
362 | sprintf(temp_buf, "/afs/%s/%s/other", info[FS_MACHINE], path); | |
363 | break; | |
364 | } | |
b7e66e09 | 365 | } |
366 | } else if (depth = -1) { | |
367 | if (isdigit(info[FS_NAME][0])) { | |
368 | strcat(temp_buf, "/"); | |
369 | depth = strlen(temp_buf); | |
370 | for (p = info[FS_NAME]; *p && isdigit(*p); p++) { | |
371 | temp_buf[depth++] = *p; | |
372 | temp_buf[depth] = 0; | |
373 | } | |
374 | } else | |
375 | strcat(temp_buf, "/other"); | |
376 | } else { | |
377 | /* no default */ | |
7cb7d352 | 378 | } |
379 | strcat(temp_buf, "/"); | |
380 | strcat(temp_buf, info[FS_NAME]); | |
381 | free(path); | |
382 | } else { | |
383 | sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE], | |
384 | lowercase(info[FS_L_TYPE]), info[FS_NAME]); | |
385 | } | |
386 | info[FS_PACK] = strsave(temp_buf); | |
387 | } | |
388 | } | |
44b10c87 | 389 | if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) == |
390 | SUB_ERROR) | |
391 | return(NULL); | |
392 | if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) == | |
393 | SUB_ERROR) | |
394 | return(NULL); | |
4423dd45 | 395 | sprintf(access_type, "fs_access_%s", info[FS_TYPE]); |
44b10c87 | 396 | if (GetTypeFromUser("Filesystem's Default Access", access_type, |
397 | &info[FS_ACCESS]) == SUB_ERROR) | |
398 | return(NULL); | |
9e2516d6 | 399 | } |
44b10c87 | 400 | if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS]) |
401 | == SUB_ERROR) | |
402 | return(NULL); | |
403 | if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) == | |
404 | SUB_ERROR) | |
405 | return(NULL); | |
406 | if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) == | |
407 | SUB_ERROR) | |
408 | return(NULL); | |
9e2516d6 | 409 | if (!fsgroup) |
03e8157a | 410 | if (GetYesNoValueFromUser("Propagate changes to fileserver", |
44b10c87 | 411 | &info[FS_CREATE]) == SUB_ERROR) |
412 | return(NULL); | |
7cb7d352 | 413 | if (strcasecmp(info[FS_TYPE], "AFS")) { |
414 | if (GetTypeFromUser("Filesystem's lockertype", "lockertype", | |
415 | &info[FS_L_TYPE]) == SUB_ERROR) | |
416 | return(NULL); | |
417 | } | |
08345b74 | 418 | |
419 | FreeAndClear(&info[FS_MODTIME], TRUE); | |
420 | FreeAndClear(&info[FS_MODBY], TRUE); | |
421 | FreeAndClear(&info[FS_MODWITH], TRUE); | |
422 | ||
423 | if (name) /* slide the newname into the #2 slot. */ | |
424 | SlipInNewName(info, newname); | |
425 | ||
426 | return(info); | |
427 | } | |
428 | ||
7cb7d352 | 429 | |
08345b74 | 430 | /* --------------- Filesystem Menu ------------- */ |
431 | ||
432 | /* Function Name: GetFS | |
433 | * Description: Get Filesystem information by name. | |
434 | * Arguments: argc, argv - name of filsys in argv[1]. | |
435 | * Returns: DM_NORMAL. | |
436 | */ | |
437 | ||
438 | /* ARGSUSED */ | |
439 | int | |
440 | GetFS(argc, argv) | |
441 | int argc; | |
442 | char **argv; | |
443 | { | |
0a2c64cb | 444 | struct qelem *top; |
08345b74 | 445 | |
0a2c64cb | 446 | top = GetFSInfo(LABEL, argv[1]); /* get info. */ |
447 | Loop(top, (void *) PrintFSInfo); | |
85ca828a | 448 | FreeQueue(top); /* clean the queue. */ |
ef1e47d8 | 449 | return (DM_NORMAL); |
450 | } | |
451 | ||
452 | /* Function Name: GetFSM | |
453 | * Description: Get Filesystem information by machine. | |
454 | * Arguments: argc, argv - name of server in argv[1]. | |
455 | * Returns: DM_NORMAL. | |
456 | */ | |
457 | ||
458 | /* ARGSUSED */ | |
459 | int | |
460 | GetFSM(argc, argv) | |
461 | int argc; | |
462 | char **argv; | |
463 | { | |
464 | struct qelem *top; | |
465 | ||
e48f7f39 | 466 | argv[1] = canonicalize_hostname(strsave(argv[1])); |
ef1e47d8 | 467 | top = GetFSInfo(MACHINE, argv[1]); /* get info. */ |
468 | Loop(top, (void *) PrintFSInfo); | |
469 | FreeQueue(top); /* clean the queue. */ | |
08345b74 | 470 | return (DM_NORMAL); |
471 | } | |
472 | ||
402461ad | 473 | /* Function Name: RealDeleteFS |
474 | * Description: Does the real deletion work. | |
475 | * Arguments: info - array of char *'s containing all useful info. | |
476 | * one_item - a Boolean that is true if only one item | |
477 | * in queue that dumped us here. | |
478 | * Returns: none. | |
479 | */ | |
480 | ||
481 | void | |
482 | RealDeleteFS(info, one_item) | |
483 | char ** info; | |
484 | Bool one_item; | |
485 | { | |
486 | int stat; | |
487 | char temp_buf[BUFSIZ]; | |
488 | ||
489 | /* | |
490 | * Deletetions are performed if the user hits 'y' on a list of multiple | |
491 | * filesystem, or if the user confirms on a unique alias. | |
492 | */ | |
493 | sprintf(temp_buf, "Are you sure that you want to delete filesystem %s", | |
494 | info[FS_NAME]); | |
495 | if(!one_item || Confirm(temp_buf)) { | |
8defc06b | 496 | if ( (stat = do_mr_query("delete_filesys", 1, |
14f99d7d | 497 | &info[FS_NAME], Scream, NULL)) != 0) |
402461ad | 498 | com_err(program_name, stat, " filesystem not deleted."); |
499 | else | |
500 | Put_message("Filesystem deleted."); | |
501 | } | |
502 | else | |
503 | Put_message("Filesystem not deleted."); | |
504 | } | |
505 | ||
08345b74 | 506 | /* Function Name: DeleteFS |
507 | * Description: Delete a filesystem give its name. | |
508 | * Arguments: argc, argv - argv[1] is the name of the filesystem. | |
509 | * Returns: none. | |
510 | */ | |
511 | ||
512 | /* ARGSUSED */ | |
513 | ||
514 | int | |
515 | DeleteFS(argc, argv) | |
516 | int argc; | |
517 | char **argv; | |
518 | { | |
402461ad | 519 | struct qelem *elem = GetFSInfo(LABEL, argv[1]); |
520 | QueryLoop(elem, PrintFSInfo, RealDeleteFS, "Delete the Filesystem"); | |
08345b74 | 521 | |
402461ad | 522 | FreeQueue(elem); |
08345b74 | 523 | return (DM_NORMAL); |
524 | } | |
525 | ||
402461ad | 526 | /* Function Name: RealChangeFS |
527 | * Description: performs the actual change to the filesys. | |
528 | * Arguments: info - the information | |
529 | * junk - an unused boolean. | |
530 | * Returns: none. | |
531 | */ | |
532 | ||
533 | /* ARGSUSED. */ | |
534 | static void | |
535 | RealChangeFS(info, junk) | |
536 | char ** info; | |
537 | Bool junk; | |
538 | { | |
539 | int stat; | |
9777ade9 | 540 | char ** args; |
bff71786 | 541 | extern Menu nfsphys_menu; |
542 | ||
9777ade9 | 543 | args = AskFSInfo(info, TRUE); |
544 | if (args == NULL) { | |
545 | Put_message("Aborted."); | |
546 | return; | |
547 | } | |
8defc06b | 548 | stat = do_mr_query("update_filesys", CountArgs(args), args, |
14f99d7d | 549 | NullFunc, NULL); |
bff71786 | 550 | switch (stat) { |
8defc06b | 551 | case MR_NFS: |
bff71786 | 552 | Put_message("That NFS filesystem is not exported."); |
d8997da7 | 553 | if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) { |
bff71786 | 554 | Do_menu(&nfsphys_menu, 0, NULL); |
d8997da7 | 555 | if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE) |
556 | == TRUE) { | |
8defc06b | 557 | if (stat = do_mr_query("update_filesys", CountArgs(args), args, |
14f99d7d | 558 | NullFunc, NULL)) |
bff71786 | 559 | com_err(program_name, stat, " filesystem not updated"); |
560 | else | |
561 | Put_message("filesystem sucessfully updated."); | |
562 | } | |
563 | } | |
564 | break; | |
8defc06b | 565 | case MR_SUCCESS: |
98cce88c | 566 | break; |
bff71786 | 567 | default: |
98cce88c | 568 | com_err(program_name, stat, " in UpdateFS"); |
bff71786 | 569 | } |
402461ad | 570 | } |
571 | ||
08345b74 | 572 | /* Function Name: ChangeFS |
573 | * Description: change the information in a filesys record. | |
574 | * Arguments: arc, argv - value of filsys in argv[1]. | |
575 | * Returns: DM_NORMAL. | |
576 | */ | |
577 | ||
578 | /* ARGSUSED */ | |
579 | int | |
580 | ChangeFS(argc, argv) | |
581 | char **argv; | |
582 | int argc; | |
583 | { | |
402461ad | 584 | struct qelem *elem = GetFSInfo(LABEL, argv[1]); |
585 | QueryLoop(elem, NullPrint, RealChangeFS, "Update the Filesystem"); | |
08345b74 | 586 | |
08345b74 | 587 | FreeQueue(elem); |
588 | return (DM_NORMAL); | |
589 | } | |
590 | ||
591 | /* Function Name: AddFS | |
592 | * Description: change the information in a filesys record. | |
593 | * Arguments: arc, argv - name of filsys in argv[1]. | |
594 | * Returns: DM_NORMAL. | |
595 | */ | |
596 | ||
597 | /* ARGSUSED */ | |
598 | int | |
599 | AddFS(argc, argv) | |
600 | char **argv; | |
601 | int argc; | |
602 | { | |
7cce48da | 603 | char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ]; |
85ca828a | 604 | int stat; |
bff71786 | 605 | extern Menu nfsphys_menu; |
08345b74 | 606 | |
607 | if ( !ValidName(argv[1]) ) | |
608 | return(DM_NORMAL); | |
609 | ||
8defc06b | 610 | if ( (stat = do_mr_query("get_filesys_by_label", 1, argv + 1, |
14f99d7d | 611 | NullFunc, NULL)) == 0) { |
08345b74 | 612 | Put_message ("A Filesystem by that name already exists."); |
613 | return(DM_NORMAL); | |
8defc06b | 614 | } else if (stat != MR_NO_MATCH) { |
461c03b6 | 615 | com_err(program_name, stat, " in AddFS"); |
08345b74 | 616 | return(DM_NORMAL); |
617 | } | |
618 | ||
44b10c87 | 619 | if ((args = AskFSInfo(SetDefaults(info, argv[1]), FALSE )) == NULL) { |
620 | Put_message("Aborted."); | |
621 | return(DM_NORMAL); | |
622 | } | |
461c03b6 | 623 | |
8defc06b | 624 | stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL); |
bff71786 | 625 | switch (stat) { |
8defc06b | 626 | case MR_NFS: |
bff71786 | 627 | Put_message("That NFS filesystem is not exported."); |
d8997da7 | 628 | if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) { |
bff71786 | 629 | Do_menu(&nfsphys_menu, 0, NULL); |
d8997da7 | 630 | if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE) |
631 | == TRUE) { | |
8defc06b | 632 | if (stat = do_mr_query("add_filesys", CountArgs(args), args, |
14f99d7d | 633 | NullFunc, NULL)) |
bff71786 | 634 | com_err(program_name, stat, " in AddFS"); |
635 | else | |
636 | Put_message("Created."); | |
637 | } | |
638 | } | |
639 | break; | |
8defc06b | 640 | case MR_SUCCESS: |
98cce88c | 641 | break; |
bff71786 | 642 | default: |
461c03b6 | 643 | com_err(program_name, stat, " in AddFS"); |
bff71786 | 644 | } |
08345b74 | 645 | |
8defc06b | 646 | if (stat == MR_SUCCESS && !strcasecmp(info[FS_L_TYPE], "HOMEDIR")) { |
7cce48da | 647 | static char *val[] = {"def_quota", NULL}; |
648 | static char *def_quota = NULL; | |
314752ee | 649 | char *argv[Q_QUOTA + 1]; |
7cce48da | 650 | struct qelem *top = NULL; |
651 | ||
652 | if (def_quota == NULL) { | |
8defc06b | 653 | stat = do_mr_query("get_value", CountArgs(val), val, |
7cce48da | 654 | StoreInfo, (char *) &top); |
8defc06b | 655 | if (stat != MR_SUCCESS) { |
7cce48da | 656 | com_err(program_name, stat, " getting default quota"); |
657 | } else { | |
658 | top = QueueTop(top); | |
659 | def_quota = Strsave(((char **)top->q_data)[0]); | |
660 | FreeQueue(top); | |
661 | } | |
662 | } | |
663 | if (def_quota != NULL) { | |
664 | sprintf(buf, "Give user %s a quota of %s on filesys %s (Y/N)", | |
665 | info[FS_NAME], def_quota, info[FS_NAME]); | |
44b10c87 | 666 | if (YesNoQuestion(buf, 1) == TRUE) { |
b124ed18 | 667 | argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME]; |
d25fad50 | 668 | if (!strcmp(info[FS_TYPE], "NFS")) |
669 | argv[Q_TYPE] = "USER"; | |
670 | else | |
671 | argv[Q_TYPE] = "ANY"; | |
7cce48da | 672 | argv[Q_QUOTA] = def_quota; |
b124ed18 | 673 | if ((stat = do_mr_query("add_quota", Q_QUOTA+1, argv, Scream, |
8defc06b | 674 | (char *) NULL)) != MR_SUCCESS) { |
7cce48da | 675 | com_err(program_name, stat, " while adding quota"); |
676 | } | |
677 | } | |
678 | } | |
d25fad50 | 679 | } else if (stat == MR_SUCCESS) { |
680 | if (YesNoQuestion("Assign a quota on this filesystem (Y/N)", 1) | |
681 | == TRUE) { | |
682 | parsed_argc = 1; | |
683 | parsed_argv[0] = info[FS_NAME]; | |
684 | AddQuota(); | |
685 | } | |
7cce48da | 686 | } |
687 | ||
08345b74 | 688 | FreeInfo(info); |
689 | return (DM_NORMAL); | |
690 | } | |
691 | ||
9e2516d6 | 692 | /* Function Name: SortAfter |
693 | * Description: choose a sortkey to cause an item to be added after | |
694 | * the count element in the queue | |
695 | * Arguments: queue of filesys names & sortkeys, queue count pointer | |
696 | * Returns: sort key to use. | |
697 | */ | |
698 | ||
699 | /* ARGSUSED */ | |
700 | char * | |
701 | SortAfter(elem, count) | |
702 | struct qelem *elem; | |
703 | int count; | |
704 | { | |
705 | char *prev, *next, prevnext, *key, keybuf[9]; | |
706 | ||
707 | /* first find the two keys we need to insert between */ | |
708 | prev = "A"; | |
709 | for (; count > 0; count--) { | |
710 | prev = ((char **)elem->q_data)[1]; | |
711 | if (elem->q_forw) | |
712 | elem = elem->q_forw; | |
713 | else | |
714 | break; | |
715 | } | |
716 | if (count > 0) | |
717 | next = "Z"; | |
718 | else | |
719 | next = ((char **)elem->q_data)[1]; | |
720 | ||
721 | /* now copy the matching characters */ | |
722 | for (key = keybuf; *prev && *prev == *next; next++) { | |
723 | *key++ = *prev++; | |
724 | } | |
725 | ||
726 | /* and set the last character */ | |
727 | if (*prev == 0) | |
728 | *prev = prevnext = 'A'; | |
729 | else | |
730 | prevnext = prev[1]; | |
731 | if (prevnext == 0) | |
732 | prevnext = 'A'; | |
733 | if (*next == 0) | |
734 | *next = 'Z'; | |
735 | if (*next - *prev > 1) { | |
736 | *key++ = (*next + *prev)/2; | |
737 | } else { | |
738 | *key++ = *prev; | |
739 | *key++ = (prevnext + 'Z')/2; | |
740 | } | |
741 | *key = 0; | |
742 | return(Strsave(keybuf)); | |
743 | } | |
744 | ||
745 | /* Function Name: AddFSToGroup | |
746 | * Description: add a filesystem to an FS group | |
747 | * Arguments: arc, argv - name of group in argv[1], filesys in argv[2]. | |
748 | * Returns: DM_NORMAL. | |
749 | */ | |
750 | ||
751 | /* ARGSUSED */ | |
752 | int | |
753 | AddFSToGroup(argc, argv) | |
754 | char **argv; | |
755 | int argc; | |
756 | { | |
757 | int stat, count; | |
758 | struct qelem *elem = NULL; | |
759 | char buf[BUFSIZ], *args[5], *bufp; | |
760 | ||
8defc06b | 761 | if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo, |
9e2516d6 | 762 | (char *)&elem)) != 0) { |
8defc06b | 763 | if (stat != MR_NO_MATCH) |
9e2516d6 | 764 | com_err(program_name, stat, " in AddFSToGroup"); |
765 | } | |
766 | if (elem == NULL) { | |
767 | args[0] = argv[1]; | |
768 | args[1] = argv[2]; | |
769 | args[2] = "M"; | |
8defc06b | 770 | stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL); |
9e2516d6 | 771 | if (stat) |
772 | com_err(program_name, stat, " in AddFSToGroup"); | |
773 | return(DM_NORMAL); | |
774 | } | |
775 | elem = QueueTop(elem); | |
776 | fsgCount = 1; | |
777 | Loop(elem, (void *) PrintFSGMembers); | |
778 | sprintf(buf, "%d", QueueCount(elem)); | |
779 | bufp = Strsave(buf); | |
44b10c87 | 780 | if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR) |
781 | return(DM_NORMAL); | |
9e2516d6 | 782 | count = atoi(bufp); |
783 | free(bufp); | |
784 | args[2] = SortAfter(elem, count); | |
785 | ||
786 | FreeQueue(QueueTop(elem)); | |
787 | args[0] = argv[1]; | |
788 | args[1] = argv[2]; | |
8defc06b | 789 | stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL); |
790 | if (stat == MR_EXISTS) { | |
9e2516d6 | 791 | Put_message("That filesystem is already a member of the group."); |
792 | Put_message("Use the order command if you want to change the sorting order."); | |
793 | } else if (stat) | |
794 | com_err(program_name, stat, " in AddFSToGroup"); | |
795 | return(DM_NORMAL); | |
796 | } | |
797 | ||
798 | ||
799 | /* Function Name: RemoveFSFromGroup | |
800 | * Description: delete a filesystem from an FS group | |
801 | * Arguments: arc, argv - name of group in argv[1]. | |
802 | * Returns: DM_NORMAL. | |
803 | */ | |
804 | ||
805 | /* ARGSUSED */ | |
806 | int | |
807 | RemoveFSFromGroup(argc, argv) | |
808 | char **argv; | |
809 | int argc; | |
810 | { | |
811 | int stat; | |
812 | char buf[BUFSIZ]; | |
813 | ||
814 | sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]); | |
815 | if (!Confirm(buf)) | |
816 | return(DM_NORMAL); | |
8defc06b | 817 | if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv+1, |
9e2516d6 | 818 | Scream, NULL)) != 0) { |
819 | com_err(program_name, stat, ", not removed."); | |
820 | } | |
821 | return(DM_NORMAL); | |
822 | } | |
823 | ||
824 | /* Function Name: ChangeFSGroupOrder | |
825 | * Description: change the sortkey on a filesys in an FSgroup | |
826 | * Arguments: arc, argv - name of group in argv[1]. | |
827 | * Returns: DM_NORMAL. | |
828 | */ | |
829 | ||
830 | /* ARGSUSED */ | |
831 | int | |
832 | ChangeFSGroupOrder(argc, argv) | |
833 | char **argv; | |
834 | int argc; | |
835 | { | |
860a8dbe | 836 | int stat, src, dst, i; |
837 | struct qelem *elem = NULL, *top, *tmpelem; | |
9e2516d6 | 838 | char buf[BUFSIZ], *bufp, *args[3]; |
839 | ||
8defc06b | 840 | if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo, |
9e2516d6 | 841 | (char *)&elem)) != 0) { |
8defc06b | 842 | if (stat == MR_NO_MATCH) { |
44b10c87 | 843 | sprintf(buf, |
844 | "Ether %s is not a filesystem group or it has no members", | |
845 | argv[1]); | |
9e2516d6 | 846 | Put_message(buf); |
847 | } else | |
848 | com_err(program_name, stat, " in ChangeFSGroupOrder"); | |
849 | return(DM_NORMAL); | |
850 | } | |
851 | top = QueueTop(elem); | |
852 | fsgCount = 1; | |
853 | Loop(top, (void *) PrintFSGMembers); | |
854 | while (1) { | |
855 | bufp = Strsave("1"); | |
44b10c87 | 856 | if (GetValueFromUser("Enter number of the filesystem to move:", |
857 | &bufp) == SUB_ERROR) | |
858 | return(DM_NORMAL); | |
9e2516d6 | 859 | src = atoi(bufp); |
860 | free(bufp); | |
861 | if (src < 0) { | |
862 | Put_message("You must enter a positive number (or 0 to abort)."); | |
863 | continue; | |
864 | } else if (src == 0) { | |
865 | Put_message("Aborted."); | |
866 | return(DM_NORMAL); | |
867 | } | |
860a8dbe | 868 | for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw); |
869 | if (i > 0) { | |
9e2516d6 | 870 | Put_message("You entered a number that is too high"); |
871 | continue; | |
872 | } | |
873 | break; | |
874 | } | |
860a8dbe | 875 | while (1) { |
876 | bufp = Strsave("0"); | |
44b10c87 | 877 | if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR) |
878 | return(DM_NORMAL); | |
860a8dbe | 879 | dst = atoi(bufp); |
880 | free(bufp); | |
881 | if (src == dst || src == dst + 1) { | |
882 | Put_message("That has no effect on the sorting order!"); | |
883 | return(DM_NORMAL); | |
884 | } | |
885 | if (dst < 0) { | |
886 | Put_message("You must enter a non-negative number."); | |
887 | continue; | |
888 | } | |
889 | for (tmpelem = top, i = dst; | |
890 | i-- > 1 && tmpelem->q_forw; | |
891 | tmpelem = tmpelem->q_forw); | |
892 | if (i > 0) { | |
893 | Put_message("You entered a number that is too high"); | |
894 | continue; | |
895 | } | |
896 | break; | |
9e2516d6 | 897 | } |
898 | args[2] = SortAfter(top, dst); | |
899 | args[0] = argv[1]; | |
900 | args[1] = ((char **)elem->q_data)[0]; | |
8defc06b | 901 | if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args, |
9e2516d6 | 902 | Scream, NULL)) != 0) { |
903 | com_err(program_name, stat, " in ChangeFSGroupOrder"); | |
904 | return(DM_NORMAL); | |
905 | } | |
8defc06b | 906 | if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args, |
9e2516d6 | 907 | Scream, NULL)) != 0) { |
908 | com_err(program_name, stat, " in ChangeFSGroupOrder"); | |
909 | } | |
910 | return(DM_NORMAL); | |
911 | } | |
912 | ||
913 | ||
08345b74 | 914 | /* -------------- Top Level Menu ---------------- */ |
915 | ||
916 | /* Function Name: GetFSAlias | |
917 | * Description: Gets the value for a Filesystem Alias. | |
918 | * Arguments: argc, argv - name of alias in argv[1]. | |
919 | * Returns: DM_NORMAL. | |
920 | * NOTES: There should only be one filesystem per alias, thus | |
921 | * this will work correctly. | |
922 | */ | |
923 | ||
924 | /* ARGSUSED */ | |
925 | int | |
926 | GetFSAlias(argc, argv) | |
927 | int argc; | |
928 | char **argv; | |
929 | { | |
0a2c64cb | 930 | struct qelem *top; |
08345b74 | 931 | |
0a2c64cb | 932 | top = GetFSInfo(ALIAS, argv[1]); |
85ca828a | 933 | Put_message(" "); /* blank line. */ |
0a2c64cb | 934 | Loop(top, (void *) PrintFSAlias); |
08345b74 | 935 | FreeQueue(top); |
936 | return(DM_NORMAL); | |
937 | } | |
938 | ||
939 | /* Function Name: CreateFSAlias | |
6c7a2fcf | 940 | * Description: Create an alias name for a filesystem |
08345b74 | 941 | * Arguments: argc, argv - name of alias in argv[1]. |
942 | * Returns: DM_NORMAL. | |
943 | * NOTES: This requires (name, type, transl) I get {name, translation} | |
944 | * from the user. I provide type, which is well-known. | |
945 | */ | |
946 | ||
947 | /* ARGSUSED */ | |
948 | int | |
949 | CreateFSAlias(argc, argv) | |
950 | int argc; | |
951 | char **argv; | |
952 | { | |
461c03b6 | 953 | register int stat; |
08345b74 | 954 | struct qelem *elem, *top; |
461c03b6 | 955 | char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info; |
08345b74 | 956 | |
957 | elem = NULL; | |
958 | ||
959 | if (!ValidName(argv[1])) | |
960 | return(DM_NORMAL); | |
961 | ||
461c03b6 | 962 | args[ALIAS_NAME] = Strsave(argv[1]); |
963 | args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE); | |
85ca828a | 964 | args[ALIAS_TRANS] = Strsave("*"); |
08345b74 | 965 | |
966 | /* | |
967 | * Check to see if this alias already exists in the database, if so then | |
968 | * print out values, free memory used and then exit. | |
969 | */ | |
970 | ||
8defc06b | 971 | if ( (stat = do_mr_query("get_alias", 3, args, StoreInfo, |
14f99d7d | 972 | (char *)&elem)) == 0) { |
85ca828a | 973 | top = elem = QueueTop(elem); |
08345b74 | 974 | while (elem != NULL) { |
975 | info = (char **) elem->q_data; | |
85ca828a | 976 | sprintf(buf,"The alias: %s currently describes the filesystem %s", |
461c03b6 | 977 | info[ALIAS_NAME], info[ALIAS_TRANS]); |
08345b74 | 978 | Put_message(buf); |
979 | elem = elem->q_forw; | |
980 | } | |
981 | FreeQueue(top); | |
982 | return(DM_NORMAL); | |
983 | } | |
8defc06b | 984 | else if ( stat != MR_NO_MATCH) { |
461c03b6 | 985 | com_err(program_name, stat, " in CreateFSAlias."); |
08345b74 | 986 | return(DM_NORMAL); |
987 | } | |
988 | ||
a1d1f62b | 989 | args[ALIAS_TRANS]= Strsave(""); |
990 | args[ALIAS_END] = NULL; | |
44b10c87 | 991 | if (GetValueFromUser("Which filesystem will this alias point to?", |
992 | &args[ALIAS_TRANS]) == SUB_ERROR) | |
993 | return(DM_NORMAL); | |
08345b74 | 994 | |
8defc06b | 995 | if ( (stat = do_mr_query("add_alias", 3, args, NullFunc, NULL)) != 0) |
461c03b6 | 996 | com_err(program_name, stat, " in CreateFSAlias."); |
08345b74 | 997 | |
461c03b6 | 998 | FreeInfo(args); |
08345b74 | 999 | return (DM_NORMAL); |
1000 | } | |
402461ad | 1001 | |
1002 | /* Function Name: RealDeleteFSAlias | |
1003 | * Description: Does the real deletion work. | |
1004 | * Arguments: info - array of char *'s containing all useful info. | |
1005 | * one_item - a Boolean that is true if only one item | |
1006 | * in queue that dumped us here. | |
1007 | * Returns: none. | |
1008 | */ | |
1009 | ||
1010 | void | |
1011 | RealDeleteFSAlias(info, one_item) | |
1012 | char ** info; | |
1013 | Bool one_item; | |
1014 | { | |
1015 | int stat; | |
1016 | char temp_buf[BUFSIZ]; | |
1017 | ||
1018 | /* | |
1019 | * Deletetions are performed if the user hits 'y' on a list of multiple | |
1020 | * filesystem, or if the user confirms on a unique alias. | |
1021 | */ | |
1022 | sprintf(temp_buf, | |
1023 | "Are you sure that you want to delete the filesystem alias %s", | |
1024 | info[ALIAS_NAME]); | |
1025 | if(!one_item || Confirm(temp_buf)) { | |
8defc06b | 1026 | if ( (stat = do_mr_query("delete_alias", CountArgs(info), |
14f99d7d | 1027 | info, Scream, NULL)) != 0 ) |
402461ad | 1028 | com_err(program_name, stat, " filesystem alias not deleted."); |
1029 | else | |
1030 | Put_message("Filesystem alias deleted."); | |
1031 | } | |
1032 | else | |
1033 | Put_message("Filesystem alias not deleted."); | |
1034 | } | |
08345b74 | 1035 | |
1036 | /* Function Name: DeleteFSAlias | |
6c7a2fcf | 1037 | * Description: Delete an alias name for a filesystem |
08345b74 | 1038 | * Arguments: argc, argv - name of alias in argv[1]. |
1039 | * Returns: DM_NORMAL. | |
1040 | * NOTES: This requires (name, type, transl) I get {name, translation} | |
1041 | * from the user. I provide type, which is well-known. | |
1042 | */ | |
1043 | ||
1044 | /* ARGSUSED */ | |
1045 | int | |
1046 | DeleteFSAlias(argc, argv) | |
1047 | int argc; | |
1048 | char **argv; | |
1049 | { | |
402461ad | 1050 | struct qelem *elem = GetFSInfo(ALIAS, argv[1]); |
1051 | QueryLoop(elem, PrintFSAlias, RealDeleteFSAlias, | |
1052 | "Delete the Filesystem Alias"); | |
1053 | FreeQueue(elem); | |
08345b74 | 1054 | return (DM_NORMAL); |
1055 | } | |
1056 | ||
1057 | /* Function Name: AttachHelp | |
1058 | * Description: Print help info on attachmaint. | |
1059 | * Arguments: none | |
1060 | * Returns: DM_NORMAL. | |
1061 | */ | |
1062 | ||
1063 | int | |
1064 | AttachHelp() | |
1065 | { | |
1066 | static char *message[] = { | |
9e2516d6 | 1067 | "These are the options:", |
1068 | "", | |
1069 | "get - get information about a filesystem.", | |
1070 | "add - add a new filesystem to the data base.", | |
1071 | "update - update the information in the database on a filesystem.", | |
1072 | "delete - delete a filesystem from the database.", | |
1073 | "check - check information about association of a name and a filesys.", | |
1074 | "alias - associate a name with a filesystem.", | |
1075 | "unalias - disassociate a name with a filesystem.", | |
1076 | "verbose - toggle the request for delete confirmation.", | |
08345b74 | 1077 | NULL, |
1078 | }; | |
1079 | ||
1080 | return(PrintHelp(message)); | |
1081 | } | |
9e2516d6 | 1082 | |
1083 | /* Function Name: FSGroupHelp | |
1084 | * Description: Print help info on fsgroups. | |
1085 | * Arguments: none | |
1086 | * Returns: DM_NORMAL. | |
1087 | */ | |
1088 | ||
1089 | int | |
1090 | FSGroupHelp() | |
1091 | { | |
1092 | static char *message[] = { | |
1093 | "A filesystem group is a named sorted list of filesystems.", | |
1094 | "", | |
1095 | "To create, modify, or delete a group itself, use the menu above", | |
1096 | " this one, and manipulate a filesystem of type FSGROUP.", | |
1097 | "Options here are:", | |
1098 | " get - get info about a group and show its members", | |
1099 | " add - add a new member to a group.", | |
1100 | " remove - remove a member from a group.", | |
1101 | " order - change the sorting order of a group.", | |
1102 | NULL | |
1103 | }; | |
1104 | ||
1105 | return(PrintHelp(message)); | |
1106 | } |