3 * This is the file attach.c for the Moira Client, which allows users
4 * to quickly and easily maintain most parts of the Moira database.
5 * It Contains: Functions for maintaining data used by Hesiod
6 * to map courses/projects/users to their file systems,
7 * and maintain filesys info.
10 * By: Chris D. Peterson
12 * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
13 * For copying and distribution information, please see the file
17 #include <mit-copyright.h>
19 #include <moira_site.h>
35 char *canonicalize_cell(char *c);
36 int GetAliasValue(int argc, char **argv, void *retval);
37 void RealDeleteFS(char **info, Bool one_item);
38 char *SortAfter(struct mqelem *elem, int count);
39 void RealDeleteFSAlias(char **info, Bool one_item);
41 #define FS_ALIAS_TYPE "FILESYS"
48 #define NO_MACHINE ("[NONE]")
50 #define DEFAULT_TYPE ("AFS")
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).
67 static char **SetDefaults(char **info, char *name)
71 info[FS_NAME] = strdup(name);
72 info[FS_TYPE] = strdup(DEFAULT_TYPE);
73 info[FS_MACHINE] = strdup(DEFAULT_MACHINE);
74 info[FS_PACK] = strdup(DEFAULT_PACK);
75 sprintf(buf, "/mit/%s", name);
76 info[FS_M_POINT] = strdup(buf);
77 info[FS_ACCESS] = strdup(DEFAULT_ACCESS);
78 info[FS_COMMENTS] = strdup(DEFAULT_COMMENTS);
79 info[FS_OWNER] = strdup(DEFAULT_OWNER);
80 info[FS_OWNERS] = strdup(DEFAULT_OWNERS);
81 info[FS_CREATE] = strdup(DEFAULT_CREATE);
82 info[FS_L_TYPE] = strdup(DEFAULT_L_TYPE);
83 info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL;
87 /* Function Name: GetFSInfo
88 * Description: Stores the info in a queue.
89 * Arguments: type - type of information to get.
90 * name - name of the item to get information on.
91 * Returns: a pointer to the first element in the queue.
94 static struct mqelem *GetFSInfo(int type, char *name)
97 struct mqelem *elem = NULL;
103 if ((stat = do_mr_query("get_filesys_by_label", 1, &name,
106 com_err(program_name, stat, " in GetFSInfo");
111 if ((stat = do_mr_query("get_filesys_by_machine", 1, &name,
114 com_err(program_name, stat, " in GetFSInfo");
119 if ((stat = do_mr_query("get_filesys_by_group", 1, &name,
122 com_err(program_name, stat, " in GetFSInfo");
127 args[ALIAS_NAME] = name;
128 args[ALIAS_TYPE] = FS_ALIAS_TYPE;
129 args[ALIAS_TRANS] = "*";
130 if ((stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
132 com_err(program_name, stat, " in get_alias.");
137 return QueueTop(elem);
140 /* Function Name: PrintFSAlias
141 * Description: Prints a filesystem alias
142 * Arguments: info - an array contains the strings of info.
143 * Returns: the name of the filesys - used be QueryLoop().
146 static char *PrintFSAlias(char **info)
150 sprintf(buf, "Alias: %-25s Filesystem: %s", info[ALIAS_NAME],
153 return info[ALIAS_NAME];
156 static int fsgCount = 1;
158 static void PrintFSGMembers(char **info)
160 char print_buf[BUFSIZ];
162 sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)",
163 fsgCount++, info[0], info[1]);
164 Put_message(print_buf);
168 /* Function Name: PrintFSInfo
169 * Description: Prints the filesystem information.
170 * Arguments: info - a pointer to the filesystem information.
174 static char *PrintFSInfo(char **info)
176 char print_buf[BUFSIZ];
180 if (!strcmp(info[FS_TYPE], "FSGROUP") || !strcmp(info[FS_TYPE], "MUL"))
183 struct mqelem *elem = NULL;
185 if (!strcmp(info[FS_TYPE], "MUL"))
186 sprintf(print_buf, "%20s Multiple Filesystem: %s", " ", info[FS_NAME]);
188 sprintf(print_buf, "%20s Filesystem Group: %s", " ", info[FS_NAME]);
189 Put_message(print_buf);
191 sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
192 Put_message(print_buf);
193 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
195 Put_message(print_buf);
196 Put_message("Containing the filesystems (in order):");
197 if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
200 if (stat == MR_NO_MATCH)
201 Put_message(" [no members]");
203 com_err(program_name, stat, " in PrintFSInfo");
208 Loop(QueueTop(elem), PrintFSGMembers);
214 sprintf(print_buf, "%20s Filesystem: %s", " ", info[FS_NAME]);
215 Put_message(print_buf);
216 sprintf(print_buf, "Type: %-40s Machine: %-15s",
217 info[FS_TYPE], info[FS_MACHINE]);
218 Put_message(print_buf);
219 sprintf(print_buf, "Default Access: %-2s Packname: %-17s Mountpoint %s ",
220 info[FS_ACCESS], info[FS_PACK], info[FS_M_POINT]);
221 Put_message(print_buf);
222 sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
223 Put_message(print_buf);
224 sprintf(print_buf, "User Ownership: %-30s Group Ownership: %s",
225 info[FS_OWNER], info[FS_OWNERS]);
226 Put_message(print_buf);
227 sprintf(print_buf, "Update Fileserver: %-27s Locker Type: %s",
228 atoi(info[FS_CREATE]) ? "ON" : "OFF", info[FS_L_TYPE]);
229 Put_message(print_buf);
230 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
232 Put_message(print_buf);
234 return info[FS_NAME];
238 char *canonicalize_cell(char *c)
244 sprintf(path, "/afs/%s", c);
245 if (lstat(path, &stbuf) || !stbuf.st_mode & S_IFLNK)
247 count = readlink(path, path, sizeof(path));
256 int GetAliasValue(int argc, char **argv, void *retval)
258 *(char **)retval = strdup(argv[2]);
262 /* Function Name: AskFSInfo.
263 * Description: This function askes the user for information about a
264 * machine and saves it into a structure.
265 * Arguments: info - a pointer the the structure to put the
267 * name - add a newname field? (T/F)
271 static char **AskFSInfo(char **info, Bool name)
273 char temp_buf[BUFSIZ], *newname, access_type[32];
274 int fsgroup = 0, newdefaults = 0;
277 sprintf(temp_buf, "Changing Attributes of filesystem %s.", info[FS_NAME]);
278 Put_message(temp_buf);
283 newname = strdup(info[FS_NAME]);
284 if (GetValueFromUser("The new name for this filesystem",
285 &newname) == SUB_ERROR)
289 strcpy(temp_buf, info[FS_TYPE]);
290 if (GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]) ==
293 if (!strcasecmp(info[FS_TYPE], "FSGROUP") ||
294 !strcasecmp(info[FS_TYPE], "MUL"))
296 if (strcasecmp(info[FS_TYPE], temp_buf))
300 free(info[FS_MACHINE]);
301 info[FS_MACHINE] = strdup(NO_MACHINE);
305 if (!strcasecmp(info[FS_TYPE], "AFS"))
307 if (!name || newdefaults)
309 free(info[FS_MACHINE]);
310 info[FS_MACHINE] = strdup(DEFAULT_CELL);
312 if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
315 info[FS_MACHINE] = canonicalize_cell(info[FS_MACHINE]);
319 if (GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]) ==
322 info[FS_MACHINE] = canonicalize_hostname(info[FS_MACHINE]);
327 if (!strcasecmp(info[FS_TYPE], "AFS"))
329 char *path, *args[3], *p;
331 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
332 &info[FS_L_TYPE]) == SUB_ERROR)
334 if (!name || newdefaults)
337 lowercase(info[FS_MACHINE]);
338 sprintf(temp_buf, "%s:%s", info[FS_MACHINE], info[FS_L_TYPE]);
343 status = do_mr_query("get_alias", 3, args, GetAliasValue, &path);
344 if (status == MR_SUCCESS)
346 p = strchr(path, ':');
354 sprintf(temp_buf, "/afs/%s/%s", info[FS_MACHINE], path);
357 for (p = info[FS_NAME];
358 *p && (p - info[FS_NAME]) < depth; p++)
362 strcat(temp_buf, "/x");
363 temp_buf[strlen(temp_buf) - 1] = *p;
367 sprintf(temp_buf, "/afs/%s/%s/other",
368 info[FS_MACHINE], path);
373 else if (depth == -1)
375 if (isdigit(info[FS_NAME][0]))
377 strcat(temp_buf, "/");
378 depth = strlen(temp_buf);
379 for (p = info[FS_NAME]; *p && isdigit(*p); p++)
381 temp_buf[depth++] = *p;
386 strcat(temp_buf, "/other");
392 strcat(temp_buf, "/");
393 strcat(temp_buf, info[FS_NAME]);
398 sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
399 lowercase(info[FS_L_TYPE]), info[FS_NAME]);
401 info[FS_PACK] = strdup(temp_buf);
404 if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
407 if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) ==
410 sprintf(access_type, "fs_access_%s", info[FS_TYPE]);
411 if (GetTypeFromUser("Filesystem's Default Access", access_type,
412 &info[FS_ACCESS]) == SUB_ERROR)
415 if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS])
418 if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) ==
421 if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) ==
425 if (GetYesNoValueFromUser("Propagate changes to fileserver",
426 &info[FS_CREATE]) == SUB_ERROR)
428 if (strcasecmp(info[FS_TYPE], "AFS"))
430 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
431 &info[FS_L_TYPE]) == SUB_ERROR)
435 FreeAndClear(&info[FS_MODTIME], TRUE);
436 FreeAndClear(&info[FS_MODBY], TRUE);
437 FreeAndClear(&info[FS_MODWITH], TRUE);
439 if (name) /* slide the newname into the #2 slot. */
440 SlipInNewName(info, newname);
446 /* --------------- Filesystem Menu ------------- */
448 /* Function Name: GetFS
449 * Description: Get Filesystem information by name.
450 * Arguments: argc, argv - name of filsys in argv[1].
451 * Returns: DM_NORMAL.
454 int GetFS(int argc, char **argv)
458 top = GetFSInfo(LABEL, argv[1]); /* get info. */
459 Loop(top, (void (*)(char **))PrintFSInfo);
460 FreeQueue(top); /* clean the queue. */
464 /* Function Name: GetFSM
465 * Description: Get Filesystem information by machine.
466 * Arguments: argc, argv - name of server in argv[1].
467 * Returns: DM_NORMAL.
470 int GetFSM(int argc, char **argv)
474 argv[1] = canonicalize_hostname(strdup(argv[1]));
475 top = GetFSInfo(MACHINE, argv[1]); /* get info. */
476 Loop(top, (void (*)(char **))PrintFSInfo);
477 FreeQueue(top); /* clean the queue. */
481 /* Function Name: RealDeleteFS
482 * Description: Does the real deletion work.
483 * Arguments: info - array of char *'s containing all useful info.
484 * one_item - a Boolean that is true if only one item
485 * in queue that dumped us here.
489 void RealDeleteFS(char **info, Bool one_item)
492 char temp_buf[BUFSIZ];
495 * Deletions are performed if the user hits 'y' on a list of multiple
496 * filesystem, or if the user confirms on a unique alias.
498 sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
500 if (!one_item || Confirm(temp_buf))
502 if ((stat = do_mr_query("delete_filesys", 1,
503 &info[FS_NAME], NULL, NULL)))
504 com_err(program_name, stat, " filesystem not deleted.");
506 Put_message("Filesystem deleted.");
509 Put_message("Filesystem not deleted.");
512 /* Function Name: DeleteFS
513 * Description: Delete a filesystem give its name.
514 * Arguments: argc, argv - argv[1] is the name of the filesystem.
518 int DeleteFS(int argc, char **argv)
520 struct mqelem *elem = GetFSInfo(LABEL, argv[1]);
521 QueryLoop(elem, PrintFSInfo, RealDeleteFS, "Delete the Filesystem");
527 /* Function Name: RealChangeFS
528 * Description: performs the actual change to the filesys.
529 * Arguments: info - the information
530 * junk - an unused boolean.
534 static void RealChangeFS(char **info, Bool junk)
538 extern Menu nfsphys_menu;
540 args = AskFSInfo(info, TRUE);
543 Put_message("Aborted.");
546 stat = do_mr_query("update_filesys", CountArgs(args), args, NULL, NULL);
550 Put_message("That NFS filesystem is not exported.");
551 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE)
553 Do_menu(&nfsphys_menu, 0, NULL);
554 if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE) == TRUE)
556 if ((stat = do_mr_query("update_filesys", CountArgs(args), args,
558 com_err(program_name, stat, " filesystem not updated");
560 Put_message("filesystem sucessfully updated.");
567 com_err(program_name, stat, " in UpdateFS");
571 /* Function Name: ChangeFS
572 * Description: change the information in a filesys record.
573 * Arguments: arc, argv - value of filsys in argv[1].
574 * Returns: DM_NORMAL.
577 int ChangeFS(int argc, char **argv)
579 struct mqelem *elem = GetFSInfo(LABEL, argv[1]);
580 QueryLoop(elem, NullPrint, RealChangeFS, "Update the Filesystem");
586 /* Function Name: AddFS
587 * Description: change the information in a filesys record.
588 * Arguments: arc, argv - name of filsys in argv[1].
589 * Returns: DM_NORMAL.
592 int AddFS(int argc, char **argv)
594 char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ];
596 extern Menu nfsphys_menu;
598 if (!ValidName(argv[1]))
601 if (!(stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
604 Put_message ("A Filesystem by that name already exists.");
607 else if (stat != MR_NO_MATCH)
609 com_err(program_name, stat, " in AddFS");
613 if (!(args = AskFSInfo(SetDefaults(info, argv[1]), FALSE)))
615 Put_message("Aborted.");
619 stat = do_mr_query("add_filesys", CountArgs(args), args, NULL, NULL);
623 Put_message("That NFS filesystem is not exported.");
624 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE)
626 Do_menu(&nfsphys_menu, 0, NULL);
627 if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
629 if ((stat = do_mr_query("add_filesys", CountArgs(args), args,
631 com_err(program_name, stat, " in AddFS");
633 Put_message("Created.");
640 com_err(program_name, stat, " in AddFS");
643 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 mqelem *top = NULL;
652 stat = do_mr_query("get_value", CountArgs(val), val,
654 if (stat != MR_SUCCESS)
655 com_err(program_name, stat, " getting default quota");
659 def_quota = strdup(((char **)top->q_data)[0]);
665 sprintf(buf, "Give user %s a quota of %s on filesys %s (Y/N)",
666 info[FS_NAME], def_quota, info[FS_NAME]);
667 if (YesNoQuestion(buf, 1) == TRUE)
669 argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME];
670 if (!strcmp(info[FS_TYPE], "NFS"))
671 argv[Q_TYPE] = "USER";
673 argv[Q_TYPE] = "ANY";
674 argv[Q_QUOTA] = def_quota;
675 if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, NULL,
677 com_err(program_name, stat, " while adding quota");
681 else if (stat == MR_SUCCESS)
683 if (YesNoQuestion("Assign a quota on this filesystem (Y/N)", 1) == TRUE)
686 parsed_argv[0] = info[FS_NAME];
687 AddQuota(parsed_argc, parsed_argv);
695 /* Function Name: SortAfter
696 * Description: choose a sortkey to cause an item to be added after
697 * the count element in the queue
698 * Arguments: queue of filesys names & sortkeys, queue count pointer
699 * Returns: sort key to use.
702 char *SortAfter(struct mqelem *elem, int count)
704 char *prev, *next, prevnext, *key, keybuf[9];
706 /* first find the two keys we need to insert between */
708 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++)
725 /* and set the last character */
727 *prev = prevnext = 'A';
734 if (*next - *prev > 1)
735 *key++ = (*next + *prev) / 2;
739 *key++ = (prevnext + 'Z') / 2;
742 return strdup(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.
751 int AddFSToGroup(int argc, char **argv)
754 struct mqelem *elem = NULL;
755 char buf[BUFSIZ], *args[5], *bufp;
757 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
760 if (stat != MR_NO_MATCH)
761 com_err(program_name, stat, " in AddFSToGroup");
768 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
770 com_err(program_name, stat, " in AddFSToGroup");
773 elem = QueueTop(elem);
775 Loop(elem, PrintFSGMembers);
776 sprintf(buf, "%d", QueueCount(elem));
778 if (GetValueFromUser("Enter number of filesystem it should follow "
779 "(0 to make it first):", &bufp) == SUB_ERROR)
783 args[2] = SortAfter(elem, count);
785 FreeQueue(QueueTop(elem));
788 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
789 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 "
796 com_err(program_name, stat, " in AddFSToGroup");
801 /* Function Name: RemoveFSFromGroup
802 * Description: delete a filesystem from an FS group
803 * Arguments: arc, argv - name of group in argv[1].
804 * Returns: DM_NORMAL.
807 int RemoveFSFromGroup(int argc, char **argv)
812 sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]);
815 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv + 1,
817 com_err(program_name, stat, ", not removed.");
821 /* Function Name: ChangeFSGroupOrder
822 * Description: change the sortkey on a filesys in an FSgroup
823 * Arguments: arc, argv - name of group in argv[1].
824 * Returns: DM_NORMAL.
827 int ChangeFSGroupOrder(int argc, char **argv)
829 int stat, src, dst, i;
830 struct mqelem *elem = NULL, *top, *tmpelem;
831 char buf[BUFSIZ], *bufp, *args[3];
833 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
836 if (stat == MR_NO_MATCH)
839 "Ether %s is not a filesystem group or it has no members",
844 com_err(program_name, stat, " in ChangeFSGroupOrder");
847 top = QueueTop(elem);
849 Loop(top, PrintFSGMembers);
853 if (GetValueFromUser("Enter number of the filesystem to move:",
860 Put_message("You must enter a positive number (or 0 to abort).");
865 Put_message("Aborted.");
868 for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw)
872 Put_message("You entered a number that is too high");
880 if (GetValueFromUser("Enter number of filesystem it should follow "
881 "(0 to make it first):", &bufp) == SUB_ERROR)
885 if (src == dst || src == dst + 1)
887 Put_message("That has no effect on the sorting order!");
892 Put_message("You must enter a non-negative number.");
895 for (tmpelem = top, i = dst; i-- > 1 && tmpelem->q_forw;
896 tmpelem = tmpelem->q_forw)
900 Put_message("You entered a number that is too high");
905 args[2] = SortAfter(top, dst);
907 args[1] = ((char **)elem->q_data)[0];
908 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
911 com_err(program_name, stat, " in ChangeFSGroupOrder");
914 if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
916 com_err(program_name, stat, " in ChangeFSGroupOrder");
921 /* -------------- Top Level Menu ---------------- */
923 /* Function Name: GetFSAlias
924 * Description: Gets the value for a Filesystem Alias.
925 * Arguments: argc, argv - name of alias in argv[1].
926 * Returns: DM_NORMAL.
927 * NOTES: There should only be one filesystem per alias, thus
928 * this will work correctly.
931 int GetFSAlias(int argc, char **argv)
935 top = GetFSInfo(ALIAS, argv[1]);
936 Put_message(" "); /* blank line. */
937 Loop(top, (void (*)(char **))PrintFSAlias);
942 /* Function Name: CreateFSAlias
943 * Description: Create an alias name for a filesystem
944 * Arguments: argc, argv - name of alias in argv[1].
945 * Returns: DM_NORMAL.
946 * NOTES: This requires (name, type, transl) I get {name, translation}
947 * from the user. I provide type, which is well-known.
950 int CreateFSAlias(int argc, char **argv)
953 struct mqelem *elem, *top;
954 char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
958 if (!ValidName(argv[1]))
961 args[ALIAS_NAME] = strdup(argv[1]);
962 args[ALIAS_TYPE] = strdup(FS_ALIAS_TYPE);
963 args[ALIAS_TRANS] = strdup("*");
966 * Check to see if this alias already exists in the database, if so then
967 * print out values, free memory used and then exit.
970 if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
972 top = elem = QueueTop(elem);
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)
986 com_err(program_name, stat, " in CreateFSAlias.");
990 args[ALIAS_TRANS] = strdup("");
991 args[ALIAS_END] = NULL;
992 if (GetValueFromUser("Which filesystem will this alias point to?",
993 &args[ALIAS_TRANS]) == SUB_ERROR)
996 if ((stat = do_mr_query("add_alias", 3, args, NULL, NULL)))
997 com_err(program_name, stat, " in CreateFSAlias.");
1003 /* Function Name: RealDeleteFSAlias
1004 * Description: Does the real deletion work.
1005 * Arguments: info - array of char *'s containing all useful info.
1006 * one_item - a Boolean that is true if only one item
1007 * in queue that dumped us here.
1011 void RealDeleteFSAlias(char **info, Bool one_item)
1014 char temp_buf[BUFSIZ];
1017 * Deletions are performed if the user hits 'y' on a list of multiple
1018 * filesystem, or if the user confirms on a unique alias.
1021 "Are you sure that you want to delete the filesystem alias %s",
1023 if (!one_item || Confirm(temp_buf))
1025 if ((stat = do_mr_query("delete_alias", CountArgs(info),
1027 com_err(program_name, stat, " filesystem alias not deleted.");
1029 Put_message("Filesystem alias deleted.");
1032 Put_message("Filesystem alias not deleted.");
1035 /* Function Name: DeleteFSAlias
1036 * Description: Delete an alias name for a filesystem
1037 * Arguments: argc, argv - name of alias in argv[1].
1038 * Returns: DM_NORMAL.
1039 * NOTES: This requires (name, type, transl) I get {name, translation}
1040 * from the user. I provide type, which is well-known.
1043 int DeleteFSAlias(int argc, char **argv)
1045 struct mqelem *elem = GetFSInfo(ALIAS, argv[1]);
1046 QueryLoop(elem, PrintFSAlias, RealDeleteFSAlias,
1047 "Delete the Filesystem Alias");
1052 /* Function Name: AttachHelp
1053 * Description: Print help info on attachmaint.
1055 * Returns: DM_NORMAL.
1058 int AttachHelp(void)
1060 static char *message[] = {
1061 "These are the options:",
1063 "get - get information about a filesystem.",
1064 "add - add a new filesystem to the data base.",
1065 "update - update the information in the database on a filesystem.",
1066 "delete - delete a filesystem from the database.",
1067 "check - check information about association of a name and a filesys.",
1068 "alias - associate a name with a filesystem.",
1069 "unalias - disassociate a name with a filesystem.",
1070 "verbose - toggle the request for delete confirmation.",
1074 return PrintHelp(message);
1077 /* Function Name: FSGroupHelp
1078 * Description: Print help info on fsgroups.
1080 * Returns: DM_NORMAL.
1083 int FSGroupHelp(int argc, char **argv)
1085 static char *message[] = {
1086 "A filesystem group is a named sorted list of filesystems.",
1088 "To create, modify, or delete a group itself, use the menu above",
1089 " this one, and manipulate a filesystem of type FSGROUP.",
1090 "Options here are:",
1091 " get - get info about a group and show its members",
1092 " add - add a new member to a group.",
1093 " remove - remove a member from a group.",
1094 " order - change the sorting order of a group.",
1098 return PrintHelp(message);