[1614] in Moira
better support for fs aliases
daemon@ATHENA.MIT.EDU (Nickolai Zeldovich)
Tue Aug 1 18:50:57 2000
Message-Id: <200008012250.SAA17221@home-on-the-dome.mit.edu>
To: moiradev@MIT.EDU
Date: Tue, 01 Aug 2000 18:50:49 -0400
From: Nickolai Zeldovich <kolya@MIT.EDU>
Here's a patch which adds better support for filesystem aliases in
the moira client -- it lists aliases along with other filesystem
information, and checks for aliases when a filesystem is looked up
by name.
The static buffers are a little bit ugly, but we already do that
with host aliases, and breaking mqelem abstractions doesn't look
like a much better choice.
-- kolya
Index: clients/moira/attach.c
===================================================================
RCS file: /mit/moiradev/repository/moira/clients/moira/attach.c,v
retrieving revision 1.49
diff -c -r1.49 attach.c
*** attach.c 2000/03/15 22:44:02 1.49
--- attach.c 2000/08/01 22:39:49
***************
*** 46,51 ****
--- 46,53 ----
#define MACHINE 1
#define GROUP 2
#define ALIAS 3
+ #define ALIAS_CHECK 4
+ #define FS_ALIASES 5
#define NO_MACHINE ("[NONE]")
***************
*** 126,139 ****
}
break;
case ALIAS:
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.");
return NULL;
}
}
return QueueTop(elem);
--- 128,155 ----
}
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)))
{
! 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,160 ****
--- 171,196 ----
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,181 ****
--- 212,218 ----
static char *PrintFSInfo(char **info)
{
char print_buf[BUFSIZ];
+ struct mqelem *top;
FORMFEED;
***************
*** 190,195 ****
--- 227,240 ----
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,220 ****
--- 260,274 ----
{
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,466 ****
int GetFS(int argc, char **argv)
{
struct mqelem *top;
! top = GetFSInfo(LABEL, argv[1]); /* get info. */
Loop(top, (void (*)(char **))PrintFSInfo);
FreeQueue(top); /* clean the queue. */
return DM_NORMAL;
--- 513,529 ----
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, fs_label); /* get info. */
Loop(top, (void (*)(char **))PrintFSInfo);
FreeQueue(top); /* clean the queue. */
return DM_NORMAL;
Index: clients/moira/menus.c
===================================================================
RCS file: /mit/moiradev/repository/moira/clients/moira/menus.c,v
retrieving revision 1.41
diff -c -r1.41 menus.c
*** menus.c 2000/03/30 21:59:53 1.41
--- menus.c 2000/08/01 21:59:08
***************
*** 375,389 ****
SUBMENU("fsgroups", "File System Groups Menu", &fsgroup_menu),
{ GetFSAlias, NULLMENU, 2, {
{"check", "Check An Association"},
! {"name", "alias name : "}
} },
{ CreateFSAlias, NULLMENU, 2, {
{"alias", "Associate with a Filesystem"},
! {"name", "alias name : "},
} },
{ DeleteFSAlias, NULLMENU, 2, {
{"unalias", "Disassociate from a Filesystem"},
! {"name", "alias name : "},
} },
SUBMENU("quotas", "Quota Menu", "a_menu),
/* SIMPLEFUNC("verbose", "Toggle Verbosity of Delete", ToggleVerboseMode), */
--- 375,389 ----
SUBMENU("fsgroups", "File System Groups Menu", &fsgroup_menu),
{ GetFSAlias, NULLMENU, 2, {
{"check", "Check An Association"},
! {"name", "Alias name: "}
} },
{ CreateFSAlias, NULLMENU, 2, {
{"alias", "Associate with a Filesystem"},
! {"name", "Alias name: "},
} },
{ DeleteFSAlias, NULLMENU, 2, {
{"unalias", "Disassociate from a Filesystem"},
! {"name", "Alias name: "},
} },
SUBMENU("quotas", "Quota Menu", "a_menu),
/* SIMPLEFUNC("verbose", "Toggle Verbosity of Delete", ToggleVerboseMode), */