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
42 VerifyXFSInodeSize(char *part)
45 int length = SIZEOF_XFS_ATTR_T;
47 int code = VERIFY_ERROR;
50 if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT) < 0) {
52 printf("Must be root to run %s\n", prog);
58 if ((fd = open(part, O_RDONLY, 0)) < 0)
61 if (fcntl(fd, F_FSGETXATTRA, &fsx) < 0)
64 if (fsx.fsx_nextents == 0)
72 (void)attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT);
77 #define ALLOC_STEP 256
80 char partName[NAME_SIZE];
81 char devName[NAME_SIZE];
83 partInfo *partList = NULL;
91 struct mntent *mntent;
98 if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
99 printf("Problems in getting mount entries(setmntent): %s\n",
103 while (mntent = getmntent(mfd)) {
104 char *part = mntent->mnt_dir;
106 if (!hasmntopt(mntent, MNTOPT_RW))
109 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
110 continue; /* Non /vicepx; ignore */
112 if (stat(part, &status) == -1) {
113 printf("Couldn't find file system %s; ignored\n", part);
116 if (!strcmp("xfs", status.st_fstype)) {
117 code = VerifyXFSInodeSize(part);
122 printf("%s: Can't check XFS inode size: %s\n",
126 if (nAvail <= nParts) {
127 nAvail += ALLOC_STEP;
128 if (nAvail == ALLOC_STEP)
130 (partInfo *) malloc(nAvail * sizeof(partInfo));
133 (partInfo *) realloc((char *)partList,
134 nAvail * sizeof(partInfo));
137 ("Failed to %salloc %d bytes for partition list.\n",
138 (nAvail == ALLOC_STEP) ? "m" : "re",
139 nAvail * sizeof(partInfo));
143 (void)strcpy(partList[nParts].partName, part);
144 (void)strcpy(partList[nParts].devName, mntent->mnt_fsname);
148 printf("Unknown return code %d from VerifyXFSInodeSize.\n",
158 main(int ac, char **av)
164 printf("Must be root to run %s.\n", prog);
168 code = CheckPartitions();
170 printf("Need to remake the following partitions:\n");
171 for (i = 0; i < nParts; i++) {
172 printf("%s: mkfs -t xfs -i size=512 -l size=4000b %s\n",
173 partList[i].partName, partList[i].devName);
180 #else /* AFS_SGI_XFS_IOPS_ENV */
183 printf("%s only runs on XFS platforms.\n, prog");
186 #endif /* AFS_SGI_XFS_IOPS_ENV */