FreeBSD/sys/geom/vinum/geom_vinum_subr.c
/*
 * Format the vinum configuration properly.  If ondisk is non-zero then the
 * configuration is intended to be written to disk later.
 */
Format the vinum configuration properly.  If ondisk is non-zero then the
configuration is intended to be written to disk later.
Format the vinum configuration properly . If ondisk is non - zero then the configuration is intended to be written to disk later .
void
gv_format_config(struct gv_softc *sc, struct sbuf *sb, int ondisk, char *prefix)
{
	struct gv_drive *d;
	struct gv_sd *s;
	struct gv_plex *p;
	struct gv_volume *v;
	if (!ondisk) {
		LIST_FOREACH(d, &sc->drives, drive) {
			sbuf_printf(sb, "%sdrive %s device /dev/%s\n", prefix,
			    d->name, d->device);
		}
	}
	LIST_FOREACH(v, &sc->volumes, volume) {
		if (!ondisk)
			sbuf_printf(sb, "%s", prefix);
		sbuf_printf(sb, "volume %s", v->name);
		if (ondisk)
			sbuf_printf(sb, " state %s", gv_volstate(v->state));
		sbuf_printf(sb, "\n");
	}
	LIST_FOREACH(p, &sc->plexes, plex) {
		if (!ondisk)
			sbuf_printf(sb, "%s", prefix);
		sbuf_printf(sb, "plex name %s org %s ", p->name,
		    gv_plexorg(p->org));
		if (gv_is_striped(p))
			sbuf_printf(sb, "%ds ", p->stripesize / 512);
		if (p->vol_sc != NULL)
			sbuf_printf(sb, "vol %s", p->volume);
		if (ondisk)
			sbuf_printf(sb, " state %s", gv_plexstate(p->state));
		sbuf_printf(sb, "\n");
	}
	LIST_FOREACH(s, &sc->subdisks, sd) {
		if (!ondisk)
			sbuf_printf(sb, "%s", prefix);
		sbuf_printf(sb, "sd name %s drive %s len %jds driveoffset "
		    "%jds", s->name, s->drive, s->size / 512,
		    s->drive_offset / 512);
		if (s->plex_sc != NULL) {
			sbuf_printf(sb, " plex %s plexoffset %jds", s->plex,
			    s->plex_offset / 512);
		}
		if (ondisk)
			sbuf_printf(sb, " state %s", gv_sdstate(s->state));
		sbuf_printf(sb, "\n");
	}
}
void gv_format_config ( struct gv_softc * sc , struct sbuf * sb , int ondisk , char * prefix ) { struct gv_drive * d ; struct gv_sd * s ; struct gv_plex * p ; struct gv_volume * v ; if ( ! ondisk ) { LIST_FOREACH ( d , & sc -> drives , drive ) { sbuf_printf ( sb , " \n " , prefix , d -> name , d -> device ) ; } } LIST_FOREACH ( v , & sc -> volumes , volume ) { if ( ! ondisk ) sbuf_printf ( sb , " " , prefix ) ; sbuf_printf ( sb , " " , v -> name ) ; if ( ondisk ) sbuf_printf ( sb , " " , gv_volstate ( v -> state ) ) ; sbuf_printf ( sb , " \n " ) ; } LIST_FOREACH ( p , & sc -> plexes , plex ) { if ( ! ondisk ) sbuf_printf ( sb , " " , prefix ) ; sbuf_printf ( sb , " " , p -> name , gv_plexorg ( p -> org ) ) ; if ( gv_is_striped ( p ) ) sbuf_printf ( sb , " " , p -> stripesize / 512 ) ; if ( p -> vol_sc != NULL ) sbuf_printf ( sb , " " , p -> volume ) ; if ( ondisk ) sbuf_printf ( sb , " " , gv_plexstate ( p -> state ) ) ; sbuf_printf ( sb , " \n " ) ; } LIST_FOREACH ( s , & sc -> subdisks , sd ) { if ( ! ondisk ) sbuf_printf ( sb , " " , prefix ) ; sbuf_printf ( sb , " " " " , s -> name , s -> drive , s -> size / 512 , s -> drive_offset / 512 ) ; if ( s -> plex_sc != NULL ) { sbuf_printf ( sb , " " , s -> plex , s -> plex_offset / 512 ) ; } if ( ondisk ) sbuf_printf ( sb , " " , gv_sdstate ( s -> state ) ) ; sbuf_printf ( sb , " \n " ) ; } }
Format the vinum configuration properly.
Format the vinum configuration properly .
/*
	 * We don't need the drive configuration if we're not writing the
	 * config to disk.
	 */