Esempio n. 1
0
static int
new_entry(char *sname, char *type, char *mname, mdsetname_t *sp)
{
	mdname_t	*mdn;
	md_error_t	 error = *mdl_mdnullerror;

	mdn = (mdl_metaname)(&sp, sname, UNKNOWN, &error);
	if (!mdisok(&error)) {
	    (mdl_mdclrerror)(&error);
	    return (0);
	}

	if (mdn != NULL && (
	    mdn->drivenamep->type == MDT_ACCES ||
	    mdn->drivenamep->type == MDT_COMP ||
	    mdn->drivenamep->type == MDT_FAST_COMP)) {

	    return (add_use_record(mdn->bname, type, mname));
	}

	return (0);
}
Esempio n. 2
0
/*
 * SVM uses "drive names" (ctd name without trailing slice) for drives
 * in disksets.  Since it massages these names there is no direct correspondence
 * with the slice device names in /dev.  So, we need to massage these names
 * back to something we can match on when a slice comes in.  We create an
 * entry for each possible slice since we don't know what slices actually
 * exist.  Slice 0 & 7 are probably enough, but the user could have
 * repartitioned the drive after they added it to the diskset and removed the
 * mdb.
 */
static int
drive_in_diskset(char *dpath, char *setname)
{
	int i;
	char path[MAXPATHLEN];

	(void) strlcpy(path, dpath, sizeof (path));
	if (strncmp(path, "/dev/rdsk/", 10) == 0) {
	    /* change rdsk to dsk */
	    char *p;

	    /* start p pointing to r in rdsk */
	    for (p = path + 5; *p; p++) {
		*p = *(p + 1);
	    }
	} else if (strncmp(path, "/dev/did/rdsk/", 14) == 0) {
	    /* change rdsk to dsk */
	    char *p;

	    /* start p pointing to r in rdsk */
	    for (p = path + 9; *p; p++) {
		*p = *(p + 1);
	    }
	}

	for (i = 0; i < 8; i++) {
	    char slice[MAXPATHLEN];

	    (void) snprintf(slice, sizeof (slice), "%ss%d", path, i);
	    if (add_use_record(slice, "diskset", setname)) {
		return (ENOMEM);
	    }
	}

	return (0);
}
Esempio n. 3
0
static int
load_vfstab()
{
	FILE	*fp;
	struct	vfstab vp;
	int	status = 1;

	fp = fopen(VFSTAB, "r");
	if (fp != NULL) {
	    (void) memset(&vp, 0, sizeof (struct vfstab));
	    while (getvfsent(fp, &vp) == 0) {
		    status = add_use_record(&vp);
		    if (status != 0) {
			(void) fclose(fp);
			return (status);
		    }
		(void) memset(&vp, 0, sizeof (struct vfstab));
	    }
	    (void) fclose(fp);
	    status = 0;
	}

	return (status);
}