From 4555a3de623fb4a632f434ae4fc9a19dc7bdd5f9 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Mon, 19 May 2003 02:21:31 +0000 Subject: [PATCH] print_config: Change config format slightly to save plex preferences correctly. vinum_scandisk: reinitialise volatile pointer after function call. This is the "deafc0de" bug. Approved by: re (scottl) --- sys/dev/vinum/vinumio.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 9f4b01c813b3..aa10466033f0 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -33,7 +33,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumio.c,v 1.37 2003/05/04 05:23:42 grog Exp grog $ + * $Id: vinumio.c,v 1.38 2003/05/07 03:29:30 grog Exp grog $ * $FreeBSD$ */ @@ -153,7 +153,7 @@ init_drive(struct drive *drive, int verbose) if (drive->lasterror) { if (verbose) log(LOG_ERR, - "vinum: Can't get partition information for %s: error %d\n", + "vinum: Can't get drive dimensions for %s: error %d\n", drive->devicename, drive->lasterror); close_drive(drive); @@ -482,10 +482,9 @@ format_config(char *config, int len) drivename = "*invalid*"; snprintf(s, configend - s, - "sd name %s drive %s plex %s len %llus driveoffset %llus state %s", + "sd name %s drive %s len %llus driveoffset %llus state %s", sd->name, drivename, - vinum_conf.plex[sd->plexno].name, (unsigned long long) sd->sectors, (unsigned long long) sd->driveoffset, sd_state(sd->state)); @@ -494,7 +493,8 @@ format_config(char *config, int len) if (sd->plexno >= 0) snprintf(s, configend - s, - " plexoffset %llds", + " plex %s plexoffset %llds", + vinum_conf.plex[sd->plexno].name, (long long) sd->plexoffset); else snprintf(s, configend - s, " detached"); @@ -940,6 +940,14 @@ vinum_scandisk(char *devicename) *eptr = '\0'; /* and delimit */ if (setjmp(command_fail) == 0) { /* come back here on error and continue */ parse_status = parse_config(config_line, &keyword_set, 1); /* parse the config line */ + /* + * parse_config recognizes referenced + * drives and builds a drive entry for + * them. This may expand the drive + * table, thus invalidating the pointer. + */ + drive = &DRIVE[drivelist[driveno]]; /* point to the drive */ + if (parse_status < 0) { /* error in config */ /* * This config should have been parsed @@ -960,7 +968,7 @@ vinum_scandisk(char *devicename) cptr++; /* skip to next line */ } } - drive->flags |= VF_CONFIGURED; /* read this drive's configuration */ + drive->flags |= VF_CONFIGURED; /* this drive's configuration is complete */ } Free(config_text);