diff options
author | grog <grog@FreeBSD.org> | 2000-05-04 07:35:03 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2000-05-04 07:35:03 +0000 |
commit | 2e5ef3db368f237906125f954e76b3f5166ab372 (patch) | |
tree | 153a37561bbf0ccd080f0b103457eb935c313fee /sys/dev/vinum | |
parent | d0290ff674c66a4238f0e4143605558dbcb1c348 (diff) | |
download | FreeBSD-src-2e5ef3db368f237906125f954e76b3f5166ab372.zip FreeBSD-src-2e5ef3db368f237906125f954e76b3f5166ab372.tar.gz |
remove_drive: correctly obliterate the magic number.
Reported-by: phk
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r-- | sys/dev/vinum/vinumio.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 5c18ff7..efa76ad 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 */ } |