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>
33 #endif /* HAVE_UNISTD_H */
37 char *canonicalize_cell(char *c);
38 int GetAliasValue(int argc, char **argv, void *retval);
39 void RealDeleteFS(char **info, Bool one_item);
40 char *SortAfter(struct mqelem *elem, int count);
41 void RealDeleteFSAlias(char **info, Bool one_item);
43 #define FS_ALIAS_TYPE "FILESYS"
50 #define NO_MACHINE ("[NONE]")
52 #define DEFAULT_TYPE ("AFS")
53 #define DEFAULT_MACHINE DEFAULT_NONE
54 #define DEFAULT_PACK DEFAULT_NONE
55 #define DEFAULT_ACCESS ("w")
56 #define DEFAULT_COMMENTS DEFAULT_COMMENT
57 #define DEFAULT_OWNER (user)
58 #define DEFAULT_OWNERS (user)
59 #define DEFAULT_CREATE DEFAULT_YES
60 #define DEFAULT_L_TYPE ("PROJECT")
61 #define DEFAULT_CELL ("athena.mit.edu")
63 /* Function Name: SetDefaults
64 * Description: sets the default values for filesystem additions.
65 * Arguments: info - an array of char pointers to recieve defaults.
66 * Returns: char ** (this array, now filled).
69 static char **SetDefaults(char **info, char *name)
73 info[FS_NAME] = strdup(name);
74 info[FS_TYPE] = strdup(DEFAULT_TYPE);
75 info[FS_MACHINE] = strdup(DEFAULT_MACHINE);
76 info[FS_PACK] = strdup(DEFAULT_PACK);
77 sprintf(buf, "/mit/%s", name);
78 info[FS_M_POINT] = strdup(buf);
79 info[FS_ACCESS] = strdup(DEFAULT_ACCESS);
80 info[FS_COMMENTS] = strdup(DEFAULT_COMMENTS);
81 info[FS_OWNER] = strdup(DEFAULT_OWNER);
82 info[FS_OWNERS] = strdup(DEFAULT_OWNERS);
83 info[FS_CREATE] = strdup(DEFAULT_CREATE);
84 info[FS_L_TYPE] = strdup(DEFAULT_L_TYPE);
85 info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL;
89 /* Function Name: GetFSInfo
90 * Description: Stores the info in a queue.
91 * Arguments: type - type of information to get.
92 * name - name of the item to get information on.
93 * Returns: a pointer to the first element in the queue.
96 static struct mqelem *GetFSInfo(int type, char *name)
99 struct mqelem *elem = NULL;
105 if ((stat = do_mr_query("get_filesys_by_label", 1, &name,
108 com_err(program_name, stat, " in GetFSInfo");
113 if ((stat = do_mr_query("get_filesys_by_machine", 1, &name,
116 com_err(program_name, stat, " in GetFSInfo");
121 if ((stat = do_mr_query("get_filesys_by_group", 1, &name,
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, &elem)))
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().
148 static char *PrintFSAlias(char **info)
152 sprintf(buf, "Alias: %-25s Filesystem: %s", info[ALIAS_NAME],
155 return info[ALIAS_NAME];
158 static int fsgCount = 1;
160 static void PrintFSGMembers(char **info)
162 char print_buf[BUFSIZ];
164 sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)",
165 fsgCount++, info[0], info[1]);
166 Put_message(print_buf);
170 /* Function Name: PrintFSInfo
171 * Description: Prints the filesystem information.
172 * Arguments: info - a pointer to the filesystem information.
176 static char *PrintFSInfo(char **info)
178 char print_buf[BUFSIZ];
182 if (!strcmp(info[FS_TYPE], "FSGROUP") || !strcmp(info[FS_TYPE], "MUL"))
185 struct mqelem *elem = NULL;
187 if (!strcmp(info[FS_TYPE], "MUL"))
188 sprintf(print_buf, "%20s Multiple Filesystem: %s", " ", info[FS_NAME]);
190 sprintf(print_buf, "%20s Filesystem Group: %s", " ", info[FS_NAME]);
191 Put_message(print_buf);
193 sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
194 Put_message(print_buf);
195 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
197 Put_message(print_buf);
198 Put_message("Containing the filesystems (in order):");
199 if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
202 if (stat == MR_NO_MATCH)
203 Put_message(" [no members]");
205 com_err(program_name, stat, " in PrintFSInfo");
210 Loop(QueueTop(elem), 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", info[FS_L_TYPE]);
231 Put_message(print_buf);
232 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
234 Put_message(print_buf);
236 return info[FS_NAME];
239 char *canonicalize_cell(char *c)
248 sprintf(path, "/afs/%s", c);
249 if (lstat(path, &stbuf) || !stbuf.st_mode & S_IFLNK)
251 count = readlink(path, path, sizeof(path));
261 int GetAliasValue(int argc, char **argv, void *retval)
263 *(char **)retval = strdup(argv[2]);
267 /* Function Name: AskFSInfo.
268 * Description: This function askes the user for information about a
269 * machine and saves it into a structure.
270 * Arguments: info - a pointer the the structure to put the
272 * name - add a newname field? (T/F)
276 static char **AskFSInfo(char **info, Bool name)
278 char temp_buf[BUFSIZ], *newname, access_type[32];
279 int fsgroup = 0, newdefaults = 0;
282 sprintf(temp_buf, "Changing Attributes of filesystem %s.", info[FS_NAME]);
283 Put_message(temp_buf);
288 newname = strdup(info[FS_NAME]);
289 if (GetValueFromUser("The new name for this filesystem",
290 &newname) == SUB_ERROR)
294 strcpy(temp_buf, info[FS_TYPE]);
295 if (GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]) ==
298 if (!strcasecmp(info[FS_TYPE], "FSGROUP") ||
299 !strcasecmp(info[FS_TYPE], "MUL"))
301 if (strcasecmp(info[FS_TYPE], temp_buf))
305 free(info[FS_MACHINE]);
306 info[FS_MACHINE] = strdup(NO_MACHINE);
310 if (!strcasecmp(info[FS_TYPE], "AFS"))
312 if (!name || newdefaults)
314 free(info[FS_MACHINE]);
315 info[FS_MACHINE] = strdup(DEFAULT_CELL);
317 if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
320 info[FS_MACHINE] = canonicalize_cell(info[FS_MACHINE]);
324 if (GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]) ==
327 info[FS_MACHINE] = canonicalize_hostname(info[FS_MACHINE]);
332 if (!strcasecmp(info[FS_TYPE], "AFS"))
334 char *path, *args[3], *p;
336 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
337 &info[FS_L_TYPE]) == SUB_ERROR)
339 if (!name || newdefaults)
342 lowercase(info[FS_MACHINE]);
343 sprintf(temp_buf, "%s:%s", info[FS_MACHINE], info[FS_L_TYPE]);
348 status = do_mr_query("get_alias", 3, args, GetAliasValue, &path);
349 if (status == MR_SUCCESS)
351 p = strchr(path, ':');
359 sprintf(temp_buf, "/afs/%s/%s", info[FS_MACHINE], path);
362 for (p = info[FS_NAME];
363 *p && (p - info[FS_NAME]) < depth; p++)
367 strcat(temp_buf, "/x");
368 temp_buf[strlen(temp_buf) - 1] = *p;
372 sprintf(temp_buf, "/afs/%s/%s/other",
373 info[FS_MACHINE], path);
378 else if (depth == -1)
380 if (isdigit(info[FS_NAME][0]))
382 strcat(temp_buf, "/");
383 depth = strlen(temp_buf);
384 for (p = info[FS_NAME]; *p && isdigit(*p); p++)
386 temp_buf[depth++] = *p;
391 strcat(temp_buf, "/other");
397 strcat(temp_buf, "/");
398 strcat(temp_buf, info[FS_NAME]);
403 sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
404 lowercase(info[FS_L_TYPE]), info[FS_NAME]);
406 info[FS_PACK] = strdup(temp_buf);
409 if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
412 if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) ==
415 sprintf(access_type, "fs_access_%s", info[FS_TYPE]);
416 if (GetTypeFromUser("Filesystem's Default Access", access_type,
417 &info[FS_ACCESS]) == SUB_ERROR)
420 if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS])
423 if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) ==
426 if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) ==
430 if (GetYesNoValueFromUser("Propagate changes to fileserver",
431 &info[FS_CREATE]) == SUB_ERROR)
433 if (strcasecmp(info[FS_TYPE], "AFS"))
435 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
436 &info[FS_L_TYPE]) == SUB_ERROR)
440 FreeAndClear(&info[FS_MODTIME], TRUE);
441 FreeAndClear(&info[FS_MODBY], TRUE);
442 FreeAndClear(&info[FS_MODWITH], TRUE);
444 if (name) /* slide the newname into the #2 slot. */
445 SlipInNewName(info, newname);
451 /* --------------- Filesystem Menu ------------- */
453 /* Function Name: GetFS
454 * Description: Get Filesystem information by name.
455 * Arguments: argc, argv - name of filsys in argv[1].
456 * Returns: DM_NORMAL.
459 int GetFS(int argc, char **argv)
463 top = GetFSInfo(LABEL, argv[1]); /* get info. */
464 Loop(top, (void (*)(char **))PrintFSInfo);
465 FreeQueue(top); /* clean the queue. */
469 /* Function Name: GetFSM
470 * Description: Get Filesystem information by machine.
471 * Arguments: argc, argv - name of server in argv[1].
472 * Returns: DM_NORMAL.
475 int GetFSM(int argc, char **argv)
479 argv[1] = canonicalize_hostname(strdup(argv[1]));
480 top = GetFSInfo(MACHINE, argv[1]); /* get info. */
481 Loop(top, (void (*)(char **))PrintFSInfo);
482 FreeQueue(top); /* clean the queue. */
486 /* Function Name: RealDeleteFS
487 * Description: Does the real deletion work.
488 * Arguments: info - array of char *'s containing all useful info.
489 * one_item - a Boolean that is true if only one item
490 * in queue that dumped us here.
494 void RealDeleteFS(char **info, Bool one_item)
497 char temp_buf[BUFSIZ];
500 * Deletions are performed if the user hits 'y' on a list of multiple
501 * filesystem, or if the user confirms on a unique alias.
503 sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
505 if (!one_item || Confirm(temp_buf))
507 if ((stat = do_mr_query("delete_filesys", 1,
508 &info[FS_NAME], NULL, NULL)))
509 com_err(program_name, stat, " filesystem not deleted.");
511 Put_message("Filesystem deleted.");
514 Put_message("Filesystem not deleted.");
517 /* Function Name: DeleteFS
518 * Description: Delete a filesystem give its name.
519 * Arguments: argc, argv - argv[1] is the name of the filesystem.
523 int DeleteFS(int argc, char **argv)
525 struct mqelem *elem = GetFSInfo(LABEL, argv[1]);
526 QueryLoop(elem, PrintFSInfo, RealDeleteFS, "Delete the Filesystem");
532 /* Function Name: RealChangeFS
533 * Description: performs the actual change to the filesys.
534 * Arguments: info - the information
535 * junk - an unused boolean.
539 static void RealChangeFS(char **info, Bool junk)
543 extern Menu nfsphys_menu;
545 args = AskFSInfo(info, TRUE);
548 Put_message("Aborted.");
551 stat = do_mr_query("update_filesys", CountArgs(args), args, NULL, NULL);
555 Put_message("That NFS filesystem is not exported.");
556 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE)
558 Do_menu(&nfsphys_menu, 0, NULL);
559 if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE) == TRUE)
561 if ((stat = do_mr_query("update_filesys", CountArgs(args), args,
563 com_err(program_name, stat, " filesystem not updated");
565 Put_message("filesystem sucessfully updated.");
572 com_err(program_name, stat, " in UpdateFS");
576 /* Function Name: ChangeFS
577 * Description: change the information in a filesys record.
578 * Arguments: arc, argv - value of filsys in argv[1].
579 * Returns: DM_NORMAL.
582 int ChangeFS(int argc, char **argv)
584 struct mqelem *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.
597 int AddFS(int argc, char **argv)
599 char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ];
601 extern Menu nfsphys_menu;
603 if (!ValidName(argv[1]))
606 if (!(stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
609 Put_message ("A Filesystem by that name already exists.");
612 else if (stat != MR_NO_MATCH)
614 com_err(program_name, stat, " in AddFS");
618 if (!(args = AskFSInfo(SetDefaults(info, argv[1]), FALSE)))
620 Put_message("Aborted.");
624 stat = do_mr_query("add_filesys", CountArgs(args), args, NULL, NULL);
628 Put_message("That NFS filesystem is not exported.");
629 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE)
631 Do_menu(&nfsphys_menu, 0, NULL);
632 if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
634 if ((stat = do_mr_query("add_filesys", CountArgs(args), args,
636 com_err(program_name, stat, " in AddFS");
638 Put_message("Created.");
645 com_err(program_name, stat, " in AddFS");
648 if (stat == MR_SUCCESS && !strcasecmp(info[FS_L_TYPE], "HOMEDIR"))
650 static char *val[] = {"def_quota", NULL};
651 static char *def_quota = NULL;
652 char *argv[Q_QUOTA + 1];
653 struct mqelem *top = NULL;
657 stat = do_mr_query("get_value", CountArgs(val), val,
659 if (stat != MR_SUCCESS)
660 com_err(program_name, stat, " getting default quota");
664 def_quota = strdup(((char **)top->q_data)[0]);
670 sprintf(buf, "Give user %s a quota of %s on filesys %s (Y/N)",
671 info[FS_NAME], def_quota, info[FS_NAME]);
672 if (YesNoQuestion(buf, 1) == TRUE)
674 argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME];
675 if (!strcmp(info[FS_TYPE], "NFS"))
676 argv[Q_TYPE] = "USER";
678 argv[Q_TYPE] = "ANY";
679 argv[Q_QUOTA] = def_quota;
680 if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, NULL,
682 com_err(program_name, stat, " while adding quota");
686 else if (stat == MR_SUCCESS)
688 if (YesNoQuestion("Assign a quota on this filesystem (Y/N)", 1) == TRUE)
691 parsed_argv[0] = info[FS_NAME];
692 AddQuota(parsed_argc, parsed_argv);
700 /* Function Name: SortAfter
701 * Description: choose a sortkey to cause an item to be added after
702 * the count element in the queue
703 * Arguments: queue of filesys names & sortkeys, queue count pointer
704 * Returns: sort key to use.
707 char *SortAfter(struct mqelem *elem, int count)
709 char *prev, *next, prevnext, *key, keybuf[9];
711 /* first find the two keys we need to insert between */
713 for (; count > 0; count--)
715 prev = ((char **)elem->q_data)[1];
724 next = ((char **)elem->q_data)[1];
726 /* now copy the matching characters */
727 for (key = keybuf; *prev && *prev == *next; next++)
730 /* and set the last character */
732 *prev = prevnext = 'A';
739 if (*next - *prev > 1)
740 *key++ = (*next + *prev) / 2;
744 *key++ = (prevnext + 'Z') / 2;
747 return strdup(keybuf);
750 /* Function Name: AddFSToGroup
751 * Description: add a filesystem to an FS group
752 * Arguments: arc, argv - name of group in argv[1], filesys in argv[2].
753 * Returns: DM_NORMAL.
756 int AddFSToGroup(int argc, char **argv)
759 struct mqelem *elem = NULL;
760 char buf[BUFSIZ], *args[5], *bufp;
762 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
765 if (stat != MR_NO_MATCH)
766 com_err(program_name, stat, " in AddFSToGroup");
773 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
775 com_err(program_name, stat, " in AddFSToGroup");
778 elem = QueueTop(elem);
780 Loop(elem, PrintFSGMembers);
781 sprintf(buf, "%d", QueueCount(elem));
783 if (GetValueFromUser("Enter number of filesystem it should follow "
784 "(0 to make it first):", &bufp) == SUB_ERROR)
788 args[2] = SortAfter(elem, count);
790 FreeQueue(QueueTop(elem));
793 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
794 if (stat == MR_EXISTS)
796 Put_message("That filesystem is already a member of the group.");
797 Put_message("Use the order command if you want to change the "
801 com_err(program_name, stat, " in AddFSToGroup");
806 /* Function Name: RemoveFSFromGroup
807 * Description: delete a filesystem from an FS group
808 * Arguments: arc, argv - name of group in argv[1].
809 * Returns: DM_NORMAL.
812 int RemoveFSFromGroup(int argc, char **argv)
817 sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]);
820 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv + 1,
822 com_err(program_name, stat, ", not removed.");
826 /* Function Name: ChangeFSGroupOrder
827 * Description: change the sortkey on a filesys in an FSgroup
828 * Arguments: arc, argv - name of group in argv[1].
829 * Returns: DM_NORMAL.
832 int ChangeFSGroupOrder(int argc, char **argv)
834 int stat, src, dst, i;
835 struct mqelem *elem = NULL, *top, *tmpelem;
836 char buf[BUFSIZ], *bufp, *args[3];
838 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
841 if (stat == MR_NO_MATCH)
844 "Ether %s is not a filesystem group or it has no members",
849 com_err(program_name, stat, " in ChangeFSGroupOrder");
852 top = QueueTop(elem);
854 Loop(top, PrintFSGMembers);
858 if (GetValueFromUser("Enter number of the filesystem to move:",
865 Put_message("You must enter a positive number (or 0 to abort).");
870 Put_message("Aborted.");
873 for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw)
877 Put_message("You entered a number that is too high");
885 if (GetValueFromUser("Enter number of filesystem it should follow "
886 "(0 to make it first):", &bufp) == SUB_ERROR)
890 if (src == dst || src == dst + 1)
892 Put_message("That has no effect on the sorting order!");
897 Put_message("You must enter a non-negative number.");
900 for (tmpelem = top, i = dst; i-- > 1 && tmpelem->q_forw;
901 tmpelem = tmpelem->q_forw)
905 Put_message("You entered a number that is too high");
910 args[2] = SortAfter(top, dst);
912 args[1] = ((char **)elem->q_data)[0];
913 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
916 com_err(program_name, stat, " in ChangeFSGroupOrder");
919 if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
921 com_err(program_name, stat, " in ChangeFSGroupOrder");
926 /* -------------- Top Level Menu ---------------- */
928 /* Function Name: GetFSAlias
929 * Description: Gets the value for a Filesystem Alias.
930 * Arguments: argc, argv - name of alias in argv[1].
931 * Returns: DM_NORMAL.
932 * NOTES: There should only be one filesystem per alias, thus
933 * this will work correctly.
936 int GetFSAlias(int argc, char **argv)
940 top = GetFSInfo(ALIAS, argv[1]);
941 Put_message(" "); /* blank line. */
942 Loop(top, (void (*)(char **))PrintFSAlias);
947 /* Function Name: CreateFSAlias
948 * Description: Create an alias name for a filesystem
949 * Arguments: argc, argv - name of alias in argv[1].
950 * Returns: DM_NORMAL.
951 * NOTES: This requires (name, type, transl) I get {name, translation}
952 * from the user. I provide type, which is well-known.
955 int CreateFSAlias(int argc, char **argv)
958 struct mqelem *elem, *top;
959 char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
963 if (!ValidName(argv[1]))
966 args[ALIAS_NAME] = strdup(argv[1]);
967 args[ALIAS_TYPE] = strdup(FS_ALIAS_TYPE);
968 args[ALIAS_TRANS] = strdup("*");
971 * Check to see if this alias already exists in the database, if so then
972 * print out values, free memory used and then exit.
975 if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
977 top = elem = QueueTop(elem);
981 sprintf(buf, "The alias: %s currently describes the filesystem %s",
982 info[ALIAS_NAME], info[ALIAS_TRANS]);
989 else if (stat != MR_NO_MATCH)
991 com_err(program_name, stat, " in CreateFSAlias.");
995 args[ALIAS_TRANS] = strdup("");
996 args[ALIAS_END] = NULL;
997 if (GetValueFromUser("Which filesystem will this alias point to?",
998 &args[ALIAS_TRANS]) == SUB_ERROR)
1001 if ((stat = do_mr_query("add_alias", 3, args, NULL, NULL)))
1002 com_err(program_name, stat, " in CreateFSAlias.");
1008 /* Function Name: RealDeleteFSAlias
1009 * Description: Does the real deletion work.
1010 * Arguments: info - array of char *'s containing all useful info.
1011 * one_item - a Boolean that is true if only one item
1012 * in queue that dumped us here.
1016 void RealDeleteFSAlias(char **info, Bool one_item)
1019 char temp_buf[BUFSIZ];
1022 * Deletions are performed if the user hits 'y' on a list of multiple
1023 * filesystem, or if the user confirms on a unique alias.
1026 "Are you sure that you want to delete the filesystem alias %s",
1028 if (!one_item || Confirm(temp_buf))
1030 if ((stat = do_mr_query("delete_alias", CountArgs(info),
1032 com_err(program_name, stat, " filesystem alias not deleted.");
1034 Put_message("Filesystem alias deleted.");
1037 Put_message("Filesystem alias not deleted.");
1040 /* Function Name: DeleteFSAlias
1041 * Description: Delete an alias name for a filesystem
1042 * Arguments: argc, argv - name of alias in argv[1].
1043 * Returns: DM_NORMAL.
1044 * NOTES: This requires (name, type, transl) I get {name, translation}
1045 * from the user. I provide type, which is well-known.
1048 int DeleteFSAlias(int argc, char **argv)
1050 struct mqelem *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.
1063 int AttachHelp(void)
1065 static char *message[] = {
1066 "These are the options:",
1068 "get - get information about a filesystem.",
1069 "add - add a new filesystem to the data base.",
1070 "update - update the information in the database on a filesystem.",
1071 "delete - delete a filesystem from the database.",
1072 "check - check information about association of a name and a filesys.",
1073 "alias - associate a name with a filesystem.",
1074 "unalias - disassociate a name with a filesystem.",
1075 "verbose - toggle the request for delete confirmation.",
1079 return PrintHelp(message);
1082 /* Function Name: FSGroupHelp
1083 * Description: Print help info on fsgroups.
1085 * Returns: DM_NORMAL.
1088 int FSGroupHelp(int argc, char **argv)
1090 static char *message[] = {
1091 "A filesystem group is a named sorted list of filesystems.",
1093 "To create, modify, or delete a group itself, use the menu above",
1094 " this one, and manipulate a filesystem of type FSGROUP.",
1095 "Options here are:",
1096 " get - get info about a group and show its members",
1097 " add - add a new member to a group.",
1098 " remove - remove a member from a group.",
1099 " order - change the sorting order of a group.",
1103 return PrintHelp(message);