Example #1
0
int
VAttachPartitions(void)
{
    int errors = 0;
    FILE *mfd;
    struct mntent *mntent;

    if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
	Log("Problems in getting mount entries(setmntent)\n");
	exit(-1);
    }
    while (mntent = getmntent(mfd)) {
	if (!hasmntopt(mntent, MNTOPT_RW))
	    continue;

	/* Skip this Partition? */
	if (VIsNeverAttach(mntent->mnt_dir))
	    continue;

	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(mntent->mnt_dir, NULL))
	    continue;

	if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname, 0) < 0)
	    errors++;
    }

    endmntent(mfd);

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #2
0
int
VAttachPartitions(void)
{
    int errors = 0;
    FILE *mfd;
    struct mntent *mntent;

    if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
	if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
	    Log("Problems in getting mount entries(setmntent)\n");
	    exit(-1);
	}
    }
    while ((mntent = getmntent(mfd))) {
	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(mntent->mnt_dir))
	    continue;

	if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0)
	    errors++;
    }
    endmntent(mfd);

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #3
0
int
VAttachPartitions(void)
{
    int errors = 0;
    struct fstab *fsent;

    if (setfsent() < 0) {
	Log("Error listing filesystems.\n");
	exit(-1);
    }

    while ((fsent = getfsent())) {
	if (strcmp(fsent->fs_type, "rw") != 0)
	    continue;

	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(fsent->fs_file))
	    continue;

	if (VCheckPartition(fsent->fs_file, fsent->fs_spec) < 0)
	    errors++;
    }
    endfsent();

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #4
0
int
VAttachPartitions(void)
{
    int errors = 0;
    int nmounts;
    struct vmount *vmountp;

    if ((nmounts = getmount(&vmountp)) <= 0) {
	Log("Problems in getting # of mount entries(getmount)\n");
	exit(-1);
    }
    for (; nmounts;
	 nmounts--, vmountp =
	 (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
	char *part = vmt2dataptr(vmountp, VMT_STUB);

	if (vmountp->vmt_flags & (MNT_READONLY | MNT_REMOVABLE | MNT_REMOTE))
	    continue;		/* Ignore any "special" partitions */

#ifdef AFS_AIX42_ENV
#ifndef AFS_NAMEI_ENV
	{
	    struct superblock fs;
	    /* The Log statements are non-sequiters in the SalvageLog and don't
	     * even appear in the VolserLog, so restrict them to the FileLog.
	     */
	    if (ReadSuper(&fs, vmt2dataptr(vmountp, VMT_OBJECT)) < 0) {
		if (programType == fileServer)
		    Log("Can't read superblock for %s, ignoring it.\n", part);
		continue;
	    }
	    if (IsBigFilesFileSystem(&fs)) {
		if (programType == fileServer)
		    Log("%s is a big files filesystem, ignoring it.\n", part);
		continue;
	    }
	}
#endif
#endif

	/* Skip this Partition? */
	if (VIsNeverAttach(part))
	    continue;

	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(part, NULL))
	    continue;

	if (VCheckPartition(part, vmt2dataptr(vmountp, VMT_OBJECT), 0) < 0)
	    errors++;
    }

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #5
0
int
VAttachPartitions(void)
{
    int errors = 0;
    struct mnttab mnt;
    FILE *mntfile;

    if (!(mntfile = afs_fopen(MNTTAB, "r"))) {
	Log("Can't open %s\n", MNTTAB);
	perror(MNTTAB);
	exit(-1);
    }
    while (!getmntent(mntfile, &mnt)) {
	/* Ignore non ufs or non read/write partitions */
	/* but allow zfs too if we're in the NAMEI environment */
	if (
#ifdef AFS_NAMEI_ENV
	    (((strcmp(mnt.mnt_fstype, "ufs") &&
		strcmp(mnt.mnt_fstype, "zfs"))))
#else
	    (strcmp(mnt.mnt_fstype, "ufs") != 0)
#endif
	    || (strncmp(mnt.mnt_mntopts, "ro,ignore", 9) == 0))
	    continue;
	
	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(mnt.mnt_mountp))
	    continue;

#ifndef AFS_NAMEI_ENV
	if (hasmntopt(&mnt, "logging") != NULL) {
	    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", mnt.mnt_mountp);
	    errors++;
	}
#endif /* !AFS_NAMEI_ENV */

	if (VCheckPartition(mnt.mnt_mountp, mnt.mnt_special) < 0)
	    errors++;
    }

    (void)fclose(mntfile);

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #6
0
int
VAttachPartitions(void)
{
    int errors = 0;
    struct mnttab mnt;
    FILE *mntfile;

    if (!(mntfile = afs_fopen(MNTTAB, "r"))) {
	Log("Can't open %s\n", MNTTAB);
	perror(MNTTAB);
	exit(-1);
    }
    while (!getmntent(mntfile, &mnt)) {
	int logging = 0;
	/* Ignore non ufs or non read/write partitions */
	/* but allow zfs too if we're in the NAMEI environment */
	if (
#ifdef AFS_NAMEI_ENV
	    (((strcmp(mnt.mnt_fstype, "ufs") &&
		strcmp(mnt.mnt_fstype, "zfs"))))
#else
	    (strcmp(mnt.mnt_fstype, "ufs") != 0)
#endif
	    || (strncmp(mnt.mnt_mntopts, "ro,ignore", 9) == 0))
	    continue;

	/* Skip this Partition? */
	if (VIsNeverAttach(mnt.mnt_mountp))
	    continue;

	/* If we're going to always attach this partition, do it later. */
	if (VIsAlwaysAttach(mnt.mnt_mountp, NULL))
	    continue;

#ifndef AFS_NAMEI_ENV
	if (hasmntopt(&mnt, "logging") != NULL) {
	    logging = 1;
	}
#endif /* !AFS_NAMEI_ENV */

	if (VCheckPartition(mnt.mnt_mountp, mnt.mnt_special, logging) < 0)
	    errors++;
    }

    (void)fclose(mntfile);

    /* Process the always-attach partitions, if any. */
    VAttachPartitions2();

    return errors;
}
Example #7
0
/* VAttachPartitions2() looks for and attaches /vicepX partitions
 * where a special file (VICE_ALWAYSATTACH_FILE) exists.  This is
 * used to attach /vicepX directories which aren't on dedicated
 * partitions, in the NAMEI fileserver.
 */
static void
VAttachPartitions2(void)
{
#ifdef AFS_NAMEI_ENV
    DIR *dirp;
    struct dirent *de;
    char pname[32];
    int wouldattach;

    dirp = opendir(OS_DIRSEP);
    while ((de = readdir(dirp))) {
	strcpy(pname, OS_DIRSEP);
	strncat(pname, de->d_name, 20);
	pname[sizeof(pname) - 1] = '\0';

	/* Only keep track of "/vicepx" partitions since automounter
	 * may hose us */
	if (VIsAlwaysAttach(pname, &wouldattach)) {
	    VCheckPartition(pname, "", 0);
	} else {
	    struct afs_stat_st st;
	    if (wouldattach && VGetPartition(pname, 0) == NULL &&
	        afs_stat(pname, &st) == 0 && S_ISDIR(st.st_mode)) {

		/* This is a /vicep* dir, and it has not been attached as a
		 * partition. This probably means that this is a /vicep* dir
		 * that is not a separate partition, so just give a notice so
		 * admins are not confused as to why their /vicep* dirs are not
		 * being attached.
		 *
		 * It is possible that the dir _is_ a separate partition and we
		 * failed to attach it earlier, making this message a bit
		 * confusing. But that should be rare, and an error message
		 * about the failure will already be logged right before this,
		 * so it should be clear enough. */

		Log("VAttachPartitions: not attaching %s; either it is not a "
		    "separate partition, or it failed to attach (create the "
		    "file %s/" VICE_ALWAYSATTACH_FILE " to force attachment)\n",
		    pname, pname);
	    }
	}
    }
    closedir(dirp);
#endif /* AFS_NAMEI_ENV */
}
Example #8
0
/* VAttachPartitions2() looks for and attaches /vicepX partitions
 * where a special file (VICE_ALWAYSATTACH_FILE) exists.  This is
 * used to attach /vicepX directories which aren't on dedicated
 * partitions, in the NAMEI fileserver.
 */
void
VAttachPartitions2(void)
{
#ifdef AFS_NAMEI_ENV
    DIR *dirp;
    struct dirent *de;
    char pname[32];

    dirp = opendir("/");
    while ((de = readdir(dirp))) {
	strcpy(pname, "/");
	strncat(pname, de->d_name, 20);
	pname[sizeof(pname) - 1] = '\0';

	/* Only keep track of "/vicepx" partitions since automounter
	 * may hose us */
	if (VIsAlwaysAttach(pname))
	    VCheckPartition(pname, "");
    }
    closedir(dirp);
#endif /* AFS_NAMEI_ENV */
}
Example #9
0
int
VAttachPartitions(void)
{
    struct DiskPartition64 *partP, *prevP, *nextP;
    struct vpt_iter iter;
    struct vptab entry;

    if (vpt_Start(&iter) < 0) {
	Log("No partitions to attach.\n");
	return 0;
    }

    while (0 == vpt_NextEntry(&iter, &entry)) {
	if (!VValidVPTEntry(&entry)) {
	    continue;
	}

	/* This test for duplicates relies on the fact that the method
	 * of storing the partition names in the NT registry means the same
	 * partition name will never appear twice in the list.
	 */
	for (partP = DiskPartitionList; partP; partP = partP->next) {
	    if (*partP->devName == *entry.vp_dev) {
		Log("Same drive (%s) used for both partition %s and partition %s, ignoring both.\n", entry.vp_dev, partP->name, entry.vp_name);
		partP->flags = PART_DUPLICATE;
		break;		/* Only one entry will ever be in this list. */
	    }
	}
	if (partP)
	    continue;		/* found a duplicate */

	if (VCheckPartition(entry.vp_dev) < 0)
	    continue;
	/* This test allows for manually inserting the FORCESALVAGE flag
	 * and thereby invoking the salvager. scandisk obviously won't be
	 * doing this for us.
	 */
	if (programType == fileServer) {
	    struct afs_stat status;
	    char salvpath[MAXPATHLEN];
	    strcpy(salvpath, entry.vp_dev);
	    strcat(salvpath, "\\FORCESALVAGE");
	    if (afs_stat(salvpath, &status) == 0) {
		Log("VAttachPartitions: Found %s; aborting\n", salvpath);
		exit(1);
	    }
	}
	VInitPartition(entry.vp_name, entry.vp_dev, *entry.vp_dev - 'A');
    }
    vpt_Finish(&iter);

    /* Run through partition list and clear out the dupes. */
    prevP = nextP = NULL;
    for (partP = DiskPartitionList; partP; partP = nextP) {
	nextP = partP->next;
	if (partP->flags == PART_DUPLICATE) {
	    if (prevP)
		prevP->next = partP->next;
	    else
		DiskPartitionList = partP->next;
	    free(partP);
	} else
	    prevP = partP;
    }

    return 0;
}