Remove the global tempHeader/stuff structures
[openafs.git] / src / vol / volinodes.h
index 2952a60..181b441 100644 (file)
@@ -1,14 +1,12 @@
 /*
  * 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
  */
 
-#if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
-#endif
 /*
        System:         VICE-TWO
        Module:         volinodes.h
 
  */
 
-/* Used by vutil.c and salvager.c */
+#ifndef __volinodes_h_
+#define __volinodes_h_
 
-private struct VolumeHeader tempHeader;
+#include <stddef.h>
+
+/* Used by vutil.c and salvager.c */
 
 #ifdef AFS_NAMEI_ENV
 #define NO_LINK_TABLE 0
 #else
 #define NO_LINK_TABLE 1
 #endif
-private struct stuff {
+
+#define MAXINODETYPE VI_LINKTABLE
+static struct afs_inode_info {
     struct versionStamp stamp;
-    bit32      inodeType;
-    int                size;   /* size of any fixed size portion of the header */
-    Inode      *inode;
-    char       *description;
+    bit32 inodeType;
+    int size;                  /* size of any fixed size portion of the header */
+    Inode *inode;
+    char *description;
     /* if this is 1, then this inode is obsolete--
      * salvager may delete it, and shouldn't complain
      * if it isn't there; create can not bother to create it */
-    int                obsolete;
-} stuff[] = {
-    {{VOLUMEINFOMAGIC,VOLUMEINFOVERSION}, VI_VOLINFO, sizeof(VolumeDiskData),
-      &tempHeader.volumeInfo, "Volume information", 0}, 
-    {{SMALLINDEXMAGIC,SMALLINDEXVERSION},VI_SMALLINDEX,sizeof(struct versionStamp),
-      &tempHeader.smallVnodeIndex, "small inode index", 0},
-    {{LARGEINDEXMAGIC,LARGEINDEXVERSION},VI_LARGEINDEX,sizeof(struct versionStamp),
-      &tempHeader.largeVnodeIndex, "large inode index", 0},
-    {{ACLMAGIC,ACLVERSION},VI_ACL,sizeof(struct versionStamp),
-      &tempHeader.volumeAcl, "access control list", 1},
-    {{MOUNTMAGIC,MOUNTVERSION},VI_MOUNTTABLE,sizeof(struct versionStamp),
-      &tempHeader.volumeMountTable, "mount table", 1},
-    {{LINKTABLEMAGIC,LINKTABLEVERSION},VI_LINKTABLE,
-        sizeof(struct versionStamp),
-      &tempHeader.linkTable, "link table", NO_LINK_TABLE},
+    int obsolete;
+} afs_common_inode_info[MAXINODETYPE] = {
+    {
+       {VOLUMEINFOMAGIC, VOLUMEINFOVERSION},
+       VI_VOLINFO,
+       sizeof(VolumeDiskData),
+       (Inode*)offsetof(struct VolumeHeader, volumeInfo),
+       "Volume information",
+       0
+    },
+    {
+       {SMALLINDEXMAGIC, SMALLINDEXVERSION},
+       VI_SMALLINDEX,
+       sizeof(struct versionStamp),
+       (Inode*)offsetof(struct VolumeHeader, smallVnodeIndex),
+       "small inode index",
+       0
+    },
+    {
+       {LARGEINDEXMAGIC, LARGEINDEXVERSION},
+       VI_LARGEINDEX,
+       sizeof(struct versionStamp),
+       (Inode*)offsetof(struct VolumeHeader, largeVnodeIndex),
+       "large inode index",
+       0
+    },
+    {
+       {ACLMAGIC, ACLVERSION},
+       VI_ACL,
+       sizeof(struct versionStamp),
+       (Inode*)offsetof(struct VolumeHeader, volumeAcl),
+       "access control list",
+       1
+    },
+    {
+       {MOUNTMAGIC, MOUNTVERSION},
+       VI_MOUNTTABLE,
+       sizeof(struct versionStamp),
+       (Inode*)offsetof(struct VolumeHeader, volumeMountTable),
+       "mount table",
+       1
+    },
+    {
+       {LINKTABLEMAGIC, LINKTABLEVERSION},
+       VI_LINKTABLE,
+       sizeof(struct versionStamp),
+       (Inode*)offsetof(struct VolumeHeader, linkTable),
+       "link table",
+       NO_LINK_TABLE
+    },
 };
 /* inodeType is redundant in the above table;  it used to be useful, but now
    we require the table to be ordered */
-#define MAXINODETYPE VI_LINKTABLE
 
-Volume *VWaitAttachVolume();
+/**
+ * initialize a struct afs_inode_info
+ *
+ * @param[in] header  the volume header struct to use when referencing volume
+ *                    header fields in 'stuff'
+ * @param[out] stuff  the struct afs_inode_info to initialize
+ *
+ */
+static_inline void
+init_inode_info(struct VolumeHeader *header,
+                struct afs_inode_info *stuff)
+{
+    int i;
+    memcpy(stuff, afs_common_inode_info, sizeof(afs_common_inode_info));
+    for (i = 0; i < MAXINODETYPE; i++) {
+       stuff[i].inode = (Inode*)((char*)header + (uintptr_t)stuff[i].inode);
+    }
+}
+
+#endif /* __volinodes_h_ */