2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* Verify that the size of the XFS inode is large enough to hold the XFS
11 * attribute for AFS inode parameters. Check all the mounted /vicep partitions.
13 #include <afs/param.h>
14 #ifdef AFS_SGI_XFS_IOPS_ENV
21 #include "partition.h"
22 #include "../sgiefs/efs.h"
23 #include <afs/xfsattrs.h>
25 char *prog = "xfs_size_check";
27 /* Verify that the on disk XFS inodes on the partition are large enough to
28 * hold the AFS attribute. Returns -1 if the attribute can't be set or is
29 * too small to fit in the inode. Returns 0 if the attribute does fit in
32 #define VERIFY_ERROR -1
35 static int VerifyXFSInodeSize(char *part)
38 int length = SIZEOF_XFS_ATTR_T;
40 int code = VERIFY_ERROR;
43 if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT)<0) {
45 printf("Must be root to run %s\n", prog);
51 if ((fd=open(part, O_RDONLY, 0))<0)
54 if (fcntl(fd, F_FSGETXATTRA, &fsx)<0)
57 if (fsx.fsx_nextents == 0)
65 (void) attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT);
70 #define ALLOC_STEP 256
73 char partName[NAME_SIZE];
74 char devName[NAME_SIZE];
76 partInfo *partList = NULL;
83 struct mntent *mntent;
90 if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
91 printf("Problems in getting mount entries(setmntent): %s\n",
95 while (mntent = getmntent(mfd)) {
96 char *part = mntent->mnt_dir;
98 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
100 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
101 continue; /* Non /vicepx; ignore */
103 if (stat(part, &status) == -1) {
104 printf("Couldn't find file system %s; ignored\n", part);
107 if (!strcmp("xfs", status.st_fstype)) {
108 code = VerifyXFSInodeSize(part);
113 printf("%s: Can't check XFS inode size: %s\n", strerror(errno));
116 if (nAvail <= nParts) {
117 nAvail += ALLOC_STEP;
118 if (nAvail == ALLOC_STEP)
119 partList = (partInfo*)malloc(nAvail*sizeof(partInfo));
121 partList = (partInfo*)realloc((char*)partList,
122 nAvail*sizeof(partInfo));
124 printf("Failed to %salloc %d bytes for partition list.\n",
125 (nAvail == ALLOC_STEP) ? "m" : "re",
126 nAvail*sizeof(partInfo));
130 (void) strcpy(partList[nParts].partName, part);
131 (void) strcpy(partList[nParts].devName, mntent->mnt_fsname);
135 printf("Unknown return code %d from VerifyXFSInodeSize.\n",
145 main(int ac, char **av)
151 printf("Must be root to run %s.\n", prog);
155 code = CheckPartitions();
157 printf("Need to remake the following partitions:\n");
158 for (i=0; i<nParts; i++) {
159 printf("%s: mkfs -t xfs -i size=512 -l size=4000b %s\n",
160 partList[i].partName, partList[i].devName);
167 #else /* AFS_SGI_XFS_IOPS_ENV */
168 main() {printf("%s only runs on XFS platforms.\n, prog"); exit(1); }
169 #endif /* AFS_SGI_XFS_IOPS_ENV */