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, "Auto Create: %-34s 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 = index(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 strcat(temp_buf, "/other");
364 } else if (depth = -1) {
365 if (isdigit(info[FS_NAME][0])) {
366 strcat(temp_buf, "/");
367 depth = strlen(temp_buf);
368 for (p = info[FS_NAME]; *p && isdigit(*p); p++) {
369 temp_buf[depth++] = *p;
373 strcat(temp_buf, "/other");
377 strcat(temp_buf, "/");
378 strcat(temp_buf, info[FS_NAME]);
381 sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
382 lowercase(info[FS_L_TYPE]), info[FS_NAME]);
384 info[FS_PACK] = strsave(temp_buf);
387 if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
390 if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) ==
393 sprintf(access_type, "fs_access_%s", info[FS_TYPE]);
394 if (GetTypeFromUser("Filesystem's Default Access", access_type,
395 &info[FS_ACCESS]) == SUB_ERROR)
398 if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS])
401 if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) ==
404 if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) ==
408 if (GetYesNoValueFromUser("Automatically create this filesystem",
409 &info[FS_CREATE]) == SUB_ERROR)
411 if (strcasecmp(info[FS_TYPE], "AFS")) {
412 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
413 &info[FS_L_TYPE]) == SUB_ERROR)
417 FreeAndClear(&info[FS_MODTIME], TRUE);
418 FreeAndClear(&info[FS_MODBY], TRUE);
419 FreeAndClear(&info[FS_MODWITH], TRUE);
421 if (name) /* slide the newname into the #2 slot. */
422 SlipInNewName(info, newname);
428 /* --------------- Filesystem Menu ------------- */
430 /* Function Name: GetFS
431 * Description: Get Filesystem information by name.
432 * Arguments: argc, argv - name of filsys in argv[1].
433 * Returns: DM_NORMAL.
444 top = GetFSInfo(LABEL, argv[1]); /* get info. */
445 Loop(top, (void *) PrintFSInfo);
446 FreeQueue(top); /* clean the queue. */
450 /* Function Name: GetFSM
451 * Description: Get Filesystem information by machine.
452 * Arguments: argc, argv - name of server in argv[1].
453 * Returns: DM_NORMAL.
464 argv[1] = canonicalize_hostname(strsave(argv[1]));
465 top = GetFSInfo(MACHINE, argv[1]); /* get info. */
466 Loop(top, (void *) PrintFSInfo);
467 FreeQueue(top); /* clean the queue. */
471 /* Function Name: RealDeleteFS
472 * Description: Does the real deletion work.
473 * Arguments: info - array of char *'s containing all useful info.
474 * one_item - a Boolean that is true if only one item
475 * in queue that dumped us here.
480 RealDeleteFS(info, one_item)
485 char temp_buf[BUFSIZ];
488 * Deletetions are performed if the user hits 'y' on a list of multiple
489 * filesystem, or if the user confirms on a unique alias.
491 sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
493 if(!one_item || Confirm(temp_buf)) {
494 if ( (stat = do_mr_query("delete_filesys", 1,
495 &info[FS_NAME], Scream, NULL)) != 0)
496 com_err(program_name, stat, " filesystem not deleted.");
498 Put_message("Filesystem deleted.");
501 Put_message("Filesystem not deleted.");
504 /* Function Name: DeleteFS
505 * Description: Delete a filesystem give its name.
506 * Arguments: argc, argv - argv[1] is the name of the filesystem.
517 struct qelem *elem = GetFSInfo(LABEL, argv[1]);
518 QueryLoop(elem, PrintFSInfo, RealDeleteFS, "Delete the Filesystem");
524 /* Function Name: RealChangeFS
525 * Description: performs the actual change to the filesys.
526 * Arguments: info - the information
527 * junk - an unused boolean.
533 RealChangeFS(info, junk)
539 extern Menu nfsphys_menu;
541 args = AskFSInfo(info, TRUE);
543 Put_message("Aborted.");
546 stat = do_mr_query("update_filesys", CountArgs(args), args,
550 Put_message("That NFS filesystem is not exported.");
551 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) {
552 Do_menu(&nfsphys_menu, 0, NULL);
553 if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE)
555 if (stat = do_mr_query("update_filesys", CountArgs(args), args,
557 com_err(program_name, stat, " filesystem not updated");
559 Put_message("filesystem sucessfully updated.");
566 com_err(program_name, stat, " in UpdateFS");
570 /* Function Name: ChangeFS
571 * Description: change the information in a filesys record.
572 * Arguments: arc, argv - value of filsys in argv[1].
573 * Returns: DM_NORMAL.
582 struct qelem *elem = GetFSInfo(LABEL, argv[1]);
583 QueryLoop(elem, NullPrint, RealChangeFS, "Update the Filesystem");
589 /* Function Name: AddFS
590 * Description: change the information in a filesys record.
591 * Arguments: arc, argv - name of filsys in argv[1].
592 * Returns: DM_NORMAL.
601 char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ];
603 extern Menu nfsphys_menu;
605 if ( !ValidName(argv[1]) )
608 if ( (stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
609 NullFunc, NULL)) == 0) {
610 Put_message ("A Filesystem by that name already exists.");
612 } else if (stat != MR_NO_MATCH) {
613 com_err(program_name, stat, " in AddFS");
617 if ((args = AskFSInfo(SetDefaults(info, argv[1]), FALSE )) == NULL) {
618 Put_message("Aborted.");
622 stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
625 Put_message("That NFS filesystem is not exported.");
626 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE) {
627 Do_menu(&nfsphys_menu, 0, NULL);
628 if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
630 if (stat = do_mr_query("add_filesys", CountArgs(args), args,
632 com_err(program_name, stat, " in AddFS");
634 Put_message("Created.");
641 com_err(program_name, stat, " in AddFS");
644 if (stat == MR_SUCCESS && !strcasecmp(info[FS_L_TYPE], "HOMEDIR")) {
645 static char *val[] = {"def_quota", NULL};
646 static char *def_quota = NULL;
647 char *argv[Q_QUOTA + 1];
648 struct qelem *top = NULL;
650 if (def_quota == NULL) {
651 stat = do_mr_query("get_value", CountArgs(val), val,
652 StoreInfo, (char *) &top);
653 if (stat != MR_SUCCESS) {
654 com_err(program_name, stat, " getting default quota");
657 def_quota = Strsave(((char **)top->q_data)[0]);
661 if (def_quota != NULL) {
662 sprintf(buf, "Give user %s a quota of %s on filesys %s (Y/N)",
663 info[FS_NAME], def_quota, info[FS_NAME]);
664 if (YesNoQuestion(buf, 1) == TRUE) {
665 argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME];
666 argv[Q_TYPE] = "USER";
667 argv[Q_QUOTA] = def_quota;
668 if ((stat = do_mr_query("add_quota", Q_QUOTA+1, argv, Scream,
669 (char *) NULL)) != MR_SUCCESS) {
670 com_err(program_name, stat, " while adding quota");
680 /* Function Name: SortAfter
681 * Description: choose a sortkey to cause an item to be added after
682 * the count element in the queue
683 * Arguments: queue of filesys names & sortkeys, queue count pointer
684 * Returns: sort key to use.
689 SortAfter(elem, count)
693 char *prev, *next, prevnext, *key, keybuf[9];
695 /* first find the two keys we need to insert between */
697 for (; count > 0; count--) {
698 prev = ((char **)elem->q_data)[1];
707 next = ((char **)elem->q_data)[1];
709 /* now copy the matching characters */
710 for (key = keybuf; *prev && *prev == *next; next++) {
714 /* and set the last character */
716 *prev = prevnext = 'A';
723 if (*next - *prev > 1) {
724 *key++ = (*next + *prev)/2;
727 *key++ = (prevnext + 'Z')/2;
730 return(Strsave(keybuf));
733 /* Function Name: AddFSToGroup
734 * Description: add a filesystem to an FS group
735 * Arguments: arc, argv - name of group in argv[1], filesys in argv[2].
736 * Returns: DM_NORMAL.
741 AddFSToGroup(argc, argv)
746 struct qelem *elem = NULL;
747 char buf[BUFSIZ], *args[5], *bufp;
749 if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo,
750 (char *)&elem)) != 0) {
751 if (stat != MR_NO_MATCH)
752 com_err(program_name, stat, " in AddFSToGroup");
758 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
760 com_err(program_name, stat, " in AddFSToGroup");
763 elem = QueueTop(elem);
765 Loop(elem, (void *) PrintFSGMembers);
766 sprintf(buf, "%d", QueueCount(elem));
768 if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR)
772 args[2] = SortAfter(elem, count);
774 FreeQueue(QueueTop(elem));
777 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
778 if (stat == MR_EXISTS) {
779 Put_message("That filesystem is already a member of the group.");
780 Put_message("Use the order command if you want to change the sorting order.");
782 com_err(program_name, stat, " in AddFSToGroup");
787 /* Function Name: RemoveFSFromGroup
788 * Description: delete a filesystem from an FS group
789 * Arguments: arc, argv - name of group in argv[1].
790 * Returns: DM_NORMAL.
795 RemoveFSFromGroup(argc, argv)
802 sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]);
805 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv+1,
806 Scream, NULL)) != 0) {
807 com_err(program_name, stat, ", not removed.");
812 /* Function Name: ChangeFSGroupOrder
813 * Description: change the sortkey on a filesys in an FSgroup
814 * Arguments: arc, argv - name of group in argv[1].
815 * Returns: DM_NORMAL.
820 ChangeFSGroupOrder(argc, argv)
824 int stat, src, dst, i;
825 struct qelem *elem = NULL, *top, *tmpelem;
826 char buf[BUFSIZ], *bufp, *args[3];
828 if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo,
829 (char *)&elem)) != 0) {
830 if (stat == MR_NO_MATCH) {
832 "Ether %s is not a filesystem group or it has no members",
836 com_err(program_name, stat, " in ChangeFSGroupOrder");
839 top = QueueTop(elem);
841 Loop(top, (void *) PrintFSGMembers);
844 if (GetValueFromUser("Enter number of the filesystem to move:",
850 Put_message("You must enter a positive number (or 0 to abort).");
852 } else if (src == 0) {
853 Put_message("Aborted.");
856 for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw);
858 Put_message("You entered a number that is too high");
865 if (GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp) == SUB_ERROR)
869 if (src == dst || src == dst + 1) {
870 Put_message("That has no effect on the sorting order!");
874 Put_message("You must enter a non-negative number.");
877 for (tmpelem = top, i = dst;
878 i-- > 1 && tmpelem->q_forw;
879 tmpelem = tmpelem->q_forw);
881 Put_message("You entered a number that is too high");
886 args[2] = SortAfter(top, dst);
888 args[1] = ((char **)elem->q_data)[0];
889 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
890 Scream, NULL)) != 0) {
891 com_err(program_name, stat, " in ChangeFSGroupOrder");
894 if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
895 Scream, NULL)) != 0) {
896 com_err(program_name, stat, " in ChangeFSGroupOrder");
902 /* -------------- Top Level Menu ---------------- */
904 /* Function Name: GetFSAlias
905 * Description: Gets the value for a Filesystem Alias.
906 * Arguments: argc, argv - name of alias in argv[1].
907 * Returns: DM_NORMAL.
908 * NOTES: There should only be one filesystem per alias, thus
909 * this will work correctly.
914 GetFSAlias(argc, argv)
920 top = GetFSInfo(ALIAS, argv[1]);
921 Put_message(" "); /* blank line. */
922 Loop(top, (void *) PrintFSAlias);
927 /* Function Name: CreateFSAlias
928 * Description: Create an alias name for a filesystem
929 * Arguments: argc, argv - name of alias in argv[1].
930 * Returns: DM_NORMAL.
931 * NOTES: This requires (name, type, transl) I get {name, translation}
932 * from the user. I provide type, which is well-known.
937 CreateFSAlias(argc, argv)
942 struct qelem *elem, *top;
943 char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
947 if (!ValidName(argv[1]))
950 args[ALIAS_NAME] = Strsave(argv[1]);
951 args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
952 args[ALIAS_TRANS] = Strsave("*");
955 * Check to see if this alias already exists in the database, if so then
956 * print out values, free memory used and then exit.
959 if ( (stat = do_mr_query("get_alias", 3, args, StoreInfo,
960 (char *)&elem)) == 0) {
961 top = elem = QueueTop(elem);
962 while (elem != NULL) {
963 info = (char **) elem->q_data;
964 sprintf(buf,"The alias: %s currently describes the filesystem %s",
965 info[ALIAS_NAME], info[ALIAS_TRANS]);
972 else if ( stat != MR_NO_MATCH) {
973 com_err(program_name, stat, " in CreateFSAlias.");
977 args[ALIAS_TRANS]= Strsave("");
978 args[ALIAS_END] = NULL;
979 if (GetValueFromUser("Which filesystem will this alias point to?",
980 &args[ALIAS_TRANS]) == SUB_ERROR)
983 if ( (stat = do_mr_query("add_alias", 3, args, NullFunc, NULL)) != 0)
984 com_err(program_name, stat, " in CreateFSAlias.");
990 /* Function Name: RealDeleteFSAlias
991 * Description: Does the real deletion work.
992 * Arguments: info - array of char *'s containing all useful info.
993 * one_item - a Boolean that is true if only one item
994 * in queue that dumped us here.
999 RealDeleteFSAlias(info, one_item)
1004 char temp_buf[BUFSIZ];
1007 * Deletetions are performed if the user hits 'y' on a list of multiple
1008 * filesystem, or if the user confirms on a unique alias.
1011 "Are you sure that you want to delete the filesystem alias %s",
1013 if(!one_item || Confirm(temp_buf)) {
1014 if ( (stat = do_mr_query("delete_alias", CountArgs(info),
1015 info, Scream, NULL)) != 0 )
1016 com_err(program_name, stat, " filesystem alias not deleted.");
1018 Put_message("Filesystem alias deleted.");
1021 Put_message("Filesystem alias not deleted.");
1024 /* Function Name: DeleteFSAlias
1025 * Description: Delete an alias name for a filesystem
1026 * Arguments: argc, argv - name of alias in argv[1].
1027 * Returns: DM_NORMAL.
1028 * NOTES: This requires (name, type, transl) I get {name, translation}
1029 * from the user. I provide type, which is well-known.
1034 DeleteFSAlias(argc, argv)
1038 struct qelem *elem = GetFSInfo(ALIAS, argv[1]);
1039 QueryLoop(elem, PrintFSAlias, RealDeleteFSAlias,
1040 "Delete the Filesystem Alias");
1045 /* Function Name: AttachHelp
1046 * Description: Print help info on attachmaint.
1048 * Returns: DM_NORMAL.
1054 static char *message[] = {
1055 "These are the options:",
1057 "get - get information about a filesystem.",
1058 "add - add a new filesystem to the data base.",
1059 "update - update the information in the database on a filesystem.",
1060 "delete - delete a filesystem from the database.",
1061 "check - check information about association of a name and a filesys.",
1062 "alias - associate a name with a filesystem.",
1063 "unalias - disassociate a name with a filesystem.",
1064 "verbose - toggle the request for delete confirmation.",
1068 return(PrintHelp(message));
1071 /* Function Name: FSGroupHelp
1072 * Description: Print help info on fsgroups.
1074 * Returns: DM_NORMAL.
1080 static char *message[] = {
1081 "A filesystem group is a named sorted list of filesystems.",
1083 "To create, modify, or delete a group itself, use the menu above",
1084 " this one, and manipulate a filesystem of type FSGROUP.",
1085 "Options here are:",
1086 " get - get info about a group and show its members",
1087 " add - add a new member to a group.",
1088 " remove - remove a member from a group.",
1089 " order - change the sorting order of a group.",
1093 return(PrintHelp(message));