afsd: correct printf format mismatch in debugging printf
[openafs.git] / src / afsd / afsd.c
index 96d3add..0fb524a 100644 (file)
 
 #include <afsconfig.h>
 #include <afs/param.h>
-#include <roken.h>
+/* darwin dirent.h doesn't give us the prototypes we want if KERNEL is
+ * defined, and roken includes dirent */
+#if defined(UKERNEL) && defined(AFS_USR_DARWIN_ENV)
+# undef KERNEL
+# include <roken.h>
+# define KERNEL
+#else
+# include <roken.h>
+#endif
 
 #define VFS 1
 
 #endif
 #include <CoreFoundation/CoreFoundation.h>
 
-#include <SystemConfiguration/SystemConfiguration.h>
-#include <SystemConfiguration/SCDynamicStore.h>
-
+static int event_pid;
 #ifndef AFS_ARM_DARWIN_ENV
-#include <IOKit/pwr_mgt/IOPMLib.h>
-#include <IOKit/IOMessage.h>
-
-static io_connect_t root_port;
-static IONotificationPortRef notify;
-static io_object_t iterator;
+#define MACOS_EVENT_HANDLING 1
 #endif
-
-static CFRunLoopSourceRef source;
-
-static int event_pid;
-
 #endif /* AFS_DARWIN_ENV */
 
 #if AFS_HAVE_STATVFS || defined(HAVE_SYS_STATVFS_H)
@@ -349,7 +345,18 @@ enum optionsList {
     OPT_rxmaxfrags,
 };
 
-#if defined(AFS_DARWIN_ENV) && !defined(AFS_ARM_DARWIN_ENV)
+#ifdef MACOS_EVENT_HANDLING
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCDynamicStore.h>
+
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <IOKit/IOMessage.h>
+
+static io_connect_t root_port;
+static IONotificationPortRef notify;
+static io_object_t iterator;
+static CFRunLoopSourceRef source;
+
 static void
 afsd_sleep_callback(void * refCon, io_service_t service,
                    natural_t messageType, void * messageArgument )
@@ -398,10 +405,9 @@ afsd_update_addresses(CFRunLoopTimerRef timer, void *info)
     char reason[1024];
     int code;
 
-    code =
-       parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
-                     AFSDIR_CLIENT_NETINFO_FILEPATH,
-                     AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
+    code = afsconf_ParseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS,
+                                reason, AFSDIR_CLIENT_NETINFO_FILEPATH,
+                                AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
 
     if (code > 0) {
        /* Note we're refreshing */
@@ -1328,7 +1334,7 @@ CheckCacheBaseDir(char *dir)
 
                    if (cp = hasmntopt(&mnt, "dev="))
                        rdev =
-                           (int)strtol(cp + strlen("dev="), (char **)NULL,
+                           (int)strtol(cp + strlen("dev="), NULL,
                                        16);
 
                    if ((rdev == 0) && (stat(mnt.mnt_mountp, &statmnt) == 0))
@@ -1460,7 +1466,7 @@ AfsdbLookupHandler(void)
     kernelMsg[1] = 0;
     acellName[0] = '\0';
 
-#if defined(AFS_DARWIN_ENV) && !defined(AFS_ARM_DARWIN_ENV)
+#ifdef MACOS_EVENT_HANDLING
     /* Fork the event handler also. */
     code = fork();
     if (code == 0) {
@@ -1677,6 +1683,9 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
 #endif
 
+    cmd_OpenConfigFile(AFSDIR_CLIENT_CONFIG_FILE_FILEPATH);
+    cmd_SetCommandName("afsd");
+
     /* call atoi on the appropriate parsed results */
     if (cmd_OptionAsInt(as, OPT_blocks, &cacheBlocks) == 0)
        sawCacheBlocks = 1;
@@ -2077,8 +2086,9 @@ afsd_run(void)
        exit(1);
     }
     if (afsd_debug)
-       printf("%s: %d inode_for_V entries at 0x%x, %lu bytes\n", rn,
-              cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T)));
+       printf("%s: %d inode_for_V entries at %p, %lu bytes\n", rn,
+              cacheFiles, inode_for_V,
+              (unsigned long)cacheFiles * sizeof(AFSD_INO_T));
 #endif
 
     if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) {
@@ -2122,10 +2132,9 @@ afsd_run(void)
        afs_uint32 addrbuf[MAXIPADDRS], maskbuf[MAXIPADDRS],
            mtubuf[MAXIPADDRS];
        char reason[1024];
-       code =
-           parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
-                         AFSDIR_CLIENT_NETINFO_FILEPATH,
-                         AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
+       code = afsconf_ParseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
+                                    AFSDIR_CLIENT_NETINFO_FILEPATH,
+                                    AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
        if (code > 0) {
            if (enable_rxbind)
                code = code | 0x80000000;
@@ -2200,7 +2209,7 @@ afsd_run(void)
     cparams.setTimeFlag = 0;
     cparams.memCacheFlag = cacheFlags;
     cparams.dynamic_vcaches = afsd_dynamic_vcaches;
-       afsd_syscall(AFSOP_CACHEINIT, &cparams);
+    afsd_syscall(AFSOP_CACHEINIT, &cparams);
 
     /* do it before we init the cache inodes */
     if (enable_splitcache) {
@@ -2435,6 +2444,9 @@ afsd_run(void)
        if (afsd_verbose)
            printf("%s: Forking 'rmtsys' daemon.\n", rn);
        afsd_fork(0, rmtsysd_thread, NULL);
+       code = afsd_syscall(AFSOP_SET_RMTSYS_FLAG, 1);
+       if (code)
+           printf("%s: Error enabling rmtsys support.\n", rn);
     }
 #endif /* !UKERNEL */
     /*
@@ -2496,11 +2508,9 @@ afsd_init(void)
     cmd_AddParmAtOffset(ts, OPT_shutdown, "-shutdown", CMD_FLAG,
                        CMD_OPTIONAL, "Shutdown all afs state");
     cmd_AddParmAtOffset(ts, OPT_peerstats, "-enable_peer_stats", CMD_FLAG,
-                       CMD_OPTIONAL | CMD_HIDE,
-                       "Collect rpc statistics by peer");
+                       CMD_OPTIONAL, "Collect rpc statistics by peer");
     cmd_AddParmAtOffset(ts, OPT_processstats, "-enable_process_stats",
-                       CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
-                       "Collect rpc statistics for this process");
+                       CMD_FLAG, CMD_OPTIONAL, "Collect rpc statistics for this process");
     cmd_AddParmAtOffset(ts, OPT_memallocsleep, "-mem_alloc_sleep",
                        CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
                        "Allow sleeps when allocating memory cache");
@@ -2594,23 +2604,32 @@ afsd_syscall_populate(struct afsd_syscall_args *args, int syscall, va_list ap)
 
     switch (syscall) {
     case AFSOP_RXEVENT_DAEMON:
+    case AFSOP_CLOSEWAIT:
+    case AFSOP_START_AFS:
+    case AFSOP_START_CS:
+    case AFSOP_START_TRUNCDAEMON:
        break;
     case AFSOP_START_BKG:
     case AFSOP_SHUTDOWN:
     case AFSOP_SET_RXPCK:
     case AFSOP_BASIC_INIT:
     case AFSOP_SET_RXMAXFRAGS:
-      case AFSOP_SET_RXMAXMTU:
+    case AFSOP_SET_RXMAXMTU:
     case AFSOP_SET_DYNROOT:
     case AFSOP_SET_FAKESTAT:
     case AFSOP_SET_BACKUPTREE:
+    case AFSOP_BUCKETPCT:
     case AFSOP_GO:
+    case AFSOP_SET_RMTSYS_FLAG:
        params[0] = CAST_SYSCALL_PARAM((va_arg(ap, int)));
        break;
     case AFSOP_SET_THISCELL:
     case AFSOP_ROOTVOLUME:
     case AFSOP_VOLUMEINFO:
     case AFSOP_CACHEFILE:
+    case AFSOP_CACHEINFO:
+    case AFSOP_CACHEINIT:
+    case AFSOP_CELLINFO:
        params[0] = CAST_SYSCALL_PARAM((va_arg(ap, void *)));
        break;
     case AFSOP_ADDCELLALIAS: