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]")
47 #define DEFAULT_TYPE ("AFS")
48 #define DEFAULT_MACHINE DEFAULT_NONE
49 #define DEFAULT_PACK DEFAULT_NONE
50 #define DEFAULT_ACCESS ("w")
51 #define DEFAULT_COMMENTS DEFAULT_COMMENT
52 #define DEFAULT_OWNER (user)
53 #define DEFAULT_OWNERS (user)
54 #define DEFAULT_CREATE DEFAULT_YES
55 #define DEFAULT_L_TYPE ("PROJECT")
56 #define DEFAULT_CELL ("athena.mit.edu")
58 /* Function Name: SetDefaults
59 * Description: sets the default values for filesystem additions.
60 * Arguments: info - an array of char pointers to recieve defaults.
61 * Returns: char ** (this array, now filled).
64 static char **SetDefaults(char **info, char *name)
68 info[FS_NAME] = Strsave(name);
69 info[FS_TYPE] = Strsave(DEFAULT_TYPE);
70 info[FS_MACHINE] = Strsave(DEFAULT_MACHINE);
71 info[FS_PACK] = Strsave(DEFAULT_PACK);
72 sprintf(buf, "/mit/%s", name);
73 info[FS_M_POINT] = Strsave(buf);
74 info[FS_ACCESS] = Strsave(DEFAULT_ACCESS);
75 info[FS_COMMENTS] = Strsave(DEFAULT_COMMENTS);
76 info[FS_OWNER] = Strsave(DEFAULT_OWNER);
77 info[FS_OWNERS] = Strsave(DEFAULT_OWNERS);
78 info[FS_CREATE] = Strsave(DEFAULT_CREATE);
79 info[FS_L_TYPE] = Strsave(DEFAULT_L_TYPE);
80 info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL;
84 /* Function Name: GetFSInfo
85 * Description: Stores the info in a queue.
86 * Arguments: type - type of information to get.
87 * name - name of the item to get information on.
88 * Returns: a pointer to the first element in the queue.
91 static struct qelem *GetFSInfo(int type, char *name)
94 struct qelem *elem = NULL;
100 if ((stat = do_mr_query("get_filesys_by_label", 1, &name,
101 StoreInfo, (char *)&elem)))
103 com_err(program_name, stat, " in GetFSInfo");
108 if ((stat = do_mr_query("get_filesys_by_machine", 1, &name,
109 StoreInfo, (char *)&elem)))
111 com_err(program_name, stat, " in GetFSInfo");
116 if ((stat = do_mr_query("get_filesys_by_group", 1, &name,
117 StoreInfo, (char *)&elem)))
119 com_err(program_name, stat, " in GetFSInfo");
124 args[ALIAS_NAME] = name;
125 args[ALIAS_TYPE] = FS_ALIAS_TYPE;
126 args[ALIAS_TRANS] = "*";
127 if ((stat = do_mr_query("get_alias", 3, args, StoreInfo,
130 com_err(program_name, stat, " in get_alias.");
135 return QueueTop(elem);
138 /* Function Name: PrintFSAlias
139 * Description: Prints a filesystem alias
140 * Arguments: info - an array contains the strings of info.
141 * Returns: the name of the filesys - used be QueryLoop().
144 static char *PrintFSAlias(char **info)
148 sprintf(buf, "Alias: %-25s Filesystem: %s", info[ALIAS_NAME],
151 return info[ALIAS_NAME];
154 static int fsgCount = 1;
156 static char *PrintFSGMembers(char **info)
158 char print_buf[BUFSIZ];
160 sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)",
161 fsgCount++, info[0], info[1]);
162 Put_message(print_buf);
167 /* Function Name: PrintFSInfo
168 * Description: Prints the filesystem information.
169 * Arguments: info - a pointer to the filesystem information.
173 static char *PrintFSInfo(char **info)
175 char print_buf[BUFSIZ];
179 if (!strcmp(info[FS_TYPE], "FSGROUP") || !strcmp(info[FS_TYPE], "MUL"))
182 struct qelem *elem = NULL;
184 if (!strcmp(info[FS_TYPE], "MUL"))
185 sprintf(print_buf, "%20s Multiple Filesystem: %s", " ", info[FS_NAME]);
187 sprintf(print_buf, "%20s Filesystem Group: %s", " ", info[FS_NAME]);
188 Put_message(print_buf);
190 sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
191 Put_message(print_buf);
192 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
194 Put_message(print_buf);
195 Put_message("Containing the filesystems (in order):");
196 if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
197 StoreInfo, (char *)&elem)))
199 if (stat == MR_NO_MATCH)
200 Put_message(" [no members]");
202 com_err(program_name, stat, " in PrintFSInfo");
207 Loop(QueueTop(elem), PrintFSGMembers);
213 sprintf(print_buf, "%20s Filesystem: %s", " ", info[FS_NAME]);
214 Put_message(print_buf);
215 sprintf(print_buf, "Type: %-40s Machine: %-15s",
216 info[FS_TYPE], info[FS_MACHINE]);
217 Put_message(print_buf);
218 sprintf(print_buf, "Default Access: %-2s Packname: %-17s Mountpoint %s ",
219 info[FS_ACCESS], info[FS_PACK], info[FS_M_POINT]);
220 Put_message(print_buf);
221 sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
222 Put_message(print_buf);
223 sprintf(print_buf, "User Ownership: %-30s Group Ownership: %s",
224 info[FS_OWNER], info[FS_OWNERS]);
225 Put_message(print_buf);
226 sprintf(print_buf, "Update Fileserver: %-27s Locker Type: %s",
227 atoi(info[FS_CREATE]) ? "ON" : "OFF", info[FS_L_TYPE]);
228 Put_message(print_buf);
229 sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
231 Put_message(print_buf);
233 return info[FS_NAME];
237 char *canonicalize_cell(char *c)
243 sprintf(path, "/afs/%s", c);
244 if (lstat(path, &stbuf) || !stbuf.st_mode & S_IFLNK)
246 count = readlink(path, path, sizeof(path));
251 return strsave(path);
255 int GetAliasValue(int argc, char **argv, char **retval)
257 *retval = strsave(argv[2]);
261 /* Function Name: AskFSInfo.
262 * Description: This function askes the user for information about a
263 * machine and saves it into a structure.
264 * Arguments: info - a pointer the the structure to put the
266 * name - add a newname field? (T/F)
270 static char **AskFSInfo(char **info, Bool name)
272 char temp_buf[BUFSIZ], *newname, access_type[32];
273 int fsgroup = 0, newdefaults = 0;
276 sprintf(temp_buf, "Changing Attributes of filesystem %s.", info[FS_NAME]);
277 Put_message(temp_buf);
282 newname = Strsave(info[FS_NAME]);
283 if (GetValueFromUser("The new name for this filesystem",
284 &newname) == SUB_ERROR)
288 strcpy(temp_buf, info[FS_TYPE]);
289 if (GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]) ==
292 if (!strcasecmp(info[FS_TYPE], "FSGROUP") ||
293 !strcasecmp(info[FS_TYPE], "MUL"))
295 if (strcasecmp(info[FS_TYPE], temp_buf))
299 free(info[FS_MACHINE]);
300 info[FS_MACHINE] = Strsave(NO_MACHINE);
304 if (!strcasecmp(info[FS_TYPE], "AFS"))
306 if (!name || newdefaults)
308 free(info[FS_MACHINE]);
309 info[FS_MACHINE] = strsave(DEFAULT_CELL);
311 if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
314 info[FS_MACHINE] = canonicalize_cell(info[FS_MACHINE]);
318 if (GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]) ==
321 info[FS_MACHINE] = canonicalize_hostname(info[FS_MACHINE]);
326 if (!strcasecmp(info[FS_TYPE], "AFS"))
328 char *path, *args[3], *p;
330 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
331 &info[FS_L_TYPE]) == SUB_ERROR)
333 if (!name || newdefaults)
336 lowercase(info[FS_MACHINE]);
337 sprintf(temp_buf, "%s:%s", info[FS_MACHINE], info[FS_L_TYPE]);
342 status = do_mr_query("get_alias", 3, args, GetAliasValue, &path);
343 if (status == MR_SUCCESS)
345 p = strchr(path, ':');
353 sprintf(temp_buf, "/afs/%s/%s", info[FS_MACHINE], path);
356 for (p = info[FS_NAME];
357 *p && (p - info[FS_NAME]) < depth; p++)
361 strcat(temp_buf, "/x");
362 temp_buf[strlen(temp_buf) - 1] = *p;
366 sprintf(temp_buf, "/afs/%s/%s/other",
367 info[FS_MACHINE], path);
372 else if (depth == -1)
374 if (isdigit(info[FS_NAME][0]))
376 strcat(temp_buf, "/");
377 depth = strlen(temp_buf);
378 for (p = info[FS_NAME]; *p && isdigit(*p); p++)
380 temp_buf[depth++] = *p;
385 strcat(temp_buf, "/other");
391 strcat(temp_buf, "/");
392 strcat(temp_buf, info[FS_NAME]);
397 sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
398 lowercase(info[FS_L_TYPE]), info[FS_NAME]);
400 info[FS_PACK] = strsave(temp_buf);
403 if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
406 if (GetValueFromUser("Filesystem's Mount Point", &info[FS_M_POINT]) ==
409 sprintf(access_type, "fs_access_%s", info[FS_TYPE]);
410 if (GetTypeFromUser("Filesystem's Default Access", access_type,
411 &info[FS_ACCESS]) == SUB_ERROR)
414 if (GetValueFromUser("Comments about this Filesystem", &info[FS_COMMENTS])
417 if (GetValueFromUser("Filesystem's owner (user)", &info[FS_OWNER]) ==
420 if (GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]) ==
424 if (GetYesNoValueFromUser("Propagate changes to fileserver",
425 &info[FS_CREATE]) == SUB_ERROR)
427 if (strcasecmp(info[FS_TYPE], "AFS"))
429 if (GetTypeFromUser("Filesystem's lockertype", "lockertype",
430 &info[FS_L_TYPE]) == SUB_ERROR)
434 FreeAndClear(&info[FS_MODTIME], TRUE);
435 FreeAndClear(&info[FS_MODBY], TRUE);
436 FreeAndClear(&info[FS_MODWITH], TRUE);
438 if (name) /* slide the newname into the #2 slot. */
439 SlipInNewName(info, newname);
445 /* --------------- Filesystem Menu ------------- */
447 /* Function Name: GetFS
448 * Description: Get Filesystem information by name.
449 * Arguments: argc, argv - name of filsys in argv[1].
450 * Returns: DM_NORMAL.
453 int GetFS(int argc, char **argv)
457 top = GetFSInfo(LABEL, argv[1]); /* get info. */
458 Loop(top, PrintFSInfo);
459 FreeQueue(top); /* clean the queue. */
463 /* Function Name: GetFSM
464 * Description: Get Filesystem information by machine.
465 * Arguments: argc, argv - name of server in argv[1].
466 * Returns: DM_NORMAL.
469 int GetFSM(int argc, char **argv)
473 argv[1] = canonicalize_hostname(strsave(argv[1]));
474 top = GetFSInfo(MACHINE, argv[1]); /* get info. */
475 Loop(top, PrintFSInfo);
476 FreeQueue(top); /* clean the queue. */
480 /* Function Name: RealDeleteFS
481 * Description: Does the real deletion work.
482 * Arguments: info - array of char *'s containing all useful info.
483 * one_item - a Boolean that is true if only one item
484 * in queue that dumped us here.
488 void RealDeleteFS(char **info, Bool one_item)
491 char temp_buf[BUFSIZ];
494 * Deletions are performed if the user hits 'y' on a list of multiple
495 * filesystem, or if the user confirms on a unique alias.
497 sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
499 if (!one_item || Confirm(temp_buf))
501 if ((stat = do_mr_query("delete_filesys", 1,
502 &info[FS_NAME], Scream, NULL)))
503 com_err(program_name, stat, " filesystem not deleted.");
505 Put_message("Filesystem deleted.");
508 Put_message("Filesystem not deleted.");
511 /* Function Name: DeleteFS
512 * Description: Delete a filesystem give its name.
513 * Arguments: argc, argv - argv[1] is the name of the filesystem.
517 int DeleteFS(int argc, char **argv)
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.
533 static void RealChangeFS(char **info, Bool junk)
537 extern Menu nfsphys_menu;
539 args = AskFSInfo(info, TRUE);
542 Put_message("Aborted.");
545 stat = do_mr_query("update_filesys", CountArgs(args), args, NullFunc, NULL);
549 Put_message("That NFS filesystem is not exported.");
550 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) == 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.
576 int ChangeFS(int argc, char **argv)
578 struct qelem *elem = GetFSInfo(LABEL, argv[1]);
579 QueryLoop(elem, NullPrint, RealChangeFS, "Update the Filesystem");
585 /* Function Name: AddFS
586 * Description: change the information in a filesys record.
587 * Arguments: arc, argv - name of filsys in argv[1].
588 * Returns: DM_NORMAL.
591 int AddFS(int argc, char **argv)
593 char *info[MAX_ARGS_SIZE], **args, buf[BUFSIZ];
595 extern Menu nfsphys_menu;
597 if (!ValidName(argv[1]))
600 if (!(stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
603 Put_message ("A Filesystem by that name already exists.");
606 else if (stat != MR_NO_MATCH)
608 com_err(program_name, stat, " in AddFS");
612 if (!(args = AskFSInfo(SetDefaults(info, argv[1]), FALSE)))
614 Put_message("Aborted.");
618 stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
622 Put_message("That NFS filesystem is not exported.");
623 if (YesNoQuestion("Fix this now (Y/N)", TRUE) == TRUE)
625 Do_menu(&nfsphys_menu, 0, NULL);
626 if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
628 if ((stat = do_mr_query("add_filesys", CountArgs(args), args,
630 com_err(program_name, stat, " in AddFS");
632 Put_message("Created.");
639 com_err(program_name, stat, " in AddFS");
642 if (stat == MR_SUCCESS && !strcasecmp(info[FS_L_TYPE], "HOMEDIR"))
644 static char *val[] = {"def_quota", NULL};
645 static char *def_quota = NULL;
646 char *argv[Q_QUOTA + 1];
647 struct qelem *top = 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");
658 def_quota = Strsave(((char **)top->q_data)[0]);
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)
668 argv[Q_NAME] = argv[Q_FILESYS] = info[FS_NAME];
669 if (!strcmp(info[FS_TYPE], "NFS"))
670 argv[Q_TYPE] = "USER";
672 argv[Q_TYPE] = "ANY";
673 argv[Q_QUOTA] = def_quota;
674 if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, Scream,
676 com_err(program_name, stat, " while adding quota");
680 else if (stat == MR_SUCCESS)
682 if (YesNoQuestion("Assign a quota on this filesystem (Y/N)", 1) == TRUE)
685 parsed_argv[0] = info[FS_NAME];
694 /* Function Name: SortAfter
695 * Description: choose a sortkey to cause an item to be added after
696 * the count element in the queue
697 * Arguments: queue of filesys names & sortkeys, queue count pointer
698 * Returns: sort key to use.
701 char *SortAfter(struct qelem *elem, int count)
703 char *prev, *next, prevnext, *key, keybuf[9];
705 /* first find the two keys we need to insert between */
707 for (; count > 0; count--)
709 prev = ((char **)elem->q_data)[1];
718 next = ((char **)elem->q_data)[1];
720 /* now copy the matching characters */
721 for (key = keybuf; *prev && *prev == *next; next++)
724 /* and set the last character */
726 *prev = prevnext = 'A';
733 if (*next - *prev > 1)
734 *key++ = (*next + *prev) / 2;
738 *key++ = (prevnext + 'Z') / 2;
741 return Strsave(keybuf);
744 /* Function Name: AddFSToGroup
745 * Description: add a filesystem to an FS group
746 * Arguments: arc, argv - name of group in argv[1], filesys in argv[2].
747 * Returns: DM_NORMAL.
750 int AddFSToGroup(int argc, char **argv)
753 struct qelem *elem = NULL;
754 char buf[BUFSIZ], *args[5], *bufp;
756 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
759 if (stat != MR_NO_MATCH)
760 com_err(program_name, stat, " in AddFSToGroup");
767 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
769 com_err(program_name, stat, " in AddFSToGroup");
772 elem = QueueTop(elem);
774 Loop(elem, PrintFSGMembers);
775 sprintf(buf, "%d", QueueCount(elem));
777 if (GetValueFromUser("Enter number of filesystem it should follow "
778 "(0 to make it first):", &bufp) == SUB_ERROR)
782 args[2] = SortAfter(elem, count);
784 FreeQueue(QueueTop(elem));
787 stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
788 if (stat == MR_EXISTS)
790 Put_message("That filesystem is already a member of the group.");
791 Put_message("Use the order command if you want to change the "
795 com_err(program_name, stat, " in AddFSToGroup");
800 /* Function Name: RemoveFSFromGroup
801 * Description: delete a filesystem from an FS group
802 * Arguments: arc, argv - name of group in argv[1].
803 * Returns: DM_NORMAL.
806 int RemoveFSFromGroup(int argc, char **argv)
811 sprintf(buf, "Delete filesystem %s from FS group %s", argv[2], argv[1]);
814 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv + 1,
816 com_err(program_name, stat, ", not removed.");
820 /* Function Name: ChangeFSGroupOrder
821 * Description: change the sortkey on a filesys in an FSgroup
822 * Arguments: arc, argv - name of group in argv[1].
823 * Returns: DM_NORMAL.
826 int ChangeFSGroupOrder(int argc, char **argv)
828 int stat, src, dst, i;
829 struct qelem *elem = NULL, *top, *tmpelem;
830 char buf[BUFSIZ], *bufp, *args[3];
832 if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
835 if (stat == MR_NO_MATCH)
838 "Ether %s is not a filesystem group or it has no members",
843 com_err(program_name, stat, " in ChangeFSGroupOrder");
846 top = QueueTop(elem);
848 Loop(top, PrintFSGMembers);
852 if (GetValueFromUser("Enter number of the filesystem to move:",
859 Put_message("You must enter a positive number (or 0 to abort).");
864 Put_message("Aborted.");
867 for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw)
871 Put_message("You entered a number that is too high");
879 if (GetValueFromUser("Enter number of filesystem it should follow "
880 "(0 to make it first):", &bufp) == SUB_ERROR)
884 if (src == dst || src == dst + 1)
886 Put_message("That has no effect on the sorting order!");
891 Put_message("You must enter a non-negative number.");
894 for (tmpelem = top, i = dst; i-- > 1 && tmpelem->q_forw;
895 tmpelem = tmpelem->q_forw)
899 Put_message("You entered a number that is too high");
904 args[2] = SortAfter(top, dst);
906 args[1] = ((char **)elem->q_data)[0];
907 if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
910 com_err(program_name, stat, " in ChangeFSGroupOrder");
913 if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
915 com_err(program_name, stat, " in ChangeFSGroupOrder");
920 /* -------------- Top Level Menu ---------------- */
922 /* Function Name: GetFSAlias
923 * Description: Gets the value for a Filesystem Alias.
924 * Arguments: argc, argv - name of alias in argv[1].
925 * Returns: DM_NORMAL.
926 * NOTES: There should only be one filesystem per alias, thus
927 * this will work correctly.
930 int GetFSAlias(int argc, char **argv)
934 top = GetFSInfo(ALIAS, argv[1]);
935 Put_message(" "); /* blank line. */
936 Loop(top, (void *) PrintFSAlias);
941 /* Function Name: CreateFSAlias
942 * Description: Create an alias name for a filesystem
943 * Arguments: argc, argv - name of alias in argv[1].
944 * Returns: DM_NORMAL.
945 * NOTES: This requires (name, type, transl) I get {name, translation}
946 * from the user. I provide type, which is well-known.
949 int CreateFSAlias(int argc, char **argv)
952 struct qelem *elem, *top;
953 char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
957 if (!ValidName(argv[1]))
960 args[ALIAS_NAME] = Strsave(argv[1]);
961 args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
962 args[ALIAS_TRANS] = Strsave("*");
965 * Check to see if this alias already exists in the database, if so then
966 * print out values, free memory used and then exit.
969 if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo,
972 top = elem = QueueTop(elem);
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)
986 com_err(program_name, stat, " in CreateFSAlias.");
990 args[ALIAS_TRANS] = Strsave("");
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, NullFunc, 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),
1026 info, Scream, NULL)))
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 qelem *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(void)
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);