diff options
author | grog <grog@FreeBSD.org> | 2001-01-10 05:02:44 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2001-01-10 05:02:44 +0000 |
commit | 4bd6619275bc95b21aa473bef8e6b8b87f569f98 (patch) | |
tree | c649daca279841bf6c88ca75b75ecb1862046ede /sys/dev/vinum | |
parent | 16c617b81881c4af5065f6e7024370870cde36ee (diff) | |
download | FreeBSD-src-4bd6619275bc95b21aa473bef8e6b8b87f569f98.zip FreeBSD-src-4bd6619275bc95b21aa473bef8e6b8b87f569f98.tar.gz |
open_drive: Refuse to open partition c of a disk device.
This should eliminate one case of foot shooting .
vinum_scandisk: If a drive in the partition table is downed, free it.
This duplicates code for the compatibility partition, which for some
reason was omitted here.
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r-- | sys/dev/vinum/vinumio.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 5bd385f..511b8fa 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -115,16 +115,19 @@ open_drive(struct drive *drive, struct proc *p, int verbose) return ENODEV; devminor = ((unit & 31) << 3) /* unit */ +(dname[2] - 'a') /* partition */ - +((dname[1] - '0' + 1) << 16) /* slice */ + +((dname[1] - '0' + 1) << 16) /* slice */ +((unit & ~31) << 16); /* high-order unit bits */ } else { /* compatibility partition */ if ((*dname < 'a') || (*dname > 'h')) /* or invalid partition */ return ENODEV; devminor = (*dname - 'a') /* partition */ - +((unit & 31) << 3) /* unit */ + +((unit & 31) << 3) /* unit */ +((unit & ~31) << 16); /* high-order unit bits */ } + if ((unit & 7) == 2) /* partition c */ + return ENOTTY; /* not buying that */ + drive->dev = makedev(devmajor, devminor); /* find the device */ if (drive->dev == NULL) /* didn't find anything */ return ENODEV; @@ -411,8 +414,8 @@ check_drive(char *devicename) if (read_drive_label(drive, 0) == DL_OURS) { /* one of ours */ for (i = 0; i < vinum_conf.drives_allocated; i++) { /* see if the name already exists */ if ((i != driveno) /* not this drive */ - &&(DRIVE[i].state != drive_unallocated) /* and it's allocated */ - &&(strcmp(DRIVE[i].label.name, +&&(DRIVE[i].state != drive_unallocated) /* and it's allocated */ + &&(strcmp(DRIVE[i].label.name, DRIVE[driveno].label.name) == 0)) { /* and it has the same name */ struct drive *mydrive = &DRIVE[i]; @@ -843,7 +846,8 @@ vinum_scandisk(char *devicename[], int drives) slice, part); drive = check_drive(partname); /* try to open it */ - if (drive->lasterror != 0) /* didn't work, */ + if ((drive->lasterror != 0) /* didn't work, */ + ||(drive->state != drive_up)) free_drive(drive); /* get rid of it */ else if (drive->flags & VF_CONFIGURED) /* already read this config, */ log(LOG_WARNING, |