struct VolumeDiskHeader diskHeader;
afs_int32 (*writefunc)(VolumeDiskHeader_t *, struct DiskPartition64 *) = NULL;
int *skip;
+ struct VolumeHeader tempHeader;
+ struct afs_inode_info stuff[MAXINODETYPE];
/* keeps track of special inodes that are probably 'good'; they are
* referenced in the vol header, and are included in the given inodes
* if we detect duplicate special inodes */
}
+ init_inode_info(&tempHeader, stuff);
+
/*
* First, look at the special inodes and see if any are referenced by
* the existing volume header. If we find duplicate special inodes, we
}
int
-SalvageHeader(struct SalvInfo *salvinfo, struct stuff *sp,
+SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
struct InodeSummary *isp, int check, int *deleteMe)
{
union {
#ifndef __volinodes_h_
#define __volinodes_h_
-/* Used by vutil.c and salvager.c */
+#include <stddef.h>
-private struct VolumeHeader tempHeader;
+/* Used by vutil.c and salvager.c */
#ifdef AFS_NAMEI_ENV
#define NO_LINK_TABLE 0
#else
#define NO_LINK_TABLE 1
#endif
-AFS_UNUSED
-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 */
* 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},};
+} 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
+
+/**
+ * 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_ */
#define afs_open open
#endif /* !O_LARGEFILE */
-#define nFILES (sizeof (stuff)/sizeof(struct stuff))
/* Note: the volume creation functions herein leave the destroyMe flag in the
volume header ON: this means that the volumes will not be attached by the
#ifdef FSSYNC_BUILD_CLIENT
static void
-RemoveInodes(Device dev, VolumeId vid)
+RemoveInodes(struct afs_inode_info *stuff, Device dev, VolumeId vid)
{
int i;
IHandle_t *handle;
* needs the dev and vid to decrement volume special files.
*/
IH_INIT(handle, dev, vid, -1);
- for (i = 0; i < nFILES; i++) {
+ for (i = 0; i < MAXINODETYPE; i++) {
Inode inode = *stuff[i].inode;
if (VALID_INO(inode))
IH_DEC(handle, inode, vid);
Inode nearInode = 0;
char *part, *name;
struct stat st;
+ struct VolumeHeader tempHeader;
+ struct afs_inode_info stuff[MAXINODETYPE];
# ifdef AFS_DEMAND_ATTACH_FS
int locktype = 0;
# endif /* AFS_DEMAND_ATTACH_FS */
+ init_inode_info(&tempHeader, stuff);
+
*ec = 0;
memset(&vol, 0, sizeof(vol));
vol.id = volumeId;
}
device = partition->device;
- for (i = 0; i < nFILES; i++) {
- struct stuff *p = &stuff[i];
+ for (i = 0; i < MAXINODETYPE; i++) {
+ struct afs_inode_info *p = &stuff[i];
if (p->obsolete)
continue;
#ifdef AFS_NAMEI_ENV
bad:
if (handle)
IH_RELEASE(handle);
- RemoveInodes(device, vol.id);
+ RemoveInodes(stuff, device, vol.id);
if (!*ec) {
*ec = VNOVOL;
}