/* $NetBSD: config.c,v 1.5 2008/04/28 20:24:17 martin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1999 Michael Smith
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from FreeBSD: config.c,v 1.2 2000/04/11 23:04:17 msmith Exp
*/
#ifndef lint
#include <sys/cdefs.h>
__RCSID("$NetBSD: config.c,v 1.5 2008/04/28 20:24:17 martin Exp $");
#endif /* not lint */
/*
* Get the configuration from the selected controller.
*
* config <controller>
* Print the configuration for <controller>
*
* XXX update to support adding/deleting drives.
*/
int
cmd_config(char **argv)
{
char hostname[MAXHOSTNAMELEN];
struct conf_config conf;
int i, j;
if (ci.ci_firmware_id[0] < 3) {
warnx("action not supported by this firmware version");
return (1);
}
gethostname(hostname, sizeof(hostname));
printf("# controller %s on %s\n", mlxname, hostname);
printf("#\n# physical devices connected:\n");
for (i = 0; i < 5; i++)
for (j = 0; j < 16; j++)
print_phys_drive(&conf, i, j);
printf("#\n# system drives defined:\n");
for (i = 0; i < conf.cc_cfg.cc_num_sys_drives; i++)
print_sys_drive(&conf, i);
return(0);
}
/*
* Print details for the system drive (drvno) in a format that we will be
* able to parse later.
*
* drive?? <raidlevel> <writemode>
* span? 0x????????-0x???????? ????blks on <disk> [...]
* ...
*/
static void
print_span(struct mlx_sys_drv_span *span, int arms)
{
int i;
for (i = 0; i < drv->sd_valid_spans; i++) {
printf(" span%d ", i);
print_span(&drv->sd_span[i], drv->sd_valid_arms);
}
}
/*
* Print details for the physical drive at chn/targ in a format suitable for
* human consumption.
*/
static void
print_phys_drive(struct conf_config *conf, int chn, int targ)
{
struct mlx_phys_drv *pd;