aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorGreg Lehey <grog@FreeBSD.org>2000-05-04 07:35:03 +0000
committerGreg Lehey <grog@FreeBSD.org>2000-05-04 07:35:03 +0000
commit46aebdeaea167da0fbf07f2c2333e586f1426a24 (patch)
treed85986e06c73a9b71f2ccdeab4c6a48a4db89626 /sys/dev
parentcf53cf132bc451a0b1a6cab29c3ddd3da64ad426 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/vinum/vinumio.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c
index 5c18ff71600c..efa76adab4b4 100644
--- a/sys/dev/vinum/vinumio.c
+++ b/sys/dev/vinum/vinumio.c
@@ -261,20 +261,28 @@ close_locked_drive(struct drive *drive)
/*
* Remove drive from the configuration.
- * Caller must ensure that it isn't active
+ * Caller must ensure that it isn't active.
*/
void
remove_drive(int driveno)
{
struct drive *drive = &vinum_conf.drive[driveno];
- int64_t nomagic = VINUM_NOMAGIC; /* no magic number */
+ struct vinum_hdr *vhdr; /* buffer for header */
+ int error;
if (drive->state > drive_referenced) { /* real drive */
- if (drive->state == drive_up)
- write_drive(drive, /* obliterate the magic, but leave a hint */
- (char *) &nomagic,
- 8,
- VINUM_LABEL_OFFSET);
+ if (drive->state == drive_up) {
+ vhdr = (struct vinum_hdr *) Malloc(VINUMHEADERLEN); /* allocate buffer */
+ CHECKALLOC(vhdr, "Can't allocate memory");
+ error = read_drive(drive, (void *) vhdr, VINUMHEADERLEN, VINUM_LABEL_OFFSET);
+ if (error)
+ drive->lasterror = error;
+ else {
+ vhdr->magic = VINUM_NOMAGIC; /* obliterate the magic, but leave the rest */
+ write_drive(drive, (void *) vhdr, VINUMHEADERLEN, VINUM_LABEL_OFFSET);
+ }
+ Free(vhdr);
+ }
free_drive(drive); /* close it and free resources */
save_config(); /* and save the updated configuration */
}