afsd: Detect -dcache presence correctly
[openafs.git] / src / afsd / afsd.c
index 0a6a995..5fe8b04 100644 (file)
 #include "afsd.h"
 
 #include <afs/afsutil.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+
 #include <sys/file.h>
-#include <errno.h>
-#include <sys/time.h>
 #include <sys/wait.h>
 
 /* darwin dirent.h doesn't give us the prototypes we want if KERNEL is
 # include <dirent.h>
 #endif
 
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
 #ifdef HAVE_SYS_FS_TYPES_H
 #include <sys/fs_types.h>
 #endif
 #include <sys/fstyp.h>
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
+#include <ctype.h>
 
-#include <netinet/in.h>
 #include <afs/afs_args.h>
 #include <afs/cellconfig.h>
-#include <ctype.h>
 #include <afs/afssyscalls.h>
 #include <afs/afsutil.h>
 #include <afs/sys_prototypes.h>
 
-#ifdef AFS_SGI61_ENV
-#include <unistd.h>
-#include <libelf.h>
-#include <dwarf.h>
-#include <libdwarf.h>
-void set_staticaddrs(void);
-#endif /* AFS_SGI61_ENV */
 #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV)
 #include <sym.h>
 #include <symconst.h>
@@ -165,7 +136,6 @@ void set_staticaddrs(void);
 
 #ifdef AFS_DARWIN_ENV
 #ifdef AFS_DARWIN80_ENV
-#include <sys/ioctl.h>
 #include <sys/xattr.h>
 #endif
 #include <CoreFoundation/CoreFoundation.h>
@@ -1765,7 +1735,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
        }
     }
 
-    if (cmd_OptionAsInt(as, OPT_dcache, &dCacheSize))
+    if (cmd_OptionAsInt(as, OPT_dcache, &dCacheSize) == 0)
        sawDCacheSize = 1;
 
     cmd_OptionAsInt(as, OPT_volumes, &vCacheSize);
@@ -2120,23 +2090,25 @@ afsd_run(void)
               cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T)));
 #endif
 
-    /*
-     * Set up all the pathnames we'll need for later.
-     */
-    sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE);
-    sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE);
-    sprintf(fullpn_CellInfoFile, "%s/%s", cacheBaseDir, CELLINFOFILE);
-    sprintf(fullpn_VFile, "%s/", cacheBaseDir);
-    vFilePtr = fullpn_VFile + strlen(fullpn_VFile);
-
-    if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)
-       && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) {
+    if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) {
+       /*
+        * Set up all the pathnames we'll need for later.
+        */
+       sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE);
+       sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE);
+       sprintf(fullpn_CellInfoFile, "%s/%s", cacheBaseDir, CELLINFOFILE);
+       sprintf(fullpn_VFile, "%s/", cacheBaseDir);
+       vFilePtr = fullpn_VFile + strlen(fullpn_VFile);
+
+       fsTypeMsg = CheckCacheBaseDir(cacheBaseDir);
+       if (fsTypeMsg) {
 #ifdef AFS_SUN5_ENV
-       printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg);
+           printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg);
 #else
-       printf("%s: ERROR: Cache dir check failed (%s)\n", rn, fsTypeMsg);
-       exit(1);
+           printf("%s: ERROR: Cache dir check failed (%s)\n", rn, fsTypeMsg);
+           exit(1);
 #endif
+       }
     }
 
     /*
@@ -2404,13 +2376,13 @@ afsd_run(void)
      * Give the kernel the names of the AFS files cached on the workstation's
      * disk.
      */
-    if (afsd_debug)
-       printf
-           ("%s: Calling AFSOP_CACHEFILE for each of the %d files in '%s'\n",
-            rn, cacheFiles, cacheBaseDir);
     if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) {
-       /* ... and again ... */
        int nocachefile = 0;
+       if (afsd_debug)
+           printf
+               ("%s: Calling AFSOP_CACHEFILE for each of the %d files in '%s'\n",
+                rn, cacheFiles, cacheBaseDir);
+       /* ... and again ... */
        for (currVFile = 0; currVFile < cacheFiles; currVFile++) {
            if (!nocachefile) {
                sprintf(fullpn_VFile, "%s/D%d/V%d", cacheBaseDir, dir_for_V[currVFile], currVFile);