[4679] in Athena Bugs
venus/fs.c: patch correction
daemon@ATHENA.MIT.EDU (Richard Basch)
Tue Apr 3 18:40:00 1990
Date: Tue, 3 Apr 90 18:39:29 -0400
To: afsbugs+@TRANSARC.COM
Cc: bugs@ATHENA.MIT.EDU, bug-afs@MIT.EDU
From: Richard Basch <probe@MIT.EDU>
I neglected to #include <strings.h> after using the index() function [I
only discovered this after trying to compile on the RT platform; the VAX
lets you get away with murder].
Here is the original patch description followed by a new patch:
Enclosed are several fixes to venus/fs.c:
- It is possible to get extraneous sites listed for a volume if multiple
volumes are specified and one of the earlier volumes had several
sites. The problem is a missing bzero(). [I sent this patch a couple
days ago].
- I also reported a while ago that "fs" doesn't check for volumes in the
cell where the mountpoint is being created. For instance, if I am
a client in the "athena.mit.edu" cell and create a mountpoint for a
volume in the "rel-eng.athena.mit.edu" cell, it still checks for the
volume in the "athena.mit.edu" cell. You will see from my patch that
there were actually several tests that were missing.
Enjoy,
-Richard
RCS file: venus/RCS/fs.c,v
retrieving revision 1.43
diff -c -r1.43 venus/fs.c
*** /tmp/,RCSt1018484 Tue Apr 3 18:37:28 1990
--- venus/fs.c Tue Apr 3 18:37:02 1990
***************
*** 14,19 ****
--- 14,20 ----
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
+ #include <strings.h>
#include <netinet/in.h>
#include <sys/stat.h>
#undef VIRTUE
***************
*** 789,794 ****
--- 790,796 ----
blob.out_size = MAXSIZE;
blob.in_size = 0;
blob.out = space;
+ bzero(space, sizeof(space));
code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
if (code) {
Die(code, ti->data);
***************
*** 987,994 ****
static MakeMountCmd(as)
register struct cmd_syndesc *as; {
register long code;
! register char *cellName, *volName;
struct vldbentry vldbEntry;
if (as->parms[5].items && !as->parms[2].items) {
printf("fs: must provide cell when creating cellular mount point.\n");
--- 989,997 ----
static MakeMountCmd(as)
register struct cmd_syndesc *as; {
register long code;
! register char *cellName, *volName, *tmpName;
struct vldbentry vldbEntry;
+ struct ViceIoctl blob;
if (as->parms[5].items && !as->parms[2].items) {
printf("fs: must provide cell when creating cellular mount point.\n");
***************
*** 1001,1006 ****
--- 1004,1023 ----
cellName = (char *) 0;
volName = as->parms[1].items->data;
+ /* Check for a cellname in the volume specification, and complain
+ * if it doesn't match what was specified with -cell */
+ if (tmpName = index(volName, ':')) {
+ *tmpName = '\0';
+ if (cellName) {
+ if (strcasecmp(cellName,volName)) {
+ printf("fs: cellnames do not match.\n");
+ return 1;
+ }
+ }
+ cellName = volName;
+ volName = ++tmpName;
+ }
+
if (!InAFS(Parent(as->parms[0].items->data))) {
printf("fs: mount points must be created within the AFS file system\n");
return 1;
***************
*** 1007,1014 ****
}
if (!(as->parms[4].items)) {
/* not fast, check name with VLDB */
! code = VLDBInit(1, AFSCONF_CLIENTNAME, cellName);
if (code == 0) {
/* make the check. Don't complain if there are problems with init */
code = ubik_Call(VL_GetEntryByName, uclient, 0, volName, &vldbEntry);
--- 1024,1042 ----
}
if (!(as->parms[4].items)) {
+ /* not fast, check which cell the mountpoint is being created in */
+ code = 0;
+ if (!cellName) {
+ blob.in_size = 0;
+ blob.out_size = MAXSIZE;
+ blob.out = space;
+ code = pioctl(Parent(as->parms[0].items->data),
+ VIOC_FILE_CELL_NAME, &blob, 1);
+ }
+
/* not fast, check name with VLDB */
! if (!code)
! code = VLDBInit(1, AFSCONF_CLIENTNAME, cellName?cellName:space);
if (code == 0) {
/* make the check. Don't complain if there are problems with init */
code = ubik_Call(VL_GetEntryByName, uclient, 0, volName, &vldbEntry);
***************
*** 1024,1032 ****
strcpy(space, "%");
else
strcpy(space, "#");
! if (as->parms[5].items) { /* parms[2] alrady checked for existence above */
/* cellular mount point, prepend cell prefix */
! strcat(space, as->parms[2].items->data);
strcat(space, ":");
}
strcat(space, volName); /* append volume name */
--- 1052,1060 ----
strcpy(space, "%");
else
strcpy(space, "#");
! if (cellName) {
/* cellular mount point, prepend cell prefix */
! strcat(space, cellName);
strcat(space, ":");
}
strcat(space, volName); /* append volume name */