Remove support for Solaris pre-8
[openafs.git] / src / afs / afs_init.c
index 76d294d..2352262 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
@@ -22,7 +22,7 @@
 #include "afsincludes.h"       /* Afs-based standard headers */
 #include "afs/afs_stats.h"     /* afs statistics */
 #include "rx/rxstat.h"
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
 #include <linux/cred.h>
 #endif
 
@@ -32,7 +32,7 @@
 /* Exported variables */
 struct osi_dev cacheDev;       /*Cache device */
 afs_int32 cacheInfoModTime;    /*Last time cache info modified */
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_NBSD_ENV)
 struct mount *afs_cacheVfsp = 0;
 #elif defined(AFS_LINUX20_ENV)
 struct super_block *afs_cacheSBp = 0;
@@ -50,11 +50,9 @@ int afs_memvolumes = 0;
 #if defined(AFS_XBSD_ENV)
 static struct vnode *volumeVnode;
 #endif
-#if defined(AFS_DISCON_ENV)
 afs_rwlock_t afs_discon_lock;
 extern afs_rwlock_t afs_disconDirtyLock;
-#endif
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
 const struct cred *cache_creds;
 #endif
 
@@ -99,10 +97,11 @@ static int afs_cacheinit_flag = 0;
 int
 afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
              afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk,
-             afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers, afs_int32 dynamic_vcaches)
+             afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers,
+             afs_int32 dynamic_vcaches)
 {
-    register afs_int32 i;
-    register struct volume *tv;
+    afs_int32 i;
+    struct volume *tv;
 
     AFS_STATCNT(afs_CacheInit);
     /*
@@ -130,23 +129,22 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
 
     LOCK_INIT(&afs_ftf, "afs_ftf");
     AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
-#ifdef AFS_DISCON_ENV
     AFS_RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
     AFS_RWLOCK_INIT(&afs_disconDirtyLock, "afs_disconDirtyLock");
     QInit(&afs_disconDirty);
     QInit(&afs_disconShadow);
-#endif
     osi_dnlc_init();
 
-    /* 
-     * create volume list structure 
+    /*
+     * create volume list structure
      */
     if (aVolumes < 50)
        aVolumes = 50;
     else if (aVolumes > 32767)
        aVolumes = 32767;
 
-    tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume));
+    tv = afs_osi_Alloc(aVolumes * sizeof(struct volume));
+    osi_Assert(tv != NULL);
     for (i = 0; i < aVolumes - 1; i++)
        tv[i].next = &tv[i + 1];
     tv[aVolumes - 1].next = NULL;
@@ -157,7 +155,7 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
     afs_cacheStats = astatSize;
     afs_vcacheInit(astatSize);
     afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
     /*
      * Save current credentials for later access to disk cache files.
      * If selinux, apparmor or other security modules are enabled,
@@ -211,7 +209,7 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
 void
 afs_ComputeCacheParms(void)
 {
-    register afs_int32 i;
+    afs_int32 i;
     afs_int32 afs_maxCacheDirty;
 
     /*
@@ -248,7 +246,8 @@ afs_ComputeCacheParms(void)
  * If the vnode is not returned, we rele it.
  */
 int
-afs_LookupInodeByPath(char *filename, afs_ufs_dcache_id_t *inode, struct vnode **fvpp)
+afs_LookupInodeByPath(char *filename, afs_ufs_dcache_id_t *inode,
+                     struct vnode **fvpp)
 {
     afs_int32 code;
 
@@ -284,7 +283,7 @@ afs_InitCellInfo(char *afile)
 {
     afs_dcache_id_t inode;
     int code = 0;
-    
+
     code = afs_LookupInodeByPath(afile, &inode.ufs, NULL);
     return afs_cellname_init(&inode, code);
 }
@@ -347,7 +346,7 @@ afs_InitVolumeInfo(char *afile)
  * Parameters:
  *     afile : Name of the file assumed to be the cache info file
  *             for the Cache Manager; it will be used as such.
- * Side Effects:  This sets afs_fragsize, which is used in the cache usage 
+ * Side Effects:  This sets afs_fragsize, which is used in the cache usage
  *                calculations such as in afs_adjustsize()
  *
  * Environment:
@@ -362,11 +361,11 @@ afs_InitVolumeInfo(char *afile)
  *
  */
 int
-afs_InitCacheInfo(register char *afile)
+afs_InitCacheInfo(char *afile)
 {
-    register afs_int32 code;
+    afs_int32 code;
     struct osi_stat tstat;
-    register struct osi_file *tfile;
+    struct osi_file *tfile;
     struct afs_fheader theader;
 #ifndef AFS_LINUX22_ENV
     struct vnode *filevp;
@@ -385,17 +384,17 @@ afs_InitCacheInfo(register char *afile)
     if (code || !filevp)
        return ENOENT;
     {
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
        struct statvfs64 st;
 #elif  defined(AFS_HPUX102_ENV)
        struct k_statvfs st;
-#elif  defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) ||defined(AFS_HPUX100_ENV)
+#elif  defined(AFS_SGI_ENV) || defined(AFS_HPUX100_ENV) || defined(AFS_NBSD40_ENV)
        struct statvfs st;
 #elif defined(AFS_DARWIN80_ENV)
        struct vfsstatfs st;
 #else
        struct statfs st;
-#endif /* SUN56 */
+#endif /* SUN5 */
 
 #if    defined(AFS_SGI_ENV)
 #ifdef AFS_SGI65_ENV
@@ -419,14 +418,12 @@ afs_InitCacheInfo(register char *afile)
 #elif defined(AFS_DARWIN80_ENV)
         afs_cacheVfsp = vnode_mount(filevp);
        if (afs_cacheVfsp && ((st = *(vfs_statfs(afs_cacheVfsp))),1))
-#elif defined(AFS_DARWIN_ENV)
-       if (!VFS_STATFS(filevp->v_mount, &st, current_proc()))
 #elif defined(AFS_FBSD80_ENV)
        if (!VFS_STATFS(filevp->v_mount, &st))
-#elif defined(AFS_FBSD50_ENV)
-       if (!VFS_STATFS(filevp->v_mount, &st, curthread))
-#elif defined(AFS_XBSD_ENV)
-       if (!VFS_STATFS(filevp->v_mount, &st, curproc))
+#elif defined(AFS_NBSD50_ENV)
+       if (!VFS_STATVFS(filevp->v_vfsp, &st))
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+       if (!VFS_STATFS(filevp->v_mount, &st, osi_curproc()))
 #else
        if (!VFS_STATFS(filevp->v_vfsp, &st))
 #endif /* SGI... */
@@ -486,6 +483,7 @@ afs_InitCacheInfo(register char *afile)
        if (theader.magic == AFS_FHMAGIC
            && theader.firstCSize == AFS_FIRSTCSIZE
            && theader.otherCSize == AFS_OTHERCSIZE
+           && theader.dataSize == sizeof(struct fcache)
            && theader.version == AFS_CI_VERSION)
            goodFile = 1;
     }
@@ -494,6 +492,7 @@ afs_InitCacheInfo(register char *afile)
        theader.magic = AFS_FHMAGIC;
        theader.firstCSize = AFS_FIRSTCSIZE;
        theader.otherCSize = AFS_OTHERCSIZE;
+       theader.dataSize = sizeof(struct fcache);
        theader.version = AFS_CI_VERSION;
        afs_osi_Write(tfile, 0, &theader, sizeof(theader));
        /*
@@ -515,7 +514,7 @@ int afs_resourceinit_flag = 0;
 int
 afs_ResourceInit(int preallocs)
 {
-    register afs_int32 i;
+    afs_int32 i;
     static struct rx_securityClass *secobj;
 
     AFS_STATCNT(afs_ResourceInit);
@@ -526,7 +525,7 @@ afs_ResourceInit(int preallocs)
     AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
     AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
     LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
-#ifndef AFS_FBSD_ENV
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
     LOCK_INIT(&osi_fsplock, "osi_fsplock");
     LOCK_INIT(&osi_flplock, "osi_flplock");
 #endif
@@ -539,8 +538,10 @@ afs_ResourceInit(int preallocs)
        afs_resourceinit_flag = 1;
        for (i = 0; i < NFENTRIES; i++)
            fvTable[i] = 0;
-       for (i = 0; i < MAXNUMSYSNAMES; i++)
+       for (i = 0; i < MAXNUMSYSNAMES; i++) {
            afs_sysnamelist[i] = afs_osi_Alloc(MAXSYSNAME);
+           osi_Assert(afs_sysnamelist[i] != NULL);
+       }
        afs_sysname = afs_sysnamelist[0];
        strcpy(afs_sysname, SYS_NAME);
        afs_sysnamecount = 1;
@@ -718,7 +719,7 @@ shutdown_cache(void)
        memset(&cacheDev, 0, sizeof(struct osi_dev));
        osi_dnlc_shutdown();
     }
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
     put_cred(cache_creds);
 #endif
 }                              /*shutdown_cache */
@@ -727,11 +728,6 @@ shutdown_cache(void)
 void
 shutdown_vnodeops(void)
 {
-#if !defined(AFS_SGI_ENV) && !defined(AFS_SUN5_ENV)
-    struct buf *afs_bread_freebp = 0;
-#endif
-
-
     AFS_STATCNT(shutdown_vnodeops);
     if (afs_cold_shutdown) {
 #ifndef        AFS_SUN5_ENV            /* XXX */
@@ -740,9 +736,6 @@ shutdown_vnodeops(void)
 #ifndef AFS_LINUX20_ENV
        afs_rd_stash_i = 0;
 #endif
-#if !defined(AFS_SGI_ENV) && !defined(AFS_SUN5_ENV)
-       afs_bread_freebp = 0;
-#endif
        shutdown_mariner();
     }
 }
@@ -752,7 +745,6 @@ static void
 shutdown_server(void)
 {
     int i;
-    struct afs_conn *tc, *ntc;
     struct afs_cbr *tcbrp, *tbrp;
     struct srvAddr *sa;
 
@@ -764,22 +756,11 @@ shutdown_server(void)
            next = ts->next;
            for (sa = ts->addr; sa; sa = sa->next_sa) {
                if (sa->conns) {
-                   /*
-                    * Free all server's connection structs
-                    */
-                   tc = sa->conns;
-                   while (tc) {
-                       ntc = tc->next;
-#if 0
-                       /* we should destroy all connections
-                          when shutting down Rx, not here */
-                       AFS_GUNLOCK();
-                       rx_DestroyConnection(tc->id);
-                       AFS_GLOCK();
-#endif
-                       afs_osi_Free(tc, sizeof(struct afs_conn));
-                       tc = ntc;
-                   }
+                    /* afs_ReleaseConns has been updated to
+                     * defer rx_DestroyConnection to Rx
+                     * shutdown, as most recently was done
+                     * here */
+                    afs_ReleaseConns(sa->conns);
                }
            }
            for (tcbrp = ts->cbrs; tcbrp; tcbrp = tbrp) {
@@ -834,8 +815,8 @@ shutdown_AFS(void)
 
        shutdown_volume();
 
-       /* 
-        * Free FreeVolList allocations 
+       /*
+        * Free FreeVolList allocations
         */
        afs_osi_Free(Initialafs_freeVolList,
                     afs_memvolumes * sizeof(struct volume));
@@ -847,16 +828,16 @@ shutdown_AFS(void)
         * we simply malloc more; we won't be able to free those additional volumes.
         */
 
-       /* 
-        * Free Users table allocation 
+       /*
+        * Free Users table allocation
         */
        {
            struct unixuser *tu, *ntu;
            for (i = 0; i < NUSERS; i++) {
                for (tu = afs_users[i]; tu; tu = ntu) {
                    ntu = tu->next;
-                   if (tu->stp)
-                       afs_osi_Free(tu->stp, tu->stLen);
+                   if (tu->tokens)
+                       afs_FreeTokens(&tu->tokens);
                    if (tu->exporter)
                        EXP_RELE(tu->exporter);
                    afs_osi_Free(tu, sizeof(struct unixuser));