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.
12 #include <afsconfig.h>
17 #include <afs/param.h>
18 #ifdef AFS_SGI_XFS_IOPS_ENV
25 #include "partition.h"
26 #ifdef AFS_SGI_EFS_IOPS_ENV
27 #include "../sgiefs/efs.h"
29 #include <afs/xfsattrs.h>
31 char *prog = "xfs_size_check";
33 /* Verify that the on disk XFS inodes on the partition are large enough to
34 * hold the AFS attribute. Returns -1 if the attribute can't be set or is
35 * too small to fit in the inode. Returns 0 if the attribute does fit in
38 #define VERIFY_ERROR -1
41 static int VerifyXFSInodeSize(char *part)
44 int length = SIZEOF_XFS_ATTR_T;
46 int code = VERIFY_ERROR;
49 if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT)<0) {
51 printf("Must be root to run %s\n", prog);
57 if ((fd=open(part, O_RDONLY, 0))<0)
60 if (fcntl(fd, F_FSGETXATTRA, &fsx)<0)
63 if (fsx.fsx_nextents == 0)
71 (void) attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT);
76 #define ALLOC_STEP 256
79 char partName[NAME_SIZE];
80 char devName[NAME_SIZE];
82 partInfo *partList = NULL;
89 struct mntent *mntent;
96 if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
97 printf("Problems in getting mount entries(setmntent): %s\n",
101 while (mntent = getmntent(mfd)) {
102 char *part = mntent->mnt_dir;
104 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
106 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
107 continue; /* Non /vicepx; ignore */
109 if (stat(part, &status) == -1) {
110 printf("Couldn't find file system %s; ignored\n", part);
113 if (!strcmp("xfs", status.st_fstype)) {
114 code = VerifyXFSInodeSize(part);
119 printf("%s: Can't check XFS inode size: %s\n", strerror(errno));
122 if (nAvail <= nParts) {
123 nAvail += ALLOC_STEP;
124 if (nAvail == ALLOC_STEP)
125 partList = (partInfo*)malloc(nAvail*sizeof(partInfo));
127 partList = (partInfo*)realloc((char*)partList,
128 nAvail*sizeof(partInfo));
130 printf("Failed to %salloc %d bytes for partition list.\n",
131 (nAvail == ALLOC_STEP) ? "m" : "re",
132 nAvail*sizeof(partInfo));
136 (void) strcpy(partList[nParts].partName, part);
137 (void) strcpy(partList[nParts].devName, mntent->mnt_fsname);
141 printf("Unknown return code %d from VerifyXFSInodeSize.\n",
151 main(int ac, char **av)
157 printf("Must be root to run %s.\n", prog);
161 code = CheckPartitions();
163 printf("Need to remake the following partitions:\n");
164 for (i=0; i<nParts; i++) {
165 printf("%s: mkfs -t xfs -i size=512 -l size=4000b %s\n",
166 partList[i].partName, partList[i].devName);
173 #else /* AFS_SGI_XFS_IOPS_ENV */
174 main() {printf("%s only runs on XFS platforms.\n, prog"); exit(1); }
175 #endif /* AFS_SGI_XFS_IOPS_ENV */