Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/raidctl Implement "raidctl -t config-file"



details:   https://anonhg.NetBSD.org/src/rev/153846b6ca3a
branches:  trunk
changeset: 366780:153846b6ca3a
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Jun 14 08:06:18 2022 +0000

description:
Implement "raidctl -t config-file"

This does the same config file parse  that -c/-C do, but only
that (hence no raidframe device is needed, or accepted).

Any syntax errors in the config file will be reported, nothing
else happens.

diffstat:

 sbin/raidctl/raidctl.8 |  12 ++++++++++--
 sbin/raidctl/raidctl.c |  34 ++++++++++++++++++++++++++++------
 2 files changed, 38 insertions(+), 8 deletions(-)

diffs (123 lines):

diff -r 1a75b06e15d8 -r 153846b6ca3a sbin/raidctl/raidctl.8
--- a/sbin/raidctl/raidctl.8    Tue Jun 14 08:06:13 2022 +0000
+++ b/sbin/raidctl/raidctl.8    Tue Jun 14 08:06:18 2022 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: raidctl.8,v 1.78 2021/08/02 20:31:15 oster Exp $
+.\"     $NetBSD: raidctl.8,v 1.79 2022/06/14 08:06:18 kre Exp $
 .\"
 .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\" any improvements or extensions that they make and grant Carnegie the
 .\" rights to redistribute these changes.
 .\"
-.Dd August 2, 2021
+.Dd June 13, 2022
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -127,6 +127,9 @@
 .Fl s Ar dev
 .Nm
 .Op Fl v
+.Fl t Ar config_file
+.Nm
+.Op Fl v
 .Fl U Ar unit Ar dev
 .Nm
 .Op Fl v
@@ -330,6 +333,11 @@
 .It Fl s Ar dev
 Display the status of the RAIDframe device for each of the components
 and spares.
+.It Fl t Ar config_file
+Read and parse the
+.Ar config_file ,
+reporting any errors, then exit.
+No raidframe operations are performed.
 .It Fl U Ar unit Ar dev
 Set the
 .Dv last_unit
diff -r 1a75b06e15d8 -r 153846b6ca3a sbin/raidctl/raidctl.c
--- a/sbin/raidctl/raidctl.c    Tue Jun 14 08:06:13 2022 +0000
+++ b/sbin/raidctl/raidctl.c    Tue Jun 14 08:06:18 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: raidctl.c,v 1.77 2022/06/14 08:06:07 kre Exp $   */
+/*      $NetBSD: raidctl.c,v 1.78 2022/06/14 08:06:18 kre Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.77 2022/06/14 08:06:07 kre Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.78 2022/06/14 08:06:18 kre Exp $");
 #endif
 
 
@@ -64,6 +64,8 @@
 #include "rf_configure.h"
 #include "prog_ops.h"
 
+#define        CONFIGURE_TEST  1       /* must be different from any raidframe ioctl */
+
 void   do_ioctl(int, u_long, void *, const char *);
 static  void rf_configure(int, char*, int);
 static  const char *device_status(RF_DiskStatus_t);
@@ -133,9 +135,9 @@
        last_unit = 0;
        openmode = O_RDWR;      /* default to read/write */
 
-       while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:LmM:r:R:sSpPuU:v"))
-              != -1)
-               switch(ch) {
+       while ((ch = getopt(argc, argv,
+           "a:A:Bc:C:f:F:g:GiI:l:LmM:r:R:sSpPt:uU:v")) != -1)
+               switch (ch) {
                case 'a':
                        action = RAIDFRAME_ADD_HOT_SPARE;
                        get_comp(component, optarg, sizeof(component));
@@ -253,6 +255,12 @@
                        openmode = O_RDONLY;
                        num_options++;
                        break;
+               case 't':
+                       action = CONFIGURE_TEST;
+                       strlcpy(config_filename, optarg,
+                           sizeof(config_filename));
+                       num_options++;
+                       break;
                case 'u':
                        action = RAIDFRAME_SHUTDOWN;
                        num_options++;
@@ -276,7 +284,20 @@
        argc -= optind;
        argv += optind;
 
-       if ((num_options > 1) || (argc == 0)) 
+       if (num_options > 1)
+               usage();
+
+       if (action == CONFIGURE_TEST) {
+               RF_Config_t cfg;
+
+               if (argc != 0)
+                       usage();
+               if (rf_MakeConfig(config_filename, &cfg) != 0)
+                       exit(1);
+               exit(0);;
+       }
+
+       if (argc != 1)
                usage();
 
        if (prog_init && prog_init() == -1)
@@ -1216,6 +1237,7 @@
        fprintf(stderr, "       %s [-v] -r component dev\n", progname); 
        fprintf(stderr, "       %s [-v] -S dev\n", progname);
        fprintf(stderr, "       %s [-v] -s dev\n", progname);
+       fprintf(stderr, "       %s [-v] -t config_file\n", progname);
        fprintf(stderr, "       %s [-v] -U unit dev\n", progname);
        fprintf(stderr, "       %s [-v] -u dev\n", progname);
        exit(1);



Home | Main Index | Thread Index | Old Index