Allow components to be specified by wedge name.

This commit is contained in:
mlelstv 2020-09-13 06:04:53 +00:00
parent f605dcf5dd
commit edc4e8445d
1 changed files with 16 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $ */ /* $NetBSD: raidctl.c,v 1.72 2020/09/13 06:04:53 mlelstv Exp $ */
/*- /*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $"); __RCSID("$NetBSD: raidctl.c,v 1.72 2020/09/13 06:04:53 mlelstv Exp $");
#endif #endif
@ -92,6 +92,13 @@ int verbose;
static const char *rootpart[] = { "No", "Force", "Soft", "*invalid*" }; static const char *rootpart[] = { "No", "Force", "Soft", "*invalid*" };
static void
get_comp(char *buf, char *arg, size_t bufsz)
{
if (getfsspecname(buf, bufsz, arg) == NULL)
errx(1,"%s",buf);
}
int int
main(int argc,char *argv[]) main(int argc,char *argv[])
{ {
@ -131,7 +138,7 @@ main(int argc,char *argv[])
switch(ch) { switch(ch) {
case 'a': case 'a':
action = RAIDFRAME_ADD_HOT_SPARE; action = RAIDFRAME_ADD_HOT_SPARE;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
num_options++; num_options++;
break; break;
case 'A': case 'A':
@ -159,19 +166,19 @@ main(int argc,char *argv[])
break; break;
case 'f': case 'f':
action = RAIDFRAME_FAIL_DISK; action = RAIDFRAME_FAIL_DISK;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
do_recon = 0; do_recon = 0;
num_options++; num_options++;
break; break;
case 'F': case 'F':
action = RAIDFRAME_FAIL_DISK; action = RAIDFRAME_FAIL_DISK;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
do_recon = 1; do_recon = 1;
num_options++; num_options++;
break; break;
case 'g': case 'g':
action = RAIDFRAME_GET_COMPONENT_LABEL; action = RAIDFRAME_GET_COMPONENT_LABEL;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
openmode = O_RDONLY; openmode = O_RDONLY;
num_options++; num_options++;
break; break;
@ -209,16 +216,16 @@ main(int argc,char *argv[])
break; break;
case 'l': case 'l':
action = RAIDFRAME_SET_COMPONENT_LABEL; action = RAIDFRAME_SET_COMPONENT_LABEL;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
num_options++; num_options++;
break; break;
case 'r': case 'r':
action = RAIDFRAME_REMOVE_HOT_SPARE; action = RAIDFRAME_REMOVE_HOT_SPARE;
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
num_options++; num_options++;
break; break;
case 'R': case 'R':
strlcpy(component, optarg, sizeof(component)); get_comp(component, optarg, sizeof(component));
action = RAIDFRAME_REBUILD_IN_PLACE; action = RAIDFRAME_REBUILD_IN_PLACE;
num_options++; num_options++;
break; break;