int CheckPartitions() { int i; struct mntent *mntent; FILE *mfd; DIR *dirp; struct dirent *dp; struct stat status; int code; if ((mfd = setmntent(MOUNTED, "r")) == NULL) { printf("Problems in getting mount entries(setmntent): %s\n", strerror(errno)); exit(-1); } while (mntent = getmntent(mfd)) { char *part = mntent->mnt_dir; if (!hasmntopt(mntent, MNTOPT_RW)) continue; if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) { continue; /* Non /vicepx; ignore */ } if (stat(part, &status) == -1) { printf("Couldn't find file system %s; ignored\n", part); continue; } if (!strcmp("xfs", status.st_fstype)) { code = VerifyXFSInodeSize(part); switch (code) { case VERIFY_OK: break; case VERIFY_ERROR: printf("%s: Can't check XFS inode size: %s\n", strerror(errno)); break; case VERIFY_FIX: if (nAvail <= nParts) { nAvail += ALLOC_STEP; if (nAvail == ALLOC_STEP) partList = malloc(nAvail * sizeof(partInfo)); else partList = realloc(partList, nAvail * sizeof(partInfo)); if (!partList) { printf ("Failed to %salloc %d bytes for partition list.\n", (nAvail == ALLOC_STEP) ? "m" : "re", nAvail * sizeof(partInfo)); exit(1); } } (void)strcpy(partList[nParts].partName, part); (void)strcpy(partList[nParts].devName, mntent->mnt_fsname); nParts++; break; default: printf("Unknown return code %d from VerifyXFSInodeSize.\n", code); abort(); } } } return nParts; }
/* VAttachPartitions() finds the vice partitions on this server. Calls * VCheckPartition() to do some basic checks on the partition. If the partition * is a valid vice partition, VCheckPartition will add it to the DiskPartition * list. * Returns the number of errors returned by VCheckPartition. An error in * VCheckPartition means that partition is a valid vice partition but the * fileserver should not start because of the error found on that partition. * * AFS_NAMEI_ENV * No specific user space file system checks, since we don't know what * is being used for vice partitions. * * Use partition name as devname. */ int VCheckPartition(char *part, char *devname) { struct afs_stat status; #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV) char AFSIDatPath[MAXPATHLEN]; #endif /* Only keep track of "/vicepx" partitions since it can get hairy * when NFS mounts are involved.. */ if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) { return 0; } if (afs_stat(part, &status) < 0) { Log("VInitVnodes: Couldn't find file system %s; ignored\n", part); return 0; } #ifndef AFS_AIX32_ENV if (programType == fileServer) { char salvpath[MAXPATHLEN]; strcpy(salvpath, part); strcat(salvpath, "/FORCESALVAGE"); if (afs_stat(salvpath, &status) == 0) { Log("VInitVnodes: Found %s; aborting\n", salvpath); return -1; } } #endif #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV) strcpy(AFSIDatPath, part); strcat(AFSIDatPath, "/AFSIDat"); #ifdef AFS_NAMEI_ENV if (afs_stat(AFSIDatPath, &status) < 0) { DIR *dirp; struct dirent *dp; dirp = opendir(part); assert(dirp); while ((dp = readdir(dirp))) { if (dp->d_name[0] == 'V') { Log("This program is compiled with AFS_NAMEI_ENV, but partition %s seems to contain volumes which don't use the namei-interface; aborting\n", part); closedir(dirp); return -1; } } closedir(dirp); } #else /* AFS_NAMEI_ENV */ if (afs_stat(AFSIDatPath, &status) == 0) { Log("This program is compiled without AFS_NAMEI_ENV, but partition %s seems to contain volumes which use the namei-interface; aborting\n", part); return -1; } #ifdef AFS_SGI_XFS_IOPS_ENV if (VerifyXFSInodeSize(part, status.st_fstype) < 0) return -1; #endif #endif /* AFS_NAMEI_ENV */ #endif /* !AFS_LINUX20_ENV && !AFS_NT40_ENV */ #if defined(AFS_DUX40_ENV) && !defined(AFS_NAMEI_ENV) if (status.st_ino != ROOTINO) { Log("%s is not a mounted file system; ignored.\n", part); return 0; } #endif VInitPartition(part, devname, status.st_dev); return 0; }
/* VAttachPartitions() finds the vice partitions on this server. Calls * VCheckPartition() to do some basic checks on the partition. If the partition * is a valid vice partition, VCheckPartition will add it to the DiskPartition * list. * Returns the number of errors returned by VCheckPartition. An error in * VCheckPartition means that partition is a valid vice partition but the * fileserver should not start because of the error found on that partition. * * AFS_NAMEI_ENV * No specific user space file system checks, since we don't know what * is being used for vice partitions. * * Use partition name as devname. */ static int VCheckPartition(char *part, char *devname, int logging) { struct afs_stat_st status; #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV) char AFSIDatPath[MAXPATHLEN]; #endif /* Only keep track of "/vicepx" partitions since it can get hairy * when NFS mounts are involved.. */ if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) { return 0; } if (volutil_GetPartitionID(part) == -1) { Log("Warning: %s is a bad partition name; ignored.\n", part); return 0; } if (afs_stat(part, &status) < 0) { Log("VInitVnodes: Couldn't find file system %s; ignored\n", part); return 0; } if (logging) { Log("This program is compiled without AFS_NAMEI_ENV, and " "partition %s is mounted with the 'logging' option. " "Using the inode fileserver backend with 'logging' UFS " "partitions causes volume corruption, so please either " "mount the partition without logging, or use the namei " "fileserver backend. Aborting...\n", part); return -1; } #ifndef AFS_AIX32_ENV if (programType == fileServer) { char salvpath[MAXPATHLEN]; strcpy(salvpath, part); strcat(salvpath, "/FORCESALVAGE"); if (afs_stat(salvpath, &status) == 0) { Log("VInitVnodes: Found %s; aborting\n", salvpath); return -1; } } #endif #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV) strcpy(AFSIDatPath, part); strcat(AFSIDatPath, "/AFSIDat"); #ifdef AFS_NAMEI_ENV if (afs_stat(AFSIDatPath, &status) < 0) { DIR *dirp; struct dirent *dp; dirp = opendir(part); opr_Assert(dirp); while ((dp = readdir(dirp))) { if (dp->d_name[0] == 'V') { Log("This program is compiled with AFS_NAMEI_ENV, but partition %s seems to contain volumes which don't use the namei-interface; aborting\n", part); closedir(dirp); return -1; } } closedir(dirp); } #else /* AFS_NAMEI_ENV */ if (afs_stat(AFSIDatPath, &status) == 0) { Log("This program is compiled without AFS_NAMEI_ENV, but partition %s seems to contain volumes which use the namei-interface; aborting\n", part); return -1; } #ifdef AFS_SGI_XFS_IOPS_ENV if (VerifyXFSInodeSize(part, status.st_fstype) < 0) return -1; #endif #endif /* AFS_NAMEI_ENV */ #endif /* !AFS_LINUX20_ENV && !AFS_NT40_ENV */ VInitPartition(part, devname, status.st_dev); return 0; }