]> andersk Git - moira.git/commitdiff
from kolya: implement better client support for filesystem aliases.
authorzacheiss <zacheiss>
Thu, 3 Aug 2000 21:49:13 +0000 (21:49 +0000)
committerzacheiss <zacheiss>
Thu, 3 Aug 2000 21:49:13 +0000 (21:49 +0000)
clients/moira/attach.c
clients/moira/menus.c

index 715ab681087f372fd3b19152c5dd3faf6fbf7ba8..5fb6d1133a4b0b14c4616ce904329c73d0df7506 100644 (file)
@@ -46,6 +46,8 @@ void RealDeleteFSAlias(char **info, Bool one_item);
 #define MACHINE      1
 #define GROUP        2
 #define ALIAS        3
+#define ALIAS_CHECK  4
+#define FS_ALIASES   5
 
 #define NO_MACHINE      ("[NONE]")
 
@@ -126,14 +128,28 @@ static struct mqelem *GetFSInfo(int type, char *name)
        }
       break;
     case ALIAS:
+    case ALIAS_CHECK:
       args[ALIAS_NAME] = name;
       args[ALIAS_TYPE] = FS_ALIAS_TYPE;
       args[ALIAS_TRANS] = "*";
       if ((stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
        {
-         com_err(program_name, stat, " in get_alias.");
+         if (type != ALIAS_CHECK || stat != MR_NO_MATCH)
+           com_err(program_name, stat, " in get_alias.");
          return NULL;
        }
+      break;
+    case FS_ALIASES:
+      args[ALIAS_NAME] = "*";
+      args[ALIAS_TYPE] = FS_ALIAS_TYPE;
+      args[ALIAS_TRANS] = name;
+      if ((stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
+       {
+         if (stat != MR_NO_MATCH)
+           com_err(program_name, stat, " in get_alias.");
+         return NULL;
+       }
+      break;
     }
 
   return QueueTop(elem);
@@ -155,6 +171,26 @@ static char *PrintFSAlias(char **info)
   return info[ALIAS_NAME];
 }
 
+static char aliasbuf[256];
+
+static char *PrintFSAliasList(char **info)
+{
+  if (strlen(aliasbuf) == 0)
+    snprintf(aliasbuf, sizeof(aliasbuf), "Aliases: %s", info[ALIAS_NAME]);
+  else
+    {
+      strncat(aliasbuf, ", ", sizeof(aliasbuf));
+      strncat(aliasbuf, info[ALIAS_NAME], sizeof(aliasbuf));
+    }
+}
+
+static char labelbuf[256];
+
+static char *GetFSLabel(char **info)
+{
+  snprintf(labelbuf, sizeof(labelbuf), info[ALIAS_TRANS]);
+}
+
 static int fsgCount = 1;
 
 static void PrintFSGMembers(char **info)
@@ -176,6 +212,7 @@ static void PrintFSGMembers(char **info)
 static char *PrintFSInfo(char **info)
 {
   char print_buf[BUFSIZ];
+  struct mqelem *top;
 
   FORMFEED;
 
@@ -190,6 +227,14 @@ static char *PrintFSInfo(char **info)
        sprintf(print_buf, "%20s Filesystem Group: %s", " ", info[FS_NAME]);
       Put_message(print_buf);
 
+      top = GetFSInfo(FS_ALIASES, info[FS_NAME]);
+      if (top != NULL) {
+       *aliasbuf = 0;
+       Loop(top, (void (*)(char **))PrintFSAliasList);
+       Put_message(aliasbuf);
+       FreeQueue(top);         /* clean the queue. */
+      }
+
       sprintf(print_buf, "Comments: %s", info[FS_COMMENTS]);
       Put_message(print_buf);
       sprintf(print_buf, MOD_FORMAT, info[FS_MODBY], info[FS_MODTIME],
@@ -215,6 +260,15 @@ static char *PrintFSInfo(char **info)
     {
       sprintf(print_buf, "%20s Filesystem: %s", " ", info[FS_NAME]);
       Put_message(print_buf);
+
+      top = GetFSInfo(FS_ALIASES, info[FS_NAME]);
+      if (top != NULL) {
+       *aliasbuf = 0;
+       Loop(top, (void (*)(char **))PrintFSAliasList);
+       Put_message(aliasbuf);
+       FreeQueue(top);         /* clean the queue. */
+      }
+
       sprintf(print_buf, "Type: %-40s Machine: %-15s",
              info[FS_TYPE], info[FS_MACHINE]);
       Put_message(print_buf);
@@ -459,8 +513,17 @@ static char **AskFSInfo(char **info, Bool name)
 int GetFS(int argc, char **argv)
 {
   struct mqelem *top;
+  char *fs_label;
+
+  fs_label = argv[1];
+
+  top = GetFSInfo(ALIAS_CHECK, argv[1]);
+  if (top != NULL) {
+    Loop(top, (void (*)(char **))GetFSLabel);
+    fs_label = labelbuf;
+  }
 
-  top = GetFSInfo(LABEL, argv[1]); /* get info. */
+  top = GetFSInfo(LABEL, fs_label); /* get info. */
   Loop(top, (void (*)(char **))PrintFSInfo);
   FreeQueue(top);              /* clean the queue. */
   return DM_NORMAL;
index 9e1749515246b48e034ae378b27785508d18137d..38cc92372aa2fc1464f36b47b97b5e0f76f12b44 100644 (file)
@@ -375,15 +375,15 @@ Menu filesys_menu = {
     SUBMENU("fsgroups", "File System Groups Menu", &fsgroup_menu),
     { GetFSAlias, NULLMENU, 2, {
       {"check", "Check An Association"},
-      {"name", "alias name : "}
+      {"name", "Alias name: "}
     } },
     { CreateFSAlias, NULLMENU, 2, {
       {"alias", "Associate with a Filesystem"},
-      {"name", "alias name : "},
+      {"name", "Alias name: "},
     } },
     { DeleteFSAlias, NULLMENU, 2, {
       {"unalias", "Disassociate from a Filesystem"},
-      {"name", "alias name : "},
+      {"name", "Alias name: "},
     } },
     SUBMENU("quotas", "Quota Menu", &quota_menu),
 /*    SIMPLEFUNC("verbose", "Toggle Verbosity of Delete", ToggleVerboseMode), */
This page took 0.042523 seconds and 5 git commands to generate.