afsd: Do not check for /afs if -nomount
[openafs.git] / src / afsd / afsd.c
index 4e8b6e5..c5efb65 100644 (file)
@@ -68,8 +68,7 @@
 
 #include "afsd.h"
 
-#include <assert.h>
-#include <potpourri.h>
+#include <afs/afs_assert.h>
 #include <afs/afsutil.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -229,11 +228,6 @@ struct in_addr_42 {
        } S_un_w;
        afs_uint32 S_addr;
     } S_un;
-#define        s_host  S_un.S_un_b.s_b2        /* host on imp */
-#define        s_net   S_un.S_un_b.s_b1        /* network */
-#define        s_imp   S_un.S_un_w.s_w2        /* imp */
-#define        s_impno S_un.S_un_b.s_b4        /* imp # */
-#define        s_lh    S_un.S_un_b.s_b3        /* logical host */
 };
 
 #define        mPrintIPAddr(ipaddr)  printf("[%d.%d.%d.%d] ",          \
@@ -270,7 +264,7 @@ static int sawBiod = 0;
 static int sawCacheStatEntries = 0;
 char afsd_cacheMountDir[1024]; /*Mount directory for AFS */
 static char rootVolume[64] = "root.afs";       /*AFS root volume name */
-static afs_int32 cacheSetTime = FALSE; /*Keep checking time to avoid drift? */
+static afs_int32 cacheSetTime = 0;     /*Keep checking time to avoid drift? */
 #ifdef AFS_XBSD_ENV
 static int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC;        /*Create & truncate on open */
 #else
@@ -406,6 +400,10 @@ afsd_update_addresses(CFRunLoopTimerRef timer, void *info)
     } else
        printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
               reason);
+
+    /* Since it's likely this means our DNS server changed, reinit now */
+    if (enable_afsdb)
+       res_init();
 }
 
 /* This function is called when the system's ip addresses may have changed. */
@@ -994,7 +992,7 @@ doSweepAFSCache(int *vFilesFound,
 #if defined(AFS_SGI62_ENV) || defined(AFS_DARWIN90_ENV)
            printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n", currp->d_ino,
                   currp->d_reclen, currp->d_name);
-#elif defined(AFS_DFBSD_ENV)
+#elif defined(AFS_DFBSD_ENV) || defined(AFS_USR_DFBSD_ENV)
            printf("\tinode=%ld, name='%s'\n", (long)currp->d_ino, currp->d_name);
 #else
            printf("\tinode=%ld, reclen=%d, name='%s'\n", (long)currp->d_ino,
@@ -1722,7 +1720,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
     if (as->parms[8].items) {
        /* -nosettime */
-       cacheSetTime = FALSE;
+       cacheSetTime = 0;
     }
     if (as->parms[9].items) {
        /* -verbose */
@@ -1854,7 +1852,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     }
     if (as->parms[32].items) {
        /* -settime */
-       cacheSetTime = TRUE;
+       cacheSetTime = 1;
     }
 
     /* set rx_extraPackets */
@@ -1887,7 +1885,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
     if (as->parms[35].items) {
 #ifdef AFS_MAXVCOUNT_ENV
        /* -disable-dynamic-vcaches */
-       afsd_dynamic_vcaches = FALSE;
+       afsd_dynamic_vcaches = 0;
 #else
        printf("afsd: Error toggling flag, dynamically allocated vcaches not supported on your platform\n");
        exit(1);
@@ -1896,7 +1894,7 @@ mainproc(struct cmd_syndesc *as, void *arock)
 #ifdef AFS_MAXVCOUNT_ENV
     else {
        /* -dynamic-vcaches */
-       afsd_dynamic_vcaches = TRUE;
+       afsd_dynamic_vcaches = 1;
     }
 
     if (afsd_verbose)
@@ -1920,6 +1918,7 @@ afsd_run(void)
 {
     static char rn[] = "afsd"; /*Name of this routine */
     struct afsconf_dir *cdir;  /* config dir */
+    struct stat statbuf;
     int lookupResult;          /*Result of GetLocalCellName() */
     int i;
     afs_int32 code;            /*Result of fork() */
@@ -1928,7 +1927,7 @@ afsd_run(void)
     int vFilesFound;           /*How many data cache files were found in sweep */
     int currVFile;             /*Current AFS cache file number passed in */
 
-    /*
+       /*
      * Pull out all the configuration info for the workstation's AFS cache and
      * the cellular community we're willing to let our users see.
      */
@@ -1953,6 +1952,18 @@ afsd_run(void)
        exit(1);
     }
 
+    if (!enable_nomount) {
+       if (stat(afsd_cacheMountDir, &statbuf)) {
+           printf("afsd: Mountpoint %s missing.\n", afsd_cacheMountDir);
+           exit(1);
+       } else {
+           if (!S_ISDIR(statbuf.st_mode)) {
+               printf("afsd: Mountpoint %s is not a directory.\n", afsd_cacheMountDir);
+               exit(1);
+           }
+       }
+    }
+
     /* do some random computations in memcache case to get things to work
      * reasonably no matter which parameters you set.
      */
@@ -2166,7 +2177,7 @@ afsd_run(void)
        if (code > 0) {
            if (enable_rxbind)
                code = code | 0x80000000;
-           afsd_call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
+               afsd_call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
        } else
            printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
                   reason);
@@ -2218,7 +2229,6 @@ afsd_run(void)
            printf("%s: Forking AFSDB lookup handler.\n", rn);
        afsd_fork(0, afsdb_thread, NULL);
     }
-
     code = afsd_call_syscall(AFSOP_BASIC_INIT, 1);
     if (code) {
        printf("%s: Error %d in basic initialization.\n", rn, code);
@@ -2243,7 +2253,7 @@ afsd_run(void)
     cparams.setTimeFlag = cacheSetTime;
     cparams.memCacheFlag = cacheFlags;
     cparams.dynamic_vcaches = afsd_dynamic_vcaches;
-    afsd_call_syscall(AFSOP_CACHEINIT, &cparams);
+       afsd_call_syscall(AFSOP_CACHEINIT, &cparams);
 
     /* do it before we init the cache inodes */
     if (enable_splitcache) {
@@ -2299,10 +2309,12 @@ afsd_run(void)
      * Pass the kernel the name of the workstation cache file holding the
      * cell information.
      */
-    if (afsd_debug)
-       printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", rn,
-              fullpn_CellInfoFile);
-    afsd_call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile);
+    if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) {
+       if (afsd_debug)
+           printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", rn,
+                  fullpn_CellInfoFile);
+       afsd_call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile);
+    }
 
     if (rxmaxmtu) {
        if (afsd_verbose)
@@ -2451,7 +2463,7 @@ afsd_run(void)
     if (afsd_debug)
        printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", rn,
               cacheSetTime);
-    afsd_call_syscall(AFSOP_GO, cacheSetTime);
+       afsd_call_syscall(AFSOP_GO, cacheSetTime);
 
     /*
      * At this point, we have finished passing the kernel all the info