vlserver: Rationalise usage message
[openafs.git] / src / vlserver / vlserver.c
index 4173479..ffeb498 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -9,34 +9,17 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
+#include <roken.h>
 
-#include <afs/stds.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
 #ifdef AFS_NT40_ENV
-#include <winsock2.h>
 #include <WINNT/afsevent.h>
 #endif
+
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
-#include <time.h>
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
 
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/keys.h>
 #include <afs/auth.h>
 #include <afs/audit.h>
+#include <afs/com_err.h>
 #include <lock.h>
 #include <ubik.h>
 #include <afs/afsutil.h>
+
 #include "vlserver.h"
 #include "vlserver_internal.h"
 
@@ -59,7 +44,8 @@ int lwps = 9;
 
 struct vldstats dynamic_statistics;
 struct ubik_dbase *VL_dbase;
-afs_uint32 HostAddress[MAXSERVERID + 1];
+afs_uint32 rd_HostAddress[MAXSERVERID + 1];
+afs_uint32 wr_HostAddress[MAXSERVERID + 1];
 
 static void *CheckSignal(void*);
 int LogLevel = 0;
@@ -86,21 +72,21 @@ CheckSignal_Signal(int unused)
 static void *
 CheckSignal(void *unused)
 {
-    register int i, errorcode;
-    struct ubik_trans *trans;
+    int i, errorcode;
+    struct vl_ctx ctx;
 
     if ((errorcode =
-       Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
+       Init_VLdbase(&ctx, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
        return (void *)(intptr_t)errorcode;
     VLog(0, ("Dump name hash table out\n"));
     for (i = 0; i < HASHSIZE; i++) {
-       HashNDump(trans, i);
+       HashNDump(&ctx, i);
     }
     VLog(0, ("Dump id hash table out\n"));
     for (i = 0; i < HASHSIZE; i++) {
-       HashIdDump(trans, i);
+       HashIdDump(&ctx, i);
     }
-    return ((void *)(intptr_t)ubik_EndTrans(trans));
+    return ((void *)(intptr_t)ubik_EndTrans(ctx.trans));
 }                              /*CheckSignal */
 
 
@@ -131,7 +117,7 @@ vldb_rxstat_userok(struct rx_call *call)
 int
 main(int argc, char **argv)
 {
-    register afs_int32 code;
+    afs_int32 code;
     afs_uint32 myHost;
     struct rx_service *tservice;
     struct rx_securityClass **securityClasses;
@@ -148,8 +134,8 @@ main(int argc, char **argv)
 
 #ifdef AFS_AIX32_ENV
     /*
-     * The following signal action for AIX is necessary so that in case of a 
-     * crash (i.e. core is generated) we can include the user's data section 
+     * The following signal action for AIX is necessary so that in case of a
+     * crash (i.e. core is generated) we can include the user's data section
      * in the core dump. Unfortunately, by default, only a partial core is
      * generated which, in many cases, isn't too useful.
      */
@@ -177,8 +163,8 @@ main(int argc, char **argv)
            }
        } else if (strcmp(argv[index], "-d") == 0) {
            if ((index + 1) >= argc) {
-               fprintf(stderr, "missing argument for -d\n"); 
-               return -1; 
+               fprintf(stderr, "missing argument for -d\n");
+               return -1;
            }
            debuglevel = atoi(argv[++index]);
            LogLevel = debuglevel;
@@ -192,14 +178,14 @@ main(int argc, char **argv)
            rxkadDisableDotCheck = 1;
        } else if (!strcmp(argv[index], "-rxmaxmtu")) {
            if ((index + 1) >= argc) {
-               fprintf(stderr, "missing argument for -rxmaxmtu\n"); 
-               return -1; 
+               fprintf(stderr, "missing argument for -rxmaxmtu\n");
+               return -1;
            }
            rxMaxMTU = atoi(argv[++index]);
-           if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || 
+           if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
                (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
                printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
-                      rxMaxMTU, RX_MIN_PACKET_SIZE, 
+                      rxMaxMTU, RX_MIN_PACKET_SIZE,
                       RX_MAX_PACKET_DATA_SIZE);
                return -1;
            }
@@ -236,20 +222,14 @@ main(int argc, char **argv)
 #endif
        } else {
            /* support help flag */
-#ifndef AFS_NT40_ENV
-           printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
-                  "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
-                  "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
-                  "[-syslog[=FACILITY]] "
-                  "[-enable_peer_stats] [-enable_process_stats] "
-                  "[-help]\n");
-#else
            printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
                   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
-                  "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
-                  "[-enable_peer_stats] [-enable_process_stats] "
-                  "[-help]\n");
+                  "[-auditlog <log path>] [-jumbo] [-d <debug level>] ");
+#ifndef AFS_NT40_ENV
+           printf("[-syslog[=FACILITY]] ");
 #endif
+           printf("[-enable_peer_stats] [-enable_process_stats] "
+                  "[-help]\n");
            fflush(stdout);
            exit(0);
        }
@@ -323,15 +303,15 @@ main(int argc, char **argv)
     if (rxBind) {
        afs_int32 ccode;
 #ifndef AFS_NT40_ENV
-        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
+        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
             ccode = parseNetFiles(SHostAddrs, NULL, NULL,
                                  ADDRSPERSITE, reason,
                                  AFSDIR_SERVER_NETINFO_FILEPATH,
                                  AFSDIR_SERVER_NETRESTRICT_FILEPATH);
-        } else 
-#endif 
+        } else
+#endif
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
@@ -342,17 +322,16 @@ main(int argc, char **argv)
     }
 
     ubik_nBuffers = 512;
-    ubik_CRXSecurityProc = afsconf_ClientAuth;
-    ubik_CRXSecurityRock = (char *)tdir;
-    ubik_SRXSecurityProc = afsconf_ServerAuth;
-    ubik_SRXSecurityRock = (char *)tdir;
-    ubik_CheckRXSecurityProc = afsconf_CheckAuth;
-    ubik_CheckRXSecurityRock = (char *)tdir;
+    ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, tdir);
+    ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
+                               afsconf_CheckAuth, tdir);
+
+    ubik_SyncWriterCacheProc = vlsynccache;
     code =
        ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
                              vl_dbaseName, &VL_dbase);
     if (code) {
-       printf("vlserver: Ubik init failed with code %d\n", code);
+       printf("vlserver: Ubik init failed: %s\n", afs_error_message(code));
        exit(2);
     }
     if (!rxJumbograms) {
@@ -363,10 +342,11 @@ main(int argc, char **argv)
     }
     rx_SetRxDeadTime(50);
 
-    memset(HostAddress, 0, sizeof(HostAddress));
+    memset(rd_HostAddress, 0, sizeof(rd_HostAddress));
+    memset(wr_HostAddress, 0, sizeof(wr_HostAddress));
     initialize_dstats();
 
-    afsconf_BuildServerSecurityObjects(tdir, 0, &securityClasses, &numClasses);
+    afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
 
     tservice =
        rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server",