move-up-cell-initialization-in-cachemgr-20030323
[openafs.git] / src / afsd / afsd.c
index 5ba6687..46296c8 100644 (file)
@@ -226,7 +226,11 @@ char cacheMountDir[1024];          /*Mount directory for AFS*/
 char rootVolume[64] = "root.afs";      /*AFS root volume name*/
 afs_int32 cacheSetTime = 1;                    /*Keep checking time to avoid drift?*/
 afs_int32 isHomeCell;                  /*Is current cell info for the home cell?*/
+#ifdef AFS_XBSD_ENV
+int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC; /*Create & truncate on open*/
+#else
 int createAndTrunc = O_CREAT | O_TRUNC; /*Create & truncate on open*/
+#endif
 int ownerRWmode        = 0600;                 /*Read/write OK by owner*/
 static int filesSet = 0;               /*True if number of files explicitly set*/
 static int nFilesPerDir = 2048;                /* # files per cache dir */
@@ -1480,6 +1484,37 @@ mainproc(as, arock)
     sprintf(fullpn_VFile,       "%s/",  cacheBaseDir);
     vFilePtr = fullpn_VFile + strlen(fullpn_VFile);
 
+#ifdef AFS_SUN5_ENV
+    {
+       FILE *vfstab;
+       struct mnttab mnt;
+       struct stat statmnt, statci;
+
+       if ((stat(cacheBaseDir, &statci) == 0) &&
+           ((vfstab = fopen(MNTTAB, "r")) != NULL)) {
+           while (getmntent(vfstab, &mnt) == 0) {
+               if (strcmp(cacheBaseDir, mnt.mnt_mountp) != 0) {
+                   char *cp;
+                   int rdev = 0;
+
+                   if (cp = hasmntopt(&mnt, "dev="))
+                       rdev=(int)strtol(cp+strlen("dev="), (char **)NULL, 16);
+
+                   if ((rdev == 0) && (stat(mnt.mnt_mountp, &statmnt) == 0))
+                       rdev=statmnt.st_dev;
+
+                   if ((rdev == statci.st_dev) &&
+                       (hasmntopt (&mnt, "logging") != NULL)) {
+                       printf("WARNING: Mounting a multi-use partition which contains the AFS cache with the\n\"logging\" option may deadlock your system.\n\n");
+                       fflush(stdout);
+                   }
+               }
+           }
+           fclose(vfstab);
+       }
+    }
+#endif
+
 #if 0
     fputs(AFS_GOVERNMENT_MESSAGE, stdout); 
     fflush(stdout);
@@ -1668,6 +1703,17 @@ mainproc(as, arock)
            printf("%s: Error enabling fakestat support.\n", rn);
     }
 
+    /*
+     * Tell the kernel about each cell in the configuration.
+     */
+    afsconf_CellApply(cdir, ConfigCell, NULL);
+    afsconf_CellAliasApply(cdir, ConfigCellAlias, NULL);
+
+    /*
+     * Set the primary cell name.
+     */
+    call_syscall(AFSOP_SET_THISCELL, LclCellName);
+
     /* Initialize AFS daemon threads. */
     if (afsd_verbose)
        printf("%s: Forking AFS daemon.\n", rn);
@@ -1724,17 +1770,6 @@ mainproc(as, arock)
 #endif
 
     /*
-     * Tell the kernel about each cell in the configuration.
-     */
-    afsconf_CellApply(cdir, ConfigCell, NULL);
-    afsconf_CellAliasApply(cdir, ConfigCellAlias, NULL);
-
-    /*
-     * Set the primary cell name.
-     */
-    call_syscall(AFSOP_SET_THISCELL, LclCellName);
-
-    /*
      * If the root volume has been explicitly set, tell the kernel.
      */
     if (rootVolSet) {