1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
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.
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.
12 * By: Chris D. Peterson
18 * Copyright 1988 by the Massachusetts Institute of Technology.
20 * For further information on copyright and distribution
21 * see the file mit-copyright.h
27 #include <moira_site.h>
29 #include <sys/types.h>
33 #include "mit-copyright.h"
38 #define FS_ALIAS_TYPE "FILESYS"
45 #define NO_MACHINE ("\\[NONE\\]") /* C will remove one of the /'s here,
46 * and the other quotes the [ for
47 * ingres' regexp facility. */
48 #define NO_MACHINE_BAD ("[NONE]")
50 #define DEFAULT_TYPE ("NFS")
51 #define DEFAULT_MACHINE DEFAULT_NONE
52 #define DEFAULT_PACK DEFAULT_NONE
53 #define DEFAULT_ACCESS ("w")
54 #define DEFAULT_COMMENTS DEFAULT_COMMENT
55 #define DEFAULT_OWNER (user)
56 #define DEFAULT_OWNERS (user)
57 #define DEFAULT_CREATE DEFAULT_YES
58 #define DEFAULT_L_TYPE ("PROJECT")
59 #define DEFAULT_CELL ("athena.mit.edu")
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).
68 SetDefaults(info, name)
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);
78 sprintf(buf, "/mit/%s", name);
79 info[FS_M_POINT] = Strsave(buf);
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;
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.
103 struct qelem * elem = NULL;
108 if ( (stat = do_mr_query("get_filesys_by_label", 1, &name,
109 StoreInfo, (char *)&elem)) != 0) {
110 com_err(program_name, stat, " in GetFSInfo");
115 if ( (stat = do_mr_query("get_filesys_by_machine", 1, &name,
116 StoreInfo, (char *)&elem)) != 0) {
117 com_err(program_name, stat, " in GetFSInfo");
122 if ( (stat = do_mr_query("get_filesys_by_group", 1, &name,
123 StoreInfo, (char *)&elem)) != 0) {
124 com_err(program_name, stat, " in GetFSInfo");
129 args[ALIAS_NAME] = name;
130 args[ALIAS_TYPE] = FS_ALIAS_TYPE;
131 args[ALIAS_TRANS] = "*";
132 if ( (stat = do_mr_query("get_alias", 3, args, StoreInfo,
133 (char *) &elem)) != 0) {
134 com_err(program_name, stat, " in get_alias.");
139 return(QueueTop(elem));
142 /* Function Name: PrintFSAlias
143 * Description: Prints a filesystem alias
144 * Arguments: info - an array contains the strings of info.
145 * Returns: the name of the filesys - used be QueryLoop().
154 sprintf(buf,"Alias: %-25s Filesystem: %s",info[ALIAS_NAME],
157 return(info[ALIAS_NAME]);
160 static int fsgCount = 1;
163 PrintFSGMembers(info)
166 char print_buf[BUFSIZ];
168 sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)", fsgCount++, info[0], info[1]);
169 Put_message(print_buf);
174 /* Function Name: PrintFSInfo
175 * Description: Prints the filesystem information.
176 * Arguments: info - a pointer to the filesystem information.
184 char print_buf[BUFSIZ];
188 if (!strcmp(info[FS_TYPE], "FSGROUP") || !strcmp(info[FS_TYPE], "MUL")) {
190 struct qelem *elem = NULL;
192 if (!strcmp(info[FS_TYPE], "MUL"))
193 sprintf(print_buf,"%20s Multiple Filesystem: %s", " ", info[FS_NAME]);
195 sprintf(print_buf,"%20s Filesystem Group: %s", " ", info[FS_NAME]);
196 Put_message(print_buf);
198 sprintf(print_buf,"Comments: %s",info[FS_COMMENTS]);
199 Put_message(print_buf);
200 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
202 Put_message(print_buf);
203 Put_message("Containing the filesystems (in order):");
204 if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
205 StoreInfo, (char *)&elem)) != 0) {
206 if (stat == MR_NO_MATCH)
207 Put_message(" [no members]");
209 com_err(program_name, stat, " in PrintFSInfo");
212 Loop(QueueTop(elem), (void *) PrintFSGMembers);
216 sprintf(print_buf,"%20s Filesystem: %s", " ", info[FS_NAME]);
217 Put_message(print_buf);
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);
224 sprintf(print_buf,"Comments: %s",info[FS_COMMENTS]);
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);
229 sprintf(print_buf, "Update Fileserver: %-27s Locker Type: %s",
230 atoi(info[FS_CREATE]) ? "ON" : "OFF",
232 Put_message(print_buf);
233 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
235 Put_message(print_buf);
237 return(info[FS_NAME]);
241 char *canonicalize_cell(c)
248 sprintf(path, "/afs/%s", c);
249 if (lstat(path, &stbuf) || !stbuf.st_mode&S_IFLNK)
251 count = readlink(path, path, sizeof(path));
252 if (count < 1) return(c);
255 return(strsave(path));
259 int GetAliasValue(argc, argv, retval)
264 *retval = strsave(argv[2]);
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
273 * name - add a newname field? (T/F)
278 AskFSInfo(info, name)
282 char temp_buf[BUFSIZ], *newname, access_type[32];
283 int fsgroup = 0, newdefaults = 0;
286 sprintf(temp_buf, "Changing Attributes of filesystem %s.",
288 Put_message(temp_buf);
292 newname = Strsave(info[FS_NAME]);
293 if (GetValueFromUser("The new name for this filesystem",
294 &newname) == SUB_ERROR)
298 strcpy(temp_buf, info[FS_TYPE]);
299 if (GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]) ==
302 if (!strcasecmp(info[FS_TYPE], "FSGROUP") ||
303 !strcasecmp(info[FS_TYPE], "MUL"))
305 if (strcasecmp(info[FS_TYPE], temp_buf))
308 free(info[FS_MACHINE]);
309 info[FS_MACHINE] = Strsave(NO_MACHINE);
311 if (!strcmp(info[FS_MACHINE], NO_MACHINE_BAD)) {
312 free(info[FS_MACHINE]);
313 info[FS_MACHINE] = Strsave(NO_MACHINE);
315 if (!strcasecmp(info[FS_TYPE], "AFS")) {
316 if (!name || newdefaults) {
317 free(info[FS_MACHINE]);
318 info[FS_MACHINE] = strsave(DEFAULT_CELL);
320 if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
323 info[FS_MACHINE] = canonicalize_cell(info[FS_MACHINE]);
325 if (GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]) ==
328 info[FS_MACHINE] = canonicalize_hostname(info[FS_MACHINE]);
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)
338 if (!name || newdefaults) {
340 lowercase(info[FS_MACHINE]);
341 sprintf(temp_buf, "%s:%s", info[FS_MACHINE], info[FS_L_TYPE]);
346 status = do_mr_query("get_alias", 3, args,
347 GetAliasValue, &path);
348 if (status == MR_SUCCESS) {
349 p = strchr(path, ':');
355 sprintf(temp_buf, "/afs/%s/%s", info[FS_MACHINE], path);
357 for (p=info[FS_NAME]; *p&&(p-info[FS_NAME])<depth; p++) {
359 strcat(temp_buf, "/x");
360 temp_buf[strlen(temp_buf)-1] = *p;
362 sprintf(temp_buf, "/afs/%s/%s/other", info[FS_MACHINE], path);
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;
375 strcat(temp_buf, "/other");
379 strcat(temp_buf, "/");
380 strcat(temp_buf, info[FS_NAME]);
383 sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
384 lowercase(info[FS_L_TYPE]), info[FS_NAME]);
386 info[FS_PACK] = strsave(temp_buf);
389 if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
392 if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) ==
395 sprintf(access_type, "fs_access_%s", info[FS_TYPE]);
396 if (GetTypeFromUser("Filesystem's Default Access", access_type,
397 &info[FS_ACCESS]) == SUB_ERROR)
400 if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS])
403 if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) ==
406 if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) ==
410 if (GetYesNoValueFromUser("Propagate changes to fileserver",
411 &info[FS_CREATE]) == SUB_ERROR)
413 if (strcasecmp(info[FS_TYPE], "AFS")) {
414 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
415 &info[FS_L_TYPE]) == SUB_ERROR)
419 FreeAndClear(&info[FS_MODTIME], TRUE);
420 FreeAndClear(&info[FS_MODBY], TRUE);
421 FreeAndClear(&info[FS_MODWITH], TRUE);
423 if (name) /* slide the newname into the #2 slot. */
424 SlipInNewName(info, newname);
430 /* --------------- Filesystem Menu ------------- */
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.
446 top = GetFSInfo(LABEL, argv[1]); /* get info. */
447 Loop(top, (void *) PrintFSInfo);
448 FreeQueue(top); /* clean the queue. */
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.
466 argv[1] = canonicalize_hostname(strsave(argv[1]));
467 top = GetFSInfo(MACHINE, argv[1]); /* get info. */
468 Loop(top, (void *) PrintFSInfo);
469 FreeQueue(top); /* clean the queue. */
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.
482 RealDeleteFS(info, one_item)
487 char temp_buf[BUFSIZ];
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.
493 sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
495 if(!one_item || Confirm(temp_buf)) {
496 if ( (stat = do_mr_query("delete_filesys", 1,
497 &info[FS_NAME], Scream, NULL)) != 0)
498 com_err(program_name, stat, " filesystem not deleted.");
500 Put_message("Filesystem deleted.");
503 Put_message("Filesystem not deleted.");
506 /* Function Name: DeleteFS
507 * Description: Delete a filesystem give its name.
508 * Arguments: argc, argv - argv[1] is the name of the filesystem.
519 struct qelem *elem = GetFSInfo(LABEL, argv[1]);
520 QueryLoop(elem, PrintFSInfo, RealDeleteFS, "Delete the Filesystem");
526 /* Function Name: RealChangeFS
527 * Description: performs the actual change to the filesys.
528 * Arguments: info - the information
529 * junk - an unused boolean.
535 RealChangeFS(info, junk)
541 extern Menu nfsphys_menu;
543 args = AskFSInfo(info, TRUE);
545 Put_message("Aborted.");
548 stat = do_mr_query("update_filesys", CountArgs(args), args,
552 Put_message("That NFS filesystem is not exported.");
553 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) {
554 Do_menu(&nfsphys_menu, 0, NULL);
555 if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE)
557 if (stat = do_mr_query("update_filesys", CountArgs(args), args,
559 com_err(program_name, stat, " filesystem not updated");
561 Put_message("filesystem sucessfully updated.");
568 com_err(program_name, stat, " in UpdateFS");
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.
584 struct qelem *elem = GetFSInfo(LABEL, argv[1]);
585 QueryLoop(elem, NullPrint, RealChangeFS, "Update the Filesystem");
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.
603 char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ];
605 extern Menu nfsphys_menu;
607 if ( !ValidName(argv[1]) )
610 if ( (stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
611 NullFunc, NULL)) == 0) {
612 Put_message ("A Filesystem by that name already exists.");
614 } else if (stat != MR_NO_MATCH) {
615 com_err(program_name, stat, " in AddFS");
619 if ((args = AskFSInfo(SetDefaults(info, argv[1]), FALSE )) == NULL) {
620 Put_message("Aborted.");
624 stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
627 Put_message("That NFS filesystem is not exported.");
628 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) {
629 Do_menu(&nfsphys_menu, 0, NULL);
630 if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
632 if (stat = do_mr_query("add_filesys", CountArgs(args), args,
634 com_err(program_name, stat, " in AddFS");
636 Put_message("Created.");
643 com_err(program_name, stat, " in AddFS");
646 if (stat == MR_SUCCESS && !strcasecmp(info[FS_L_TYPE], "HOMEDIR")) {
647 static char *val[] = {"def_quota", NULL};
648 static char *def_quota = NULL;
649 char *argv[Q_QUOTA + 1];
650 struct qelem *top = NULL;
652 if (def_quota == NULL) {
653 stat = do_mr_query("get_value", CountArgs(val), val,
654 StoreInfo, (char *) &top);
655 if (stat != MR_SUCCESS) {
656 com_err(program_name, stat, " getting default quota");
659 def_quota = Strsave(((char **)top->q_data)[0]);
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]);
666 if (YesNoQuestion(buf, 1) == TRUE) {
667 argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME];
668 if (!strcmp(info[FS_TYPE], "NFS"))
669 argv[Q_TYPE] = "USER";
671 argv[Q_TYPE] = "ANY";
672 argv[Q_QUOTA] = def_quota;
673 if ((stat = do_mr_query("add_quota", Q_QUOTA+1, argv, Scream,
674 (char *) NULL)) != MR_SUCCESS) {
675 com_err(program_name, stat, " while adding quota");
679 } else if (stat == MR_SUCCESS) {
680 if (YesNoQuestion("Assign a quota on this filesystem (Y/N)", 1)
683 parsed_argv[0] = info[FS_NAME];
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.
701 SortAfter(elem, count)
705 char *prev, *next, prevnext, *key, keybuf[9];
707 /* first find the two keys we need to insert between */
709 for (; count > 0; count--) {
710 prev = ((char **)elem->q_data)[1];
719 next = ((char **)elem->q_data)[1];
721 /* now copy the matching characters */
722 for (key = keybuf; *prev && *prev == *next; next++) {
726 /* and set the last character */
728 *prev = prevnext = 'A';
735 if (*next - *prev > 1) {
736 *key++ = (*next + *prev)/2;
739 *key++ = (prevnext + 'Z')/2;
742 return(Strsave(keybuf));
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.
753 AddFSToGroup(argc, argv)
758 struct qelem *elem = NULL;
759 char buf[BUFSIZ], *args[5], *bufp;
761 if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo,
762 (char *)&elem)) != 0) {
763 if (stat != MR_NO_MATCH)
764 com_err(program_name, stat, " in AddFSToGroup");
770 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
772 com_err(program_name, stat, " in AddFSToGroup");
775 elem = QueueTop(elem);
777 Loop(elem, (void *) PrintFSGMembers);
778 sprintf(buf, "%d", QueueCount(elem));
780 if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR)
784 args[2] = SortAfter(elem, count);
786 FreeQueue(QueueTop(elem));
789 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
790 if (stat == MR_EXISTS) {
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.");
794 com_err(program_name, stat, " in AddFSToGroup");
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.
807 RemoveFSFromGroup(argc, argv)
814 sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]);
817 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv+1,
818 Scream, NULL)) != 0) {
819 com_err(program_name, stat, ", not removed.");
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.
832 ChangeFSGroupOrder(argc, argv)
836 int stat, src, dst, i;
837 struct qelem *elem = NULL, *top, *tmpelem;
838 char buf[BUFSIZ], *bufp, *args[3];
840 if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo,
841 (char *)&elem)) != 0) {
842 if (stat == MR_NO_MATCH) {
844 "Ether %s is not a filesystem group or it has no members",
848 com_err(program_name, stat, " in ChangeFSGroupOrder");
851 top = QueueTop(elem);
853 Loop(top, (void *) PrintFSGMembers);
856 if (GetValueFromUser("Enter number of the filesystem to move:",
862 Put_message("You must enter a positive number (or 0 to abort).");
864 } else if (src == 0) {
865 Put_message("Aborted.");
868 for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw);
870 Put_message("You entered a number that is too high");
877 if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR)
881 if (src == dst || src == dst + 1) {
882 Put_message("That has no effect on the sorting order!");
886 Put_message("You must enter a non-negative number.");
889 for (tmpelem = top, i = dst;
890 i-- > 1 && tmpelem->q_forw;
891 tmpelem = tmpelem->q_forw);
893 Put_message("You entered a number that is too high");
898 args[2] = SortAfter(top, dst);
900 args[1] = ((char **)elem->q_data)[0];
901 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
902 Scream, NULL)) != 0) {
903 com_err(program_name, stat, " in ChangeFSGroupOrder");
906 if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
907 Scream, NULL)) != 0) {
908 com_err(program_name, stat, " in ChangeFSGroupOrder");
914 /* -------------- Top Level Menu ---------------- */
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.
926 GetFSAlias(argc, argv)
932 top = GetFSInfo(ALIAS, argv[1]);
933 Put_message(" "); /* blank line. */
934 Loop(top, (void *) PrintFSAlias);
939 /* Function Name: CreateFSAlias
940 * Description: Create an alias name for a filesystem
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.
949 CreateFSAlias(argc, argv)
954 struct qelem *elem, *top;
955 char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
959 if (!ValidName(argv[1]))
962 args[ALIAS_NAME] = Strsave(argv[1]);
963 args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
964 args[ALIAS_TRANS] = Strsave("*");
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.
971 if ( (stat = do_mr_query("get_alias", 3, args, StoreInfo,
972 (char *)&elem)) == 0) {
973 top = elem = QueueTop(elem);
974 while (elem != NULL) {
975 info = (char **) elem->q_data;
976 sprintf(buf,"The alias: %s currently describes the filesystem %s",
977 info[ALIAS_NAME], info[ALIAS_TRANS]);
984 else if ( stat != MR_NO_MATCH) {
985 com_err(program_name, stat, " in CreateFSAlias.");
989 args[ALIAS_TRANS]= Strsave("");
990 args[ALIAS_END] = NULL;
991 if (GetValueFromUser("Which filesystem will this alias point to?",
992 &args[ALIAS_TRANS]) == SUB_ERROR)
995 if ( (stat = do_mr_query("add_alias", 3, args, NullFunc, NULL)) != 0)
996 com_err(program_name, stat, " in CreateFSAlias.");
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.
1011 RealDeleteFSAlias(info, one_item)
1016 char temp_buf[BUFSIZ];
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.
1023 "Are you sure that you want to delete the filesystem alias %s",
1025 if(!one_item || Confirm(temp_buf)) {
1026 if ( (stat = do_mr_query("delete_alias", CountArgs(info),
1027 info, Scream, NULL)) != 0 )
1028 com_err(program_name, stat, " filesystem alias not deleted.");
1030 Put_message("Filesystem alias deleted.");
1033 Put_message("Filesystem alias not deleted.");
1036 /* Function Name: DeleteFSAlias
1037 * Description: Delete an alias name for a filesystem
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.
1046 DeleteFSAlias(argc, argv)
1050 struct qelem *elem = GetFSInfo(ALIAS, argv[1]);
1051 QueryLoop(elem, PrintFSAlias, RealDeleteFSAlias,
1052 "Delete the Filesystem Alias");
1057 /* Function Name: AttachHelp
1058 * Description: Print help info on attachmaint.
1060 * Returns: DM_NORMAL.
1066 static char *message[] = {
1067 "These are the options:",
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.",
1080 return(PrintHelp(message));
1083 /* Function Name: FSGroupHelp
1084 * Description: Print help info on fsgroups.
1086 * Returns: DM_NORMAL.
1092 static char *message[] = {
1093 "A filesystem group is a named sorted list of filesystems.",
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.",
1105 return(PrintHelp(message));