gcc-warnings-cleanup-20030701
[openafs.git] / src / venus / fs.c
index dd50ac0..18ac2a1 100644 (file)
@@ -27,6 +27,15 @@ RCSID("$Header$");
 #ifdef AFS_AIX32_ENV
 #include <signal.h>
 #endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+
 #undef VIRTUE
 #undef VICE
 #include "afs/prs_fs.h"
@@ -40,7 +49,6 @@ RCSID("$Header$");
 #include <afs/volser.h>
 #include <afs/vlserver.h>
 #include <afs/cmd.h>
-#include <strings.h>
 #include <afs/afsutil.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -64,9 +72,8 @@ static int RxStatProcCmd(), RxStatPeerCmd();
 
 extern char *hostutil_GetNameByINet();
 extern struct hostent *hostutil_GetHostByName();
-extern afs_int32 VL_GetEntryByNameO();
 
-extern int errno;
+
 extern struct cmd_syndesc *cmd_CreateSyntax();
 static char pn[] = "fs";
 static int rxInitDone = 0;
@@ -165,9 +172,8 @@ static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
  * Determine whether either the -id or -if switches are present, and
  * return 0, 1 or 2, as appropriate. Abort if both switches are present.
  */
-static int getidf(as, id)
-    struct cmd_syndesc *as;
-    int id;    /* Offset of -id switch; -if is next switch */
+/*    int id;  Offset of -id switch; -if is next switch */
+static int getidf(struct cmd_syndesc *as, int id)
 {
     int idf = 0;
 
@@ -187,9 +193,7 @@ static int getidf(as, id)
     return idf;
 }
 
-static int PRights(arights, dfs)
-    afs_int32 arights;
-    int dfs;
+static int PRights(afs_int32 arights, int dfs)
 {
     if (!dfs) {
        if (arights & PRSFS_READ) printf("r");
@@ -227,8 +231,7 @@ static int PRights(arights, dfs)
 }
 
 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
-static int InAFS(apath)
-    char *apath;
+static int InAFS(char *apath)
 {
     struct ViceIoctl blob;
     afs_int32 code;
@@ -245,12 +248,11 @@ static int InAFS(apath)
 }
 
 /* return a static pointer to a buffer */
-static char *Parent(apath)
-    char *apath;
+static char *Parent(char *apath)
 {
     char *tp;
     strcpy(tspace, apath);
-    tp = rindex(tspace, '/');
+    tp = strrchr(tspace, '/');
     if (tp) {
        *tp = 0;
     }
@@ -260,10 +262,7 @@ static char *Parent(apath)
 
 enum rtype {add, destroy, deny};
 
-static afs_int32 Convert(arights, dfs, rtypep)
-    char *arights;
-    int dfs;
-    enum rtype *rtypep;
+static afs_int32 Convert(char *arights, int dfs, enum rtype *rtypep)
 {
     int i, len;
     afs_int32 mode;
@@ -338,9 +337,7 @@ static afs_int32 Convert(arights, dfs, rtypep)
     return mode;
 }
 
-static struct AclEntry *FindList(alist, aname)
-    struct AclEntry *alist;
-    char *aname;
+static struct AclEntry *FindList(struct AclEntry *alist, char *aname)
 {
     while (alist) {
         if (!foldcmp(alist->name, aname)) return alist;
@@ -350,8 +347,7 @@ static struct AclEntry *FindList(alist, aname)
 }
 
 /* if no parm specified in a particular slot, set parm to be "." instead */
-static void SetDotDefault(aitemp)
-    struct cmd_item **aitemp;
+static void SetDotDefault(struct cmd_item **aitemp)
 {
     struct cmd_item *ti;
     if (*aitemp) return;       /* already has value */
@@ -365,11 +361,7 @@ static void SetDotDefault(aitemp)
     *aitemp = ti;
 }
 
-static void ChangeList(al, plus, aname, arights)
-    struct Acl *al;
-    afs_int32 plus;
-    char *aname;
-    afs_int32 arights;
+static void ChangeList(struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights)
 {
     struct AclEntry *tlist;
     tlist = (plus ? al->pluslist : al->minuslist);
@@ -403,8 +395,7 @@ static void ChangeList(al, plus, aname, arights)
     }
 }
 
-static void ZapList(alist)
-    struct AclEntry *alist;
+static void ZapList(struct AclEntry *alist)
 {
     struct AclEntry *tp, *np;
     for (tp = alist; tp; tp = np) {
@@ -413,9 +404,7 @@ static void ZapList(alist)
     }
 }
 
-static int PruneList(ae, dfs)
-    struct AclEntry **ae;
-    int dfs;
+static int PruneList(struct AclEntry **ae, int dfs)
 {
     struct AclEntry **lp;
     struct AclEntry *te, *ne;
@@ -437,8 +426,7 @@ static int PruneList(ae, dfs)
     return ctr;
 }
 
-static char *SkipLine(astr)
-    char *astr;
+static char *SkipLine(char *astr)
 {
     while (*astr !='\n') astr++;
     astr++;
@@ -452,8 +440,7 @@ static char *SkipLine(astr)
  * assume that the acl is AFS: for DFS, the user can always resort to
  * acl_edit, but for AFS there may be no other way out).
  */
-static struct Acl *EmptyAcl(astr)
-    char *astr;
+static struct Acl *EmptyAcl(char *astr)
 {
     struct Acl *tp;
     int junk;
@@ -467,8 +454,7 @@ static struct Acl *EmptyAcl(astr)
     return tp;
 }
 
-static struct Acl *ParseAcl(astr)
-    char *astr;
+static struct Acl *ParseAcl(char *astr)
 {
     int nplus, nminus, i, trights;
     char tname[MAXNAME];
@@ -521,10 +507,7 @@ static struct Acl *ParseAcl(astr)
     return ta;
 }
 
-static PrintStatus(status, name, offmsg)
-    VolumeStatus *status;
-    char *name;
-    char *offmsg;
+static int PrintStatus(VolumeStatus *status, char *name, char *offmsg)
 {
     printf("Volume status for vid = %u named %s\n",status->Vid, name);
     if (*offmsg != 0)
@@ -534,11 +517,10 @@ static PrintStatus(status, name, offmsg)
     else printf("unlimited\n");
     printf("Current blocks used are %d\n",status->BlocksInUse);
     printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
+    return 0;
 }
 
-static QuickPrintStatus(status, name)
-    VolumeStatus *status;
-    char *name;
+static int QuickPrintStatus(VolumeStatus *status, char *name)
 {
     double QuotaUsed =0.0;
     double PartUsed =0.0;
@@ -566,11 +548,10 @@ static QuickPrintStatus(status, name)
        printf("  <<WARNING\n");
     }
     else printf("\n");
+    return 0;
 }
 
-static QuickPrintSpace(status, name)
-    VolumeStatus *status;
-    char *name;
+static int QuickPrintSpace(VolumeStatus *status, char *name)
 {
     double PartUsed =0.0;
     int WARN = 0;
@@ -588,10 +569,10 @@ static QuickPrintSpace(status, name)
        printf("  <<WARNING\n");
     }
     else printf("\n");
+    return 0;
 }
 
-static char *AclToString(acl)
-    struct Acl *acl;
+static char *AclToString(struct Acl *acl)
 {
     static char mydata[MAXSIZE];
     char tstring[MAXSIZE];
@@ -612,8 +593,7 @@ static char *AclToString(acl)
     return mydata;
 }
 
-static SetACLCmd(as)
-    struct cmd_syndesc *as;
+static int SetACLCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -731,8 +711,7 @@ static SetACLCmd(as)
 }
 
 
-static CopyACLCmd(as)
-    struct cmd_syndesc *as;
+static int CopyACLCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -810,8 +789,7 @@ static CopyACLCmd(as)
 }
 
 /* pioctl() call to get the cellname of a pathname */
-static afs_int32 GetCell(fname, cellname)
-  char *fname, *cellname;
+static afs_int32 GetCell(char *fname, char *cellname)
 {
   afs_int32 code;
   struct ViceIoctl blob;
@@ -828,8 +806,7 @@ static afs_int32 GetCell(fname, cellname)
  * negative sign), then it might be bad. We then query the ptserver
  * to see.
  */
-static BadName(aname, fname)
-    char *aname, *fname;
+static BadName(char *aname, char *fname)
 {
     afs_int32  tc, code, id;
     char   *nm;
@@ -855,9 +832,7 @@ static BadName(aname, fname)
 
 /* clean up an access control list of its bad entries; return 1 if we made
    any changes to the list, and 0 otherwise */
-static CleanAcl(aa, fname)
-    struct Acl *aa;
-    char *fname;     /* The file name */
+static CleanAcl(struct Acl *aa, char *fname)
 {
     struct AclEntry *te, **le, *ne;
     int changes;
@@ -901,8 +876,7 @@ static CleanAcl(aa, fname)
 
 
 /* clean up an acl to not have bogus entries */
-static CleanACLCmd(as)
-    struct cmd_syndesc *as;
+static int CleanACLCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct Acl *ta = 0;
@@ -982,8 +956,7 @@ static CleanACLCmd(as)
     return error;
 }
 
-static ListACLCmd(as)
-    struct cmd_syndesc *as;
+static int ListACLCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct Acl *ta;
@@ -1044,8 +1017,7 @@ static ListACLCmd(as)
     return error;
 }
 
-static FlushVolumeCmd(as)
-    struct cmd_syndesc *as;
+static int FlushVolumeCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1066,8 +1038,7 @@ static FlushVolumeCmd(as)
     return error;
 }
 
-static FlushCmd(as)
-    struct cmd_syndesc *as;
+static int FlushCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1093,18 +1064,16 @@ static FlushCmd(as)
 }
 
 /* all this command does is repackage its args and call SetVolCmd */
-static SetQuotaCmd(as)
-    struct cmd_syndesc *as;
+static int SetQuotaCmd(struct cmd_syndesc *as)
 {
     struct cmd_syndesc ts;
 
     /* copy useful stuff from our command slot; we may later have to reorder */
-    bcopy(as, &ts, sizeof(ts));        /* copy whole thing */
+    memcpy(&ts, as, sizeof(ts));       /* copy whole thing */
     return SetVolCmd(&ts);
 }
 
-static SetVolCmd(as)
-    struct cmd_syndesc *as;
+static int SetVolCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1122,7 +1091,7 @@ static SetVolCmd(as)
        blob.in = space;
        status = (VolumeStatus *)space;
        status->MinQuota = status->MaxQuota = -1;
-        offmsg = (char *) 0;
+        offmsg = NULL;
        if (as->parms[1].items) {
            code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
            if (code) {
@@ -1156,8 +1125,7 @@ static SetVolCmd(as)
     return error;
 }
 
-static ExamineCmd(as)
-    struct cmd_syndesc *as;
+static int ExamineCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1186,8 +1154,7 @@ static ExamineCmd(as)
     return error;
 }
 
-static ListQuotaCmd(as)
-    struct cmd_syndesc *as;
+static int ListQuotaCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1217,8 +1184,7 @@ static ListQuotaCmd(as)
     return error;
 }
 
-static WhereIsCmd(as)
-    struct cmd_syndesc *as;
+static int WhereIsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1234,7 +1200,7 @@ static WhereIsCmd(as)
        blob.out_size = MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
-       bzero(space, sizeof(space));
+       memset(space, 0, sizeof(space));
        code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
        if (code) {
            Die(errno, ti->data);
@@ -1254,8 +1220,7 @@ static WhereIsCmd(as)
 }
 
 
-static DiskFreeCmd(as)
-    struct cmd_syndesc *as;
+static int DiskFreeCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1285,8 +1250,7 @@ static DiskFreeCmd(as)
     return error;
 }
 
-static QuotaCmd(as)
-    struct cmd_syndesc *as;
+static int QuotaCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1315,8 +1279,7 @@ static QuotaCmd(as)
     return error;
 }
 
-static ListMountCmd(as)
-    struct cmd_syndesc *as;
+static int ListMountCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1373,7 +1336,7 @@ static ListMountCmd(as)
             * name (we know there is one) and splice in the symlink value.
             */
            if (true_name[0] != '/') {
-               last_component = (char *) rindex(orig_name, '/');
+               last_component = (char *) strrchr(orig_name, '/');
                strcpy(++last_component, true_name);
                strcpy(true_name, orig_name);
            }
@@ -1384,7 +1347,7 @@ static ListMountCmd(as)
        /*
         * Find rightmost slash, if any.
         */
-       last_component = (char *) rindex(true_name, '/');
+       last_component = (char *) strrchr(true_name, '/');
        if (last_component) {
            /*
             * Found it.  Designate everything before it as the parent directory,
@@ -1414,7 +1377,7 @@ static ListMountCmd(as)
        blob.in_size = strlen(last_component)+1;
        blob.out_size = MAXSIZE;
        blob.out = space;
-       bzero(space, MAXSIZE);
+       memset(space, 0, MAXSIZE);
 
        code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
 
@@ -1438,8 +1401,7 @@ static ListMountCmd(as)
     return error;
 }
 
-static MakeMountCmd(as)
-    struct cmd_syndesc *as;
+static MakeMountCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     char *cellName, *volName, *tmpName;
@@ -1460,7 +1422,7 @@ defect #3069
     if (as->parms[2].items)    /* cell name specified */
        cellName = as->parms[2].items->data;
     else
-       cellName = (char *) 0;
+       cellName = NULL;
     volName = as->parms[1].items->data;
 
     if (strlen(volName) >= 64) {
@@ -1470,7 +1432,7 @@ defect #3069
 
     /* Check for a cellname in the volume specification, and complain
      * if it doesn't match what was specified with -cell */
-    if (tmpName = index(volName, ':')) {
+    if (tmpName = strchr(volName, ':')) {
        *tmpName = '\0';
        if (cellName) {
            if (strcasecmp(cellName,volName)) {
@@ -1537,8 +1499,7 @@ defect #3069
  *         (or ``.'' if none is provided)
  *      tp: Set to point to the actual name of the mount point to nuke.
  */
-static RemoveMountCmd(as)
-    struct cmd_syndesc *as;
+static int RemoveMountCmd(struct cmd_syndesc *as)
 {
     afs_int32 code=0;
     struct ViceIoctl blob;
@@ -1550,7 +1511,7 @@ static RemoveMountCmd(as)
 
     for(ti=as->parms[0].items; ti; ti=ti->next) {
        /* once per file */
-       tp = (char *) rindex(ti->data, '/');
+       tp = (char *) strrchr(ti->data, '/');
        if (tp) {
            strncpy(tbuffer, ti->data, code=tp-ti->data);  /* the dir name */
            tbuffer[code] = 0;
@@ -1590,8 +1551,7 @@ static RemoveMountCmd(as)
 /*
 */
 
-static CheckServersCmd(as)
-    struct cmd_syndesc *as;
+static int CheckServersCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1603,13 +1563,13 @@ static CheckServersCmd(as)
     struct afsconf_cell info;
     struct chservinfo checkserv;
 
-    bzero(&checkserv,sizeof(struct chservinfo));
+    memset(&checkserv, 0, sizeof(struct chservinfo));
     blob.in_size=sizeof(struct chservinfo);
     blob.in=(caddr_t)&checkserv;
 
     blob.out_size = MAXSIZE;
     blob.out = space;
-    bzero(space, sizeof(afs_int32));   /* so we assure zero when nothing is copied back */
+    memset(space, 0, sizeof(afs_int32));       /* so we assure zero when nothing is copied back */
 
     /* prepare flags for checkservers command */
     temp = 2;  /* default to checking local cell only */
@@ -1659,7 +1619,7 @@ static CheckServersCmd(as)
        Die(errno, 0);
        return 1;
     }
-    bcopy(space, &temp, sizeof(afs_int32));
+    memcpy(&temp, space, sizeof(afs_int32));
     if (checkserv.tinterval >= 0) {
        if (checkserv.tinterval > 0)
            printf("The new down server probe interval (%d secs) is now in effect (old interval was %d secs)\n",
@@ -1674,7 +1634,7 @@ static CheckServersCmd(as)
     else {
        printf("These servers unavailable due to network or server problems: ");
        for(j=0; ; j++) {
-           bcopy(space + j*sizeof(afs_int32), &temp, sizeof(afs_int32));
+           memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
            if (temp == 0) break;
            tp = hostutil_GetNameByINet(temp);
            printf(" %s", tp);
@@ -1685,8 +1645,7 @@ static CheckServersCmd(as)
     return code;
 }
 
-static MessagesCmd(as)
-    struct cmd_syndesc *as;
+static int MessagesCmd(struct cmd_syndesc *as)
 {
     afs_int32 code=0;
     struct ViceIoctl blob;
@@ -1695,12 +1654,12 @@ static MessagesCmd(as)
     struct gaginfo gagflags;
     struct cmd_item *show;
 
-    bzero (&gagflags, sizeof(struct gaginfo));
+    memset(&gagflags, 0, sizeof(struct gaginfo));
     blob.in_size = sizeof(struct gaginfo);
     blob.in = (caddr_t) &gagflags;
     blob.out_size = MAXSIZE;
     blob.out = space;
-    bzero(space, sizeof(afs_int32));   /* so we assure zero when nothing is copied back */
+    memset(space, 0, sizeof(afs_int32));       /* so we assure zero when nothing is copied back */
 
     if (show = as->parms[0].items) {
        if (!strcasecmp (show->data, "user"))
@@ -1731,8 +1690,7 @@ static MessagesCmd(as)
     return 0;
 }
 
-static CheckVolumesCmd(as)
-    struct cmd_syndesc *as;
+static int CheckVolumesCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1749,8 +1707,7 @@ static CheckVolumesCmd(as)
     return 0;
 }
 
-static SetCacheSizeCmd(as)
-    struct cmd_syndesc *as;
+static int SetCacheSizeCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1778,7 +1735,7 @@ static SetCacheSizeCmd(as)
            printf("'fs setcache' not allowed on memory cache based cache managers.\n");
        }
        else {
-           Die(errno, (char *) 0);
+           Die(errno, NULL);
        }
        return 1;
     }
@@ -1788,21 +1745,20 @@ static SetCacheSizeCmd(as)
 }
 
 #define MAXGCSIZE      16
-static GetCacheParmsCmd(as)
-    struct cmd_syndesc *as;
+static int GetCacheParmsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     afs_int32 parms[MAXGCSIZE];
 
     memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
-    blob.in = (char *) 0;
+    blob.in = NULL;
     blob.in_size = 0;
     blob.out_size = sizeof(parms);
     blob.out = (char *) parms;
     code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
     if (code) {
-       Die(errno, (char *) 0);
+       Die(errno, NULL);
        return 1;
     }
     printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
@@ -1812,8 +1768,7 @@ static GetCacheParmsCmd(as)
     return 0;
 }
 
-static ListCellsCmd(as)
-    struct cmd_syndesc *as;
+static int ListCellsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     afs_int32 i, j;
@@ -1826,7 +1781,7 @@ static ListCellsCmd(as)
 
     for(i=0;;i++) {
         tp = space;
-       bcopy(&i, tp, sizeof(afs_int32));
+       memcpy(tp, &i, sizeof(afs_int32));
        blob.out_size = MAXSIZE;
        blob.in_size = sizeof(afs_int32);
        blob.in = space;
@@ -1843,7 +1798,7 @@ static ListCellsCmd(as)
            afs_int32 addr;
            char *name, tbuffer[20];
 
-           bcopy(tp + j*sizeof(afs_int32), &addr, sizeof(afs_int32));
+           memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
            if (addr == 0) break;
 
            if (resolve) {
@@ -1863,8 +1818,35 @@ static ListCellsCmd(as)
     return 0;
 }
 
-static NewCellCmd(as)
-    struct cmd_syndesc *as;
+static int ListAliasesCmd(struct cmd_syndesc *as)
+{
+    afs_int32 code, i;
+    char *tp, *aliasName, *realName;
+    struct ViceIoctl blob;
+
+    for(i=0;;i++) {
+       tp = space;
+       memcpy(tp, &i, sizeof(afs_int32));
+       blob.out_size = MAXSIZE;
+       blob.in_size = sizeof(afs_int32);
+       blob.in = space;
+       blob.out = space;
+       code = pioctl(0, VIOC_GETALIAS, &blob, 1);
+       if (code < 0) {
+           if (errno == EDOM) break;   /* done with the list */
+           Die(errno, 0);
+           return 1;
+       }
+       tp = space;
+       aliasName = tp;
+       tp += strlen(aliasName) + 1;
+       realName = tp;
+       printf("Alias %s for cell %s\n", aliasName, realName);
+    }
+    return 0;
+}
+
+static int NewCellCmd(struct cmd_syndesc *as)
 {
     afs_int32 code, linkedstate=0, size=0, *lp;
     struct ViceIoctl blob;
@@ -1880,6 +1862,8 @@ static NewCellCmd(as)
      * MAXCELLHOSTS (8) servers. To determine which we are talking to,
      * do a GETCELL pioctl and pass it a magic number. If an array of
      * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
+     * If we get back EDOM, there are no cells in the kernel yet,
+     * and we'll assume a 3.5 client.
      */
     tp = space;
     lp = (afs_int32 *)tp;
@@ -1890,16 +1874,20 @@ static NewCellCmd(as)
     blob.in       = space;
     blob.out      = space;
     code = pioctl(0, VIOCGETCELL, &blob, 1);
-    if (code < 0) {
+    if (code < 0 && errno != EDOM) {
        Die(errno, 0);
        return 1;
     }
-    tp = space;
-    cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
-    scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
+    if (code < 1 && errno == EDOM) {
+       scount = MAXHOSTS;
+    } else {
+       tp = space;
+       cellname = tp + MAXCELLHOSTS*sizeof(afs_int32);
+       scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
+    }
 
     /* Now setup and do the NEWCELL pioctl call */
-    bzero(space, (scount+1) * sizeof(afs_int32));
+    memset(space, 0, (scount+1) * sizeof(afs_int32));
     tp = space;
     lp = (afs_int32 *)tp;
     *lp++ = 0x12345678;
@@ -1911,7 +1899,7 @@ static NewCellCmd(as)
                   pn, ti->data);
        }
        else {
-           bcopy(thp->h_addr, tp, sizeof(afs_int32));
+           memcpy(tp, thp->h_addr, sizeof(afs_int32));
            tp += sizeof(afs_int32);
        }
     }
@@ -1964,8 +1952,40 @@ static NewCellCmd(as)
     return 0;
 }
 
-static WhichCellCmd(as)
-  struct cmd_syndesc *as;
+static int NewAliasCmd(struct cmd_syndesc *as)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+    char *tp;
+    char *aliasName, *realName;
+
+    /* Now setup and do the NEWCELL pioctl call */
+    aliasName = as->parms[0].items->data;
+    realName = as->parms[1].items->data;
+    tp = space;
+    strcpy(tp, aliasName);
+    tp += strlen(aliasName) + 1;
+    strcpy(tp, realName);
+    tp += strlen(realName) + 1;
+
+    blob.in_size = tp - space;
+    blob.in = space;
+    blob.out_size = 0;
+    blob.out = space;
+    code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
+    if (code < 0) {
+       if (errno == EEXIST) {
+           fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n",
+                   pn, aliasName);
+       } else {
+           Die(errno, 0);
+       }
+       return 1;
+    }
+    return 0;
+}
+
+static int WhichCellCmd(struct cmd_syndesc *as)
 {
   afs_int32 code;
   struct cmd_item *ti;
@@ -1989,20 +2009,19 @@ static WhichCellCmd(as)
   return error;
 }
 
-static WSCellCmd(as)
-    struct cmd_syndesc *as;
+static int WSCellCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
 
     blob.in_size = 0;
-    blob.in = (char *) 0;
+    blob.in = NULL;
     blob.out_size = MAXSIZE;
     blob.out = space;
 
-    code = pioctl((char *) 0, VIOC_GET_WS_CELL, &blob, 1);
+    code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
     if (code) {
-       Die(errno, (char *) 0);
+       Die(errno, NULL);
        return 1;
     }
 
@@ -2019,8 +2038,7 @@ static PrimaryCellCmd(as)
 }
 */
 
-static MonitorCmd(as)
-    struct cmd_syndesc *as;
+static int MonitorCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2048,7 +2066,7 @@ static MonitorCmd(as)
                    return 1;
                }
            }
-           else bcopy(thp->h_addr, &hostAddr, sizeof(afs_int32));
+           else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
        }
     }
     else {
@@ -2082,8 +2100,7 @@ static MonitorCmd(as)
     return 0;
 }
 
-static SysNameCmd(as)
-    struct cmd_syndesc *as;
+static int SysNameCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2108,7 +2125,7 @@ static SysNameCmd(as)
        input += strlen(ti->data);
        *(input++) = '\0';
     }
-    bcopy(&setp, space, sizeof(afs_int32));
+    memcpy(space, &setp, sizeof(afs_int32));
     code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
     if (code) {
        Die(errno, 0);
@@ -2119,7 +2136,7 @@ static SysNameCmd(as)
        return 0;
     }
     input = space;
-    bcopy(input, &setp, sizeof(afs_int32));
+    memcpy(&setp, input, sizeof(afs_int32));
     input += sizeof(afs_int32);
     if (!setp) {
        fprintf(stderr, "No sysname name value was found\n");
@@ -2135,8 +2152,7 @@ static SysNameCmd(as)
 }
 
 static char *exported_types[] = {"null", "nfs", ""};
-static ExportAfsCmd(as)
-    struct cmd_syndesc *as;
+static int ExportAfsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2221,8 +2237,7 @@ static ExportAfsCmd(as)
 }
 
 
-static GetCellCmd(as)
-    struct cmd_syndesc *as;
+static int GetCellCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2267,8 +2282,7 @@ static GetCellCmd(as)
     return error;
 }
 
-static SetCellCmd(as)
-    struct cmd_syndesc *as;
+static int SetCellCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2315,9 +2329,7 @@ static SetCellCmd(as)
     return error;
 }
 
-static GetCellName(cellName, info)
-    char *cellName;
-    struct afsconf_cell *info;
+static int GetCellName(char *cellName, struct afsconf_cell *info)
 {
     struct afsconf_dir *tdir;
     int code;
@@ -2340,9 +2352,7 @@ static GetCellName(cellName, info)
 }
 
 
-static VLDBInit(noAuthFlag, info)
-    int noAuthFlag;
-    struct afsconf_cell *info;
+static int VLDBInit(int noAuthFlag, struct afsconf_cell *info)
 {
     afs_int32 code;
     struct ktc_principal sname;
@@ -2363,7 +2373,7 @@ static VLDBInit(noAuthFlag, info)
        strcpy(sname.cell, info->name);
        sname.instance[0] = 0;
        strcpy(sname.name, "afs");
-       code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), (char *)0);
+       code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), NULL);
        if (code) {
            fprintf(stderr, "%s: Could not get afs tokens, running unauthenticated.\n", pn);
            scIndex = 0;
@@ -2381,7 +2391,7 @@ static VLDBInit(noAuthFlag, info)
     else scIndex = 0;      /* don't authenticate */
     switch (scIndex) {
     case 0:
-       sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
+       sc = rxnull_NewClientSecurityObject();
        break;
 
     case 1:
@@ -2398,7 +2408,7 @@ static VLDBInit(noAuthFlag, info)
                pn, info->numServers, VLDB_MAXSERVERS);
        exit(1);
     }
-    bzero(serverconns, sizeof(serverconns));
+    memset(serverconns, 0, sizeof(serverconns));
     for (i = 0;i<info->numServers;i++)
        serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
                                          info->hostAddr[i].sin_port, USER_SERVICE_ID,
@@ -2431,7 +2441,7 @@ static int debug = 0;
  * 0 on success,
  * errno value if error and no error message printed
  */
-static pokeServers()
+static int pokeServers(void)
 {
     int code;
 
@@ -2458,9 +2468,7 @@ static pokeServers()
  * 0 on success,
  * errno value if error and no error message printed
  */
-static addServer(name, rank)
-    char *name;
-    afs_int32 rank;
+static int addServer(char *name, afs_int32 rank)
 {
     int t,code;
     struct setspref *ssp;
@@ -2493,7 +2501,7 @@ static addServer(name, rank)
        }
 
        sp = (struct spref *) (gblob.in + gblob.in_size);
-       bcopy (thostent->h_addr_list[t], &(sp->server.s_addr), sizeof(afs_uint32));
+       memcpy(&(sp->server.s_addr), thostent->h_addr_list[t], sizeof(afs_uint32));
        sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
        gblob.in_size += sizeof(struct spref);
        ssp->num_servers++;
@@ -2507,8 +2515,7 @@ static addServer(name, rank)
 }
 
 
-static SetPrefCmd(as)
-    struct cmd_syndesc *as;
+static int SetPrefCmd(struct cmd_syndesc *as)
 {
     FILE *infd;
     afs_int32 code;
@@ -2607,8 +2614,7 @@ static SetPrefCmd(as)
 
 
 
-static GetPrefCmd(as)
-    struct cmd_syndesc *as;
+static int GetPrefCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct cmd_item *ti;
@@ -2677,8 +2683,7 @@ static GetPrefCmd(as)
     return 0;
 }
 
-static StoreBehindCmd(as)
-    struct cmd_syndesc *as;
+static int StoreBehindCmd(struct cmd_syndesc *as)
 {
     afs_int32 code=0;
     struct ViceIoctl blob;
@@ -2724,7 +2729,7 @@ static StoreBehindCmd(as)
     blob.in  = (char *)&tsb;
     blob.out = (char *)&tsb2;
     blob.in_size = blob.out_size = sizeof(struct sbstruct);
-    bzero (&tsb2, sizeof(tsb2));
+    memset(&tsb2, 0, sizeof(tsb2));
 
     /* once per -file */
     for (ti=as->parms[1].items; ti; ti=ti->next) {
@@ -2778,8 +2783,7 @@ static StoreBehindCmd(as)
 }
 
 
-static afs_int32 SetCryptCmd(as)
-    struct cmd_syndesc *as;
+static afs_int32 SetCryptCmd(struct cmd_syndesc *as)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
@@ -2800,29 +2804,28 @@ static afs_int32 SetCryptCmd(as)
     blob.out_size = 0;
     code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
     if (code)
-      Die(errno, (char *) 0);
+      Die(errno, NULL);
     return 0;
 }
 
 
-static afs_int32 GetCryptCmd(as)
-    struct cmd_syndesc *as;
+static afs_int32 GetCryptCmd(struct cmd_syndesc *as)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
     char *tp;
  
-    blob.in = (char *) 0;
+    blob.in = NULL;
     blob.in_size = 0;
     blob.out_size = sizeof(flag);
     blob.out = space;
 
     code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
 
-    if (code) Die(errno, (char *) 0);
+    if (code) Die(errno, NULL);
     else {
       tp = space;
-      bcopy(tp, &flag, sizeof(afs_int32));
+      memcpy(&flag, tp, sizeof(afs_int32));
       printf("Security level is currently ");
       if (flag == 1)
         printf("crypt (data security).\n");
@@ -2834,9 +2837,7 @@ static afs_int32 GetCryptCmd(as)
 
 #include "AFS_component_version_number.c"
 
-main(argc, argv)
-    int argc;
-    char **argv;
+int main(int argc, char **argv)
 {
     afs_int32 code;
     struct cmd_syndesc *ts;
@@ -2984,6 +2985,8 @@ defect 3069
     ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
     cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
 
+    ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases");
+
     ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
     cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
@@ -2997,6 +3000,10 @@ defect 3069
     cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
     cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
 
+    ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias");
+    cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
+    cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
+
 #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
 /*
  * Turn this on only if you wish to be able to talk to a server which is listening
@@ -3084,9 +3091,7 @@ defect 3069
     return code;
 }
 
-static void Die(errnum, filename)
-    int errnum;
-    char *filename;
+static void Die(int errnum, char *filename)
 {
     switch (errnum) {
     case EINVAL:
@@ -3125,9 +3130,7 @@ static void Die(errnum, filename)
 }
 
 /* get clients interface addresses */
-static int
-GetClientAddrsCmd(as)
-    struct cmd_syndesc *as;
+static int GetClientAddrsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct cmd_item *ti;
@@ -3173,9 +3176,7 @@ GetClientAddrsCmd(as)
     return 0;
 }
 
-static int
-SetClientAddrsCmd(as)
-    struct cmd_syndesc *as;
+static int SetClientAddrsCmd(struct cmd_syndesc *as)
 {
     afs_int32 code, addr;
     struct cmd_item *ti;
@@ -3247,9 +3248,7 @@ SetClientAddrsCmd(as)
     return error;
 }
 
-static int
-FlushMountCmd(as)
-    struct cmd_syndesc *as;
+static int FlushMountCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -3306,7 +3305,7 @@ FlushMountCmd(as)
             * name (we know there is one) and splice in the symlink value.
             */
            if (true_name[0] != '/') {
-               last_component = (char *) rindex(orig_name, '/');
+               last_component = (char *) strrchr(orig_name, '/');
                strcpy(++last_component, true_name);
                strcpy(true_name, orig_name);
            }
@@ -3317,7 +3316,7 @@ FlushMountCmd(as)
        /*
         * Find rightmost slash, if any.
         */
-       last_component = (char *) rindex(true_name, '/');
+       last_component = (char *) strrchr(true_name, '/');
        if (last_component) {
            /*
             * Found it.  Designate everything before it as the parent directory,
@@ -3346,7 +3345,7 @@ FlushMountCmd(as)
        blob.in = last_component;
        blob.in_size = strlen(last_component)+1;
        blob.out_size = 0;
-       bzero(space, MAXSIZE);
+       memset(space, 0, MAXSIZE);
 
        code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
 
@@ -3364,9 +3363,7 @@ FlushMountCmd(as)
     return error;
 }
 
-static int
-RxStatProcCmd(as)
-    struct cmd_syndesc *as;
+static int RxStatProcCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     afs_int32 flags = 0;
@@ -3400,9 +3397,7 @@ RxStatProcCmd(as)
     return 0;
 }
 
-static int
-RxStatPeerCmd(as)
-    struct cmd_syndesc *as;
+static int RxStatPeerCmd(struct cmd_syndesc *as)
 {
     afs_int32 code;
     afs_int32 flags = 0;