CVS commit: src/sbin/raidctl

2023-09-20 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Thu Sep 21 01:48:41 UTC 2023

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Remove a couple of unneeded comments.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.80 src/sbin/raidctl/raidctl.c:1.81
--- src/sbin/raidctl/raidctl.c:1.80	Thu Sep 21 01:40:44 2023
+++ src/sbin/raidctl/raidctl.c	Thu Sep 21 01:48:41 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.80 2023/09/21 01:40:44 oster Exp $   */
+/*  $NetBSD: raidctl.c,v 1.81 2023/09/21 01:48:41 oster Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.80 2023/09/21 01:40:44 oster Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.81 2023/09/21 01:48:41 oster Exp $");
 #endif
 
 
@@ -144,7 +144,6 @@ main(int argc,char *argv[])
 	if (argc > 5) {
 		/* we have at least 5 args, so it might be a simplified config */
 		
-		/* XXX NEW CODE XXX */
 		strlcpy(name, argv[1], sizeof(name));
 		fd = opendisk(name, openmode, dev_name, sizeof(dev_name), 0);
 		if (fd != -1) {
@@ -159,7 +158,6 @@ main(int argc,char *argv[])
 rf_simple_create(fd,argc-3,[3]);
 
 /* set serial number, set autoconfig, init parity */
-/* XXX need to grok a random number for the serial number here */
 
 if (gettimeofday(,NULL) == -1) {
 	serial_number = 12345777;



CVS commit: src/sbin/raidctl

2023-09-20 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Thu Sep 21 01:48:41 UTC 2023

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Remove a couple of unneeded comments.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2023-09-20 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Thu Sep 21 01:40:44 UTC 2023

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Implement command-line configuration of simple RAID sets with raidctl
based on the usage pattern:

raidctl  create...

For example,

raidctl raid0 create mirror absent /dev/wd1e

will create a RAID level 1 (mirror) set with an absent first component
and /dev/wd1e as the second component.  The resulting RAID device will
be marked as auto-configurable, will have a serial number set (based
on the current time), and parity will be initialized.  Reasonable
performance values are automatically used by default for other parameters
normally specified in the configuration file.

Also: Only print out Autoconfig status if being verbose.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.79 -r1.80 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2023-09-20 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Thu Sep 21 01:40:44 UTC 2023

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Implement command-line configuration of simple RAID sets with raidctl
based on the usage pattern:

raidctl  create...

For example,

raidctl raid0 create mirror absent /dev/wd1e

will create a RAID level 1 (mirror) set with an absent first component
and /dev/wd1e as the second component.  The resulting RAID device will
be marked as auto-configurable, will have a serial number set (based
on the current time), and parity will be initialized.  Reasonable
performance values are automatically used by default for other parameters
normally specified in the configuration file.

Also: Only print out Autoconfig status if being verbose.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.79 -r1.80 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.80 src/sbin/raidctl/raidctl.8:1.81
--- src/sbin/raidctl/raidctl.8:1.80	Sun Sep 17 20:07:39 2023
+++ src/sbin/raidctl/raidctl.8	Thu Sep 21 01:40:44 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.80 2023/09/17 20:07:39 oster Exp $
+.\" $NetBSD: raidctl.8,v 1.81 2023/09/21 01:40:44 oster 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 September 16, 2023
+.Dd September 20, 2023
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -61,6 +61,10 @@
 .Nd configuration utility for the RAIDframe disk driver
 .Sh SYNOPSIS
 .Nm
+.Ar dev
+.Ar command
+.Op Ar arg Op ...
+.Nm
 .Op Fl v
 .Fl A Op yes | no | forceroot | softroot
 .Ar dev
@@ -148,7 +152,27 @@ For more information about the RAIDframe
 This document assumes the reader has at least rudimentary knowledge of
 RAID and RAID concepts.
 .Pp
-The command-line options for
+The simplified command-line options for
+.Nm
+are as follows:
+.Bl -tag -width indent
+.It Ic create Ar level Ar component1 Ar component2 Ar ...
+where
+.Ar level
+specifies the RAID level and is one of
+.Ar 0
+,
+.Ar 1 
+(or
+.Ar mirror
+), or
+.Ar 5
+and each of
+.Ar componentN
+specify the devices to be configured into the RAID set.
+.El
+.Pp
+The advanced command-line options for
 .Nm
 are as follows:
 .Bl -tag -width indent
@@ -370,6 +394,38 @@ for many others, or just simply
 .Pa /dev/rraid0[cd] ) .
 It is recommended that the partitions used to represent the
 RAID device are not used for file systems.
+.Ss Simple RAID configuration
+For simple RAID configurations using RAID levels 0 (simple striping),
+1 (mirroring), or 5 (striping with distributed parity)
+.Nm
+supports command-line configuration of RAID setups without
+the use of a configuration file.  For example,
+.Bd -literal -offset indent
+raidctl raid0 create 0 /dev/wd0e /dev/wd1e /dev/wd2e
+.Ed
+.Pp
+will create a RAID level 0 set on the device named
+.Pa raid0
+using the components
+.Pa /dev/wd0e ,
+.Pa /dev/wd1e ,
+and
+.Pa /dev/wd2e .
+Similarly,
+.Bd -literal -offset indent
+raidctl raid0 create mirror absent /dev/wd1e
+.Ed
+.Pp
+will create a RAID level 1 (mirror) set with an absent first component
+and
+.Pa /dev/wd1e
+as the second component.  In all cases the resulting RAID device will
+be marked as auto-configurable, will have a serial number set (based
+on the current time), and parity will be initialized (if the RAID level
+has parity and sufficent components are present).  Reasonable
+performance values are automatically used by default for other
+parameters normally specified in the configuration file.
+.Pp
 .Ss Configuration file
 The format of the configuration file is complex, and
 only an abbreviated treatment is given here.
@@ -540,6 +596,10 @@ for a more complete configuration file e
 device special files.
 .El
 .Sh EXAMPLES
+The examples given in this section are for more complex
+setups than can be configured with the simplified command-line
+configuration option described early.
+.Pp
 It is highly recommended that before using the RAID driver for real
 file systems that the system administrator(s) become quite familiar
 with the use of

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.79 src/sbin/raidctl/raidctl.c:1.80
--- src/sbin/raidctl/raidctl.c:1.79	Sun Sep 17 20:07:39 2023
+++ src/sbin/raidctl/raidctl.c	Thu Sep 21 01:40:44 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.79 2023/09/17 20:07:39 oster Exp $   */
+/*  $NetBSD: raidctl.c,v 1.80 2023/09/21 01:40:44 oster Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.79 2023/09/17 20:07:39 oster Exp $");

CVS commit: src/sbin/raidctl

2022-07-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Jul 21 09:19:54 UTC 2022

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
PR bin/56917

If getfsspecname() fails that will usually mean that a NAME=wedge or
ROOT.x partition is unabailable.   raidframe specified unavailable
partitions as "absent" so in this case, pass "absent" rather than the
unaltered NAME= or ROOT.x string, which the kernel has no clue what
do do with, and doesn't configure the raid at all.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.36 src/sbin/raidctl/rf_configure.c:1.37
--- src/sbin/raidctl/rf_configure.c:1.36	Tue Jun 14 08:06:13 2022
+++ src/sbin/raidctl/rf_configure.c	Thu Jul 21 09:19:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.36 2022/06/14 08:06:13 kre Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.37 2022/07/21 09:19:53 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.36 2022/06/14 08:06:13 kre Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.37 2022/07/21 09:19:53 kre Exp $");
 #endif
 
 
@@ -278,7 +278,7 @@ rf_MakeConfig(char *configname, RF_Confi
 			warnx("Config file error: warning: unable to "
 			"get device file for disk at col %d: %s",
 			c, b1);
-			b = buf;
+			b = "absent";
 		}
 
 		strlcpy(cfgPtr->devnames[0][c], b,



CVS commit: src/sbin/raidctl

2022-07-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Jul 21 09:19:54 UTC 2022

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
PR bin/56917

If getfsspecname() fails that will usually mean that a NAME=wedge or
ROOT.x partition is unabailable.   raidframe specified unavailable
partitions as "absent" so in this case, pass "absent" rather than the
unaltered NAME= or ROOT.x string, which the kernel has no clue what
do do with, and doesn't configure the raid at all.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sbin/raidctl

2022-06-18 Thread Robert Elz
Date:Sat, 18 Jun 2022 14:45:12 - (UTC)
From:chris...@astron.com (Christos Zoulas)
Message-ID:  

  | Nevertheless why don't we make the char one unsigned char?

I wondered about that possibility, but it was a bigger change than I
wanted to make at the time - I didn't want to have to even consider
the potential flow on cleanup changes that come from switching from
signed to unsigned.

It would be cleaner however - a quick skim of the source suggested to
me that anything <= 0 is treated as 1 in any case, so (if that is
correct) there's certainly no point in allowing negative values.

kre

ps: my raid5 is working fine with its -56 queue length!

Component label for /dev/dk21:
   Row: 0, Column: 0, Num Rows: 1, Num Columns: 3
   Version: 2, Serial Number: 19591006, Mod Counter: 1772
   Clean: No, Status: 0
   sectPerSU: 32, SUsPerPU: 1, SUsPerRU: 1
   Queue size: -56, blocksize: 512, numBlocks: 27344762880
   RAID Level: 5




Re: CVS commit: src/sbin/raidctl

2022-06-18 Thread Christos Zoulas
In article <20220614080613.b4570f...@cvs.netbsd.org>,
Robert Elz  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  kre
>Date:  Tue Jun 14 08:06:13 UTC 2022
>
>Modified Files:
>   src/sbin/raidctl: rf_configure.c
>
>Log Message:
>Fix some config file parsing.
>
>First, and what got me started on this set of cleanups, the queue
>length in the "queue" section (START queue) is limited to what will
>fit in a char without losing accuracy (I tried setting it to 200,
>rather than the more common (universal?) 100 and found that the
>value configured into the array was -56 instead.
>
>Why the value needs to be passed through a char variable I have no
>idea (it is an int in the filesystem raidframe headers) - but that's
>the way it is done, and changing it would be an ABI change I believe
>(and so need versioning to alter) and that isn't worth it for this
>(or not now, IMO).
>
>Instead check that the value in the char is the same value as was
>read from the config file, and complain if not.   Those of you with
>unsigned chars will be able to have queue lengths up to 255, the
>rest of us are limited to 127.
>
>While looking at that, I noticed some code that obviously fails to
>understand that scanf("%s") will never return a string containing
>spaces, and proceeded to attempt to remove trailing spaces from the
>result ... amusingly, after having used the result for its intended
>purpose (non existent trailing spaces unremoved), after which that
>buffer was never used again.   That code is now gone (but for now,
>just #if 0'd rather than actually deleted - it should be cleaned up
>sometime).
>
>Then I saw some other issues with how the config was parsed - a
>simple (unbounded) scanf("%s") into a buffer, which hypothetically
>might not be large enough (not a security issue really, raidctl has
>no special privs, and it isn't likely that root could easily be
>tricked into running it on a bogus config file - or not without
>looking first anyway, and a huge long string would rather stand
>out).   Bound the string length to something reasonable, and
>assert() that the buffer is big enough to contain it.
>
>Lastly, in the event of one particular detected error in the
>config file, the code would write a warning, but then just go
>ahead and use the bad data (or nothing perhaps) anyway - a
>failure of logic flow (unlikely to have ever happened, everyone
>seems to simply copy the sample config from the man page, and
>make minor adjustments as needed).
>
>If any of these changes make any difference to anyone (except
>me with my attempt to make longer queues - for no particularly
>well thought out reason), I'd be very surprised.

There is really no type consistency

raidframevar.h: charmaxOutstandingDiskReqs; /* # concurrent reqs to be sent 
to a
raidframevar.h: int maxOutstanding;   /* maxOutstanding disk requests */
rf_diskqueue.h: longmaxOutstanding; /* max # of I/Os that can be 
outstanding on a
rf_raid.h:  int maxOutstanding;   

Nevertheless why don't we make the char one unsigned char? It will not
be an ABI change and it will make it 255 for everyone.

christos



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:18 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.77 -r1.78 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.78 src/sbin/raidctl/raidctl.8:1.79
--- src/sbin/raidctl/raidctl.8:1.78	Mon Aug  2 20:31:15 2021
+++ src/sbin/raidctl/raidctl.8	Tue Jun 14 08:06:18 2022
@@ -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 @@ achieved in each of these areas.
 .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

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.77 src/sbin/raidctl/raidctl.c:1.78
--- src/sbin/raidctl/raidctl.c:1.77	Tue Jun 14 08:06:07 2022
+++ src/sbin/raidctl/raidctl.c	Tue Jun 14 08:06:18 2022
@@ -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 
 
 #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 @@ __RCSID("$NetBSD: raidctl.c,v 1.77 2022/
 #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 @@ main(int argc,char *argv[])
 	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 @@ main(int argc,char *argv[])
 			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 @@ main(int argc,char *argv[])
 	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, ) != 0)
+			exit(1);
+		exit(0);;
+	}
+
+	if (argc != 1)
 		usage();
 
 	if (prog_init && prog_init() == -1)
@@ -1216,6 +1237,7 @@ usage(void)
 	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);



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:18 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.77 -r1.78 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:13 UTC 2022

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Fix some config file parsing.

First, and what got me started on this set of cleanups, the queue
length in the "queue" section (START queue) is limited to what will
fit in a char without losing accuracy (I tried setting it to 200,
rather than the more common (universal?) 100 and found that the
value configured into the array was -56 instead.

Why the value needs to be passed through a char variable I have no
idea (it is an int in the filesystem raidframe headers) - but that's
the way it is done, and changing it would be an ABI change I believe
(and so need versioning to alter) and that isn't worth it for this
(or not now, IMO).

Instead check that the value in the char is the same value as was
read from the config file, and complain if not.   Those of you with
unsigned chars will be able to have queue lengths up to 255, the
rest of us are limited to 127.

While looking at that, I noticed some code that obviously fails to
understand that scanf("%s") will never return a string containing
spaces, and proceeded to attempt to remove trailing spaces from the
result ... amusingly, after having used the result for its intended
purpose (non existent trailing spaces unremoved), after which that
buffer was never used again.   That code is now gone (but for now,
just #if 0'd rather than actually deleted - it should be cleaned up
sometime).

Then I saw some other issues with how the config was parsed - a
simple (unbounded) scanf("%s") into a buffer, which hypothetically
might not be large enough (not a security issue really, raidctl has
no special privs, and it isn't likely that root could easily be
tricked into running it on a bogus config file - or not without
looking first anyway, and a huge long string would rather stand
out).   Bound the string length to something reasonable, and
assert() that the buffer is big enough to contain it.

Lastly, in the event of one particular detected error in the
config file, the code would write a warning, but then just go
ahead and use the bad data (or nothing perhaps) anyway - a
failure of logic flow (unlikely to have ever happened, everyone
seems to simply copy the sample config from the man page, and
make minor adjustments as needed).

If any of these changes make any difference to anyone (except
me with my attempt to make longer queues - for no particularly
well thought out reason), I'd be very surprised.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.35 src/sbin/raidctl/rf_configure.c:1.36
--- src/sbin/raidctl/rf_configure.c:1.35	Tue Jun 14 08:06:07 2022
+++ src/sbin/raidctl/rf_configure.c	Tue Jun 14 08:06:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.35 2022/06/14 08:06:07 kre Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.36 2022/06/14 08:06:13 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.35 2022/06/14 08:06:07 kre Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.36 2022/06/14 08:06:13 kre Exp $");
 #endif
 
 
@@ -59,6 +59,7 @@ __RCSID("$NetBSD: rf_configure.c,v 1.35 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -212,29 +213,45 @@ rf_MakeConfig(char *configname, RF_Confi
 		warnx("[No disk queue discipline specified in config file %s. "
 		"Using %s.]", configname, cfgPtr->diskQueueType);
 	}
+else {
 
 	/*
 	 * the queue specifier line contains two entries: 1st char of first
 	 * word specifies queue to be used 2nd word specifies max num reqs
 	 * that can be outstanding on the disk itself (typically 1)
 	 */
-	if (sscanf(buf, "%s %d", buf1, ) != 2) {
+	assert(64 < sizeof buf1);
+	if (sscanf(buf, "%64s %d", buf1, ) != 2 || strlen(buf1) >= 60) {
 		warnx("Can't determine queue type and/or max outstanding "
-		"reqs from line: %*s", (int)(sizeof(buf) - 1), buf);
+		"reqs from line: %.*s", (int)(sizeof(buf) - 1), buf);
 		warnx("Using %s-%d", cfgPtr->diskQueueType,
 		cfgPtr->maxOutstandingDiskReqs);
 	} else {
+#if 0
 		char *ch;
+#endif
 		memcpy(cfgPtr->diskQueueType, buf1,
 		RF_MIN(sizeof(cfgPtr->diskQueueType), strlen(buf1) + 1));
+		cfgPtr->diskQueueType[sizeof cfgPtr->diskQueueType - 1] = '\0';
+
+#if 0	/* this indicates a lack of understanding of how scanf() works */
+	/* it was also pointless as buf1 data was (b4) never used again */
 		for (ch = buf1; *ch; ch++) {
 			if (*ch == ' ') {
 *ch = '\0';
 break;
 			}
 		}
+#endif
 		cfgPtr->maxOutstandingDiskReqs = val;
+		if (cfgPtr->maxOutstandingDiskReqs != val) {
+			warnx("Queue length for %s out of range"
+			" [%d interp as %d], 

CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:13 UTC 2022

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Fix some config file parsing.

First, and what got me started on this set of cleanups, the queue
length in the "queue" section (START queue) is limited to what will
fit in a char without losing accuracy (I tried setting it to 200,
rather than the more common (universal?) 100 and found that the
value configured into the array was -56 instead.

Why the value needs to be passed through a char variable I have no
idea (it is an int in the filesystem raidframe headers) - but that's
the way it is done, and changing it would be an ABI change I believe
(and so need versioning to alter) and that isn't worth it for this
(or not now, IMO).

Instead check that the value in the char is the same value as was
read from the config file, and complain if not.   Those of you with
unsigned chars will be able to have queue lengths up to 255, the
rest of us are limited to 127.

While looking at that, I noticed some code that obviously fails to
understand that scanf("%s") will never return a string containing
spaces, and proceeded to attempt to remove trailing spaces from the
result ... amusingly, after having used the result for its intended
purpose (non existent trailing spaces unremoved), after which that
buffer was never used again.   That code is now gone (but for now,
just #if 0'd rather than actually deleted - it should be cleaned up
sometime).

Then I saw some other issues with how the config was parsed - a
simple (unbounded) scanf("%s") into a buffer, which hypothetically
might not be large enough (not a security issue really, raidctl has
no special privs, and it isn't likely that root could easily be
tricked into running it on a bogus config file - or not without
looking first anyway, and a huge long string would rather stand
out).   Bound the string length to something reasonable, and
assert() that the buffer is big enough to contain it.

Lastly, in the event of one particular detected error in the
config file, the code would write a warning, but then just go
ahead and use the bad data (or nothing perhaps) anyway - a
failure of logic flow (unlikely to have ever happened, everyone
seems to simply copy the sample config from the man page, and
make minor adjustments as needed).

If any of these changes make any difference to anyone (except
me with my attempt to make longer queues - for no particularly
well thought out reason), I'd be very surprised.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:07 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c rf_configure.c

Log Message:
In the previous (and some earlier) version(s) of raidctl.c
the following comment appeared:

/*
 * After NetBSD 9, convert this to not output the numRow's value,
 * which is no longer required or ever used.
 */

We are after NetBSD 9 (well after).   The change requested in that
comment is made here, and the comment is thus removed.

A couple of places in rf_configure.c where a value for the "rows"
parameter was output in an error message (always simply as the
constant 0) have also been updated (those messages will no longer
include "row 0", which they always said previously).   One of them
was also slightly reworded to be clearer what problem it was
experiencing (when it said 'unable to get device file' it meant
it was unable to locate the name for the device in the config file,
not that it was found, and there was some other problem with it).


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/raidctl/raidctl.c
cvs rdiff -u -r1.34 -r1.35 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.76 src/sbin/raidctl/raidctl.c:1.77
--- src/sbin/raidctl/raidctl.c:1.76	Tue Jun 14 08:06:01 2022
+++ src/sbin/raidctl/raidctl.c	Tue Jun 14 08:06:07 2022
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.76 2022/06/14 08:06:01 kre Exp $   */
+/*  $NetBSD: raidctl.c,v 1.77 2022/06/14 08:06:07 kre Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.76 2022/06/14 08:06:01 kre Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.77 2022/06/14 08:06:07 kre Exp $");
 #endif
 
 
@@ -637,14 +637,9 @@ rf_output_configuration(int fd, const ch
 	nspares = MIN(device_config.nspares,
 	__arraycount(device_config.spares));
 	
-	/*
-	 * After NetBSD 9, convert this to not output the numRow's value,
-	 * which is no longer required or ever used.
-	 */
 	printf("START array\n");
-	printf("# numRow numCol numSpare\n");
-	printf("%d %d %d\n", 1, device_config.cols,
-	device_config.nspares);
+	printf("# numCol numSpare\n");
+	printf("%d %d\n", device_config.cols, device_config.nspares);
 	printf("\n");
 
 	printf("START disks\n");

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.34 src/sbin/raidctl/rf_configure.c:1.35
--- src/sbin/raidctl/rf_configure.c:1.34	Sun Sep  6 05:31:46 2020
+++ src/sbin/raidctl/rf_configure.c	Tue Jun 14 08:06:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.34 2020/09/06 05:31:46 mrg Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.35 2022/06/14 08:06:07 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.34 2020/09/06 05:31:46 mrg Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.35 2022/06/14 08:06:07 kre Exp $");
 #endif
 
 
@@ -250,8 +250,8 @@ rf_MakeConfig(char *configname, RF_Confi
 
 		if (rf_get_next_nonblank_line(
 		buf, sizeof(buf), fp, NULL)) {
-			warnx("Config file error: unable to get device "
-			"file for disk at row %d col %d", 0, c);
+			warnx("Config file error: unable to find device "
+			"file name for disk at col %d", c);
 			retcode = -1;
 			goto out;
 		}
@@ -259,8 +259,8 @@ rf_MakeConfig(char *configname, RF_Confi
 		b = getfsspecname(b1, sizeof(b1), buf);
 		if (b == NULL) {
 			warnx("Config file error: warning: unable to "
-			"get device file for disk at row %d col "
-			"%d: %s", 0, c, b1);
+			"get device file for disk at col %d: %s",
+			c, b1);
 			b = buf;
 		}
 



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:07 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c rf_configure.c

Log Message:
In the previous (and some earlier) version(s) of raidctl.c
the following comment appeared:

/*
 * After NetBSD 9, convert this to not output the numRow's value,
 * which is no longer required or ever used.
 */

We are after NetBSD 9 (well after).   The change requested in that
comment is made here, and the comment is thus removed.

A couple of places in rf_configure.c where a value for the "rows"
parameter was output in an error message (always simply as the
constant 0) have also been updated (those messages will no longer
include "row 0", which they always said previously).   One of them
was also slightly reworded to be clearer what problem it was
experiencing (when it said 'unable to get device file' it meant
it was unable to locate the name for the device in the config file,
not that it was found, and there was some other problem with it).


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/raidctl/raidctl.c
cvs rdiff -u -r1.34 -r1.35 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:02 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Reorder the getopts() switch () (slightly) to sort the options.   NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:06:02 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Reorder the getopts() switch () (slightly) to sort the options.   NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.75 src/sbin/raidctl/raidctl.c:1.76
--- src/sbin/raidctl/raidctl.c:1.75	Tue Jun 14 08:05:55 2022
+++ src/sbin/raidctl/raidctl.c	Tue Jun 14 08:06:01 2022
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.75 2022/06/14 08:05:55 kre Exp $   */
+/*  $NetBSD: raidctl.c,v 1.76 2022/06/14 08:06:01 kre Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.75 2022/06/14 08:05:55 kre Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.76 2022/06/14 08:06:01 kre Exp $");
 #endif
 
 
@@ -223,6 +223,16 @@ main(int argc,char *argv[])
 			while (i < 3)
 parityparams[i++] = 0;
 			break;
+		case 'p':
+			action = RAIDFRAME_CHECK_PARITY;
+			openmode = O_RDONLY;
+			num_options++;
+			break;
+		case 'P':
+			action = RAIDFRAME_CHECK_PARITY;
+			do_rewrite = 1;
+			num_options++;
+			break;
 		case 'r':
 			action = RAIDFRAME_REMOVE_HOT_SPARE;
 			get_comp(component, optarg, sizeof(component));
@@ -243,16 +253,6 @@ main(int argc,char *argv[])
 			openmode = O_RDONLY;
 			num_options++;
 			break;
-		case 'p':
-			action = RAIDFRAME_CHECK_PARITY;
-			openmode = O_RDONLY;
-			num_options++;
-			break;
-		case 'P':
-			action = RAIDFRAME_CHECK_PARITY;
-			do_rewrite = 1;
-			num_options++;
-			break;
 		case 'u':
 			action = RAIDFRAME_SHUTDOWN;
 			num_options++;



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:05:56 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
KNF (whitespace & 80 column limits) - NFCI.

This is the first of a series of 5 commits in this
directory, all coming within minutes or now.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.74 src/sbin/raidctl/raidctl.c:1.75
--- src/sbin/raidctl/raidctl.c:1.74	Mon Aug  2 20:31:15 2021
+++ src/sbin/raidctl/raidctl.c	Tue Jun 14 08:05:55 2022
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.74 2021/08/02 20:31:15 oster Exp $   */
+/*  $NetBSD: raidctl.c,v 1.75 2022/06/14 08:05:55 kre Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.74 2021/08/02 20:31:15 oster Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.75 2022/06/14 08:05:55 kre Exp $");
 #endif
 
 
@@ -294,7 +294,7 @@ main(int argc,char *argv[])
 
 	raidID = DISKUNIT(st.st_rdev);
 
-	switch(action) {
+	switch (action) {
 	case RAIDFRAME_ADD_HOT_SPARE:
 		add_hot_spare(fd, component);
 		break;
@@ -490,7 +490,8 @@ rf_get_device_status(int fd)
 			} else {
 printf("%s status is: %s.  Skipping label.\n",
    device_config.spares[i].devname,
-   device_status(device_config.spares[i].status));
+   device_status(
+	   device_config.spares[i].status));
 			}		
 		}
 	}
@@ -966,7 +967,8 @@ check_parity(int fd, int do_rewrite, cha
  get started. */
 			if (verbose) {
 printf("Parity Re-write status:\n");
-do_meter(fd, RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT);
+do_meter(fd,
+RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT);
 			} else {
 do_ioctl(fd, 
 	 RAIDFRAME_CHECK_PARITYREWRITE_STATUS, 
@@ -975,13 +977,14 @@ check_parity(int fd, int do_rewrite, cha
 	 );
 while( percent_done < 100 ) {
 	sleep(3); /* wait a bit... */
-	do_ioctl(fd, RAIDFRAME_CHECK_PARITYREWRITE_STATUS, 
-		 _done, "RAIDFRAME_CHECK_PARITYREWRITE_STATUS");
+	do_ioctl(fd,
+	   RAIDFRAME_CHECK_PARITYREWRITE_STATUS,
+		 _done,
+"RAIDFRAME_CHECK_PARITYREWRITE_STATUS");
 }
 
 			}
-			   printf("%s: Parity Re-write complete\n",
-  dev_name);
+			printf("%s: Parity Re-write complete\n", dev_name);
 		} else {
 			/* parity is wrong, and is not being fixed.
 			   Exit w/ an error. */
@@ -1175,7 +1178,8 @@ get_time_string(char *string, size_t len
 #endif
 		
 		if (hours > 0) {
-			snprintf(hours_buffer,sizeof hours_buffer,"%02d:",hours);
+			snprintf(hours_buffer,sizeof hours_buffer,
+			"%02d:",hours);
 		} else {
 			snprintf(hours_buffer,sizeof hours_buffer,"   ");
 		}
@@ -1195,7 +1199,9 @@ usage(void)
 {
 	const char *progname = getprogname();
 
-	fprintf(stderr, "usage: %s [-v] -A [yes | no | softroot | hardroot] dev\n", progname);
+	fprintf(stderr,
+	"usage: %s [-v] -A [yes | no | softroot | hardroot] dev\n",
+	progname);
 	fprintf(stderr, "   %s [-v] -a component dev\n", progname);
 	fprintf(stderr, "   %s [-v] -B dev\n", progname);
 	fprintf(stderr, "   %s [-v] -C config_file dev\n", progname);



CVS commit: src/sbin/raidctl

2022-06-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Jun 14 08:05:56 UTC 2022

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
KNF (whitespace & 80 column limits) - NFCI.

This is the first of a series of 5 commits in this
directory, all coming within minutes or now.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2021-08-01 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Sun Aug  1 20:26:53 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Move case 'l' to be in sorted order.  No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.72 src/sbin/raidctl/raidctl.c:1.73
--- src/sbin/raidctl/raidctl.c:1.72	Sun Sep 13 06:04:53 2020
+++ src/sbin/raidctl/raidctl.c	Sun Aug  1 20:26:53 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.72 2020/09/13 06:04:53 mlelstv Exp $   */
+/*  $NetBSD: raidctl.c,v 1.73 2021/08/01 20:26:53 oster Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.72 2020/09/13 06:04:53 mlelstv Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.73 2021/08/01 20:26:53 oster Exp $");
 #endif
 
 
@@ -197,6 +197,11 @@ main(int argc,char *argv[])
 			serial_number = xstrtouint(optarg);
 			num_options++;
 			break;
+		case 'l': 
+			action = RAIDFRAME_SET_COMPONENT_LABEL;
+			get_comp(component, optarg, sizeof(component));
+			num_options++;
+			break;
 		case 'm':
 			action = RAIDFRAME_PARITYMAP_STATUS;
 			openmode = O_RDONLY;
@@ -214,11 +219,6 @@ main(int argc,char *argv[])
 			while (i < 3)
 parityparams[i++] = 0;
 			break;
-		case 'l': 
-			action = RAIDFRAME_SET_COMPONENT_LABEL;
-			get_comp(component, optarg, sizeof(component));
-			num_options++;
-			break;
 		case 'r':
 			action = RAIDFRAME_REMOVE_HOT_SPARE;
 			get_comp(component, optarg, sizeof(component));



CVS commit: src/sbin/raidctl

2021-08-01 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Sun Aug  1 20:26:53 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Move case 'l' to be in sorted order.  No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2021-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May 27 07:03:27 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Avoid using Pq.

In this case, the parentheses were wrong when a line was extended.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2021-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May 27 07:03:27 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Avoid using Pq.

In this case, the parentheses were wrong when a line was extended.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.76 src/sbin/raidctl/raidctl.8:1.77
--- src/sbin/raidctl/raidctl.8:1.76	Thu May 27 06:53:37 2021
+++ src/sbin/raidctl/raidctl.8	Thu May 27 07:03:27 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.76 2021/05/27 06:53:37 mrg Exp $
+.\" $NetBSD: raidctl.8,v 1.77 2021/05/27 07:03:27 wiz Exp $
 .\"
 .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -166,8 +166,8 @@ All components of the set must be of typ
 .Dv RAID
 in the disklabel.
 Note that only certain architectures
-.Pq currently arc, alpha, amd64, bebox, cobalt, emips, evbarm, i386, landisk,
-ofppc, pmax, riscv, sandpoint, sgimips, sparc, sparc64, and vax
+(currently arc, alpha, amd64, bebox, cobalt, emips, evbarm, i386, landisk,
+ofppc, pmax, riscv, sandpoint, sgimips, sparc, sparc64, and vax)
 support booting a kernel directly from a RAID set.
 Please note that
 .Ic forceroot
@@ -1305,7 +1305,7 @@ arguments.
 .Pp
 Note that kernels can only be directly read from RAID 1 components on
 architectures that support that
-.Pq currently alpha, i386, pmax, sandpoint, sparc, sparc64, and vax .
+(currently alpha, i386, pmax, sandpoint, sparc, sparc64, and vax).
 On those architectures, the
 .Dv FS_RAID
 file system is recognized by the bootblocks, and will properly load the



CVS commit: src/sbin/raidctl

2021-05-26 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 26 08:23:18 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
update the list of platforms supporting loading kernels from raid.
expand the HISTORY section to include notable RF moments in netbsd.
bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.74 src/sbin/raidctl/raidctl.8:1.75
--- src/sbin/raidctl/raidctl.8:1.74	Thu Jan 18 00:32:49 2018
+++ src/sbin/raidctl/raidctl.8	Wed May 26 08:23:18 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.74 2018/01/18 00:32:49 mrg Exp $
+.\" $NetBSD: raidctl.8,v 1.75 2021/05/26 08:23:18 mrg 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 January 6, 2016
+.Dd May 26, 2021
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -166,7 +166,8 @@ All components of the set must be of typ
 .Dv RAID
 in the disklabel.
 Note that only certain architectures
-.Pq currently alpha, amd64, i386, pmax, sandpoint, sparc, sparc64, and vax
+.Pq currently arc, alpha, amd64, bebox, cobalt, emips, i386, landisk,
+ofppc, pmax, sandpoint, sgimips, sparc, sparc64, and vax
 support booting a kernel directly from a RAID set.
 Please note that
 .Ic forceroot
@@ -502,6 +503,12 @@ the RAIDframe documentation discussed in
 .Sx HISTORY
 section.
 .Pp
+Since
+.Nx 10
+RAIDframe has been been capable of autoconfiguration of components
+originally configured on opposite endian systems.  The current label
+endianness will be retained.
+.Pp
 See
 .Sx EXAMPLES
 for a more complete configuration file example.
@@ -1563,6 +1570,26 @@ for RAID Systems", by William V. Courtri
 Holland, LeAnn Neal Reilly, and Jim Zelenka, and published by the
 Parallel Data Laboratory of Carnegie Mellon University.
 .Pp
+RAIDframe was ported to
+.Nx
+by Greg Oster in 1998, who has maintained it since.
+In 1999, component labels, spares, automatic rebuilding of parity, and
+autoconfiguration of volumes were added.
+In 2000, root on RAID support was added (initially, with no support for
+loading kernels from RAID volumes, which has been added to many ports since.)
+In 2009, support for parity bimap was added, reducing parity resync time
+after a crash.
+In 2010, support for larger the 2TiB and non-512 sector devices was added.
+In 2018, support for 32-bit userland compatibility was added.
+In 2021, support for autoconfiguration from other-endian raid sets was added.
+.Pp
+Support for loading kernels from RAID 1 partitions was added for the
+alpha, pmax and vax ports in 2000, the the sgimips port in 2001,
+the x86 ports in 2003, the arc port in 2005, the landisk, sparc, and
+sparc64 ports in 2006, the cobalt port in 2007, the ofppc port in 2008,
+the bebox port in 2010, the emips port in 2011, and the sandpoint port
+in 2012.
+.Pp
 The
 .Nm
 command first appeared as a program in CMU's RAIDframe v1.1 distribution.



CVS commit: src/sbin/raidctl

2021-05-26 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 26 08:23:18 UTC 2021

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
update the list of platforms supporting loading kernels from raid.
expand the HISTORY section to include notable RF moments in netbsd.
bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2020-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep 13 06:04:53 UTC 2020

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Allow components to be specified by wedge name.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.71 src/sbin/raidctl/raidctl.c:1.72
--- src/sbin/raidctl/raidctl.c:1.71	Thu Sep 26 10:47:30 2019
+++ src/sbin/raidctl/raidctl.c	Sun Sep 13 06:04:53 2020
@@ -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.
@@ -39,7 +39,7 @@
 #include 
 
 #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
 
 
@@ -92,6 +92,13 @@ int verbose;
 
 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
 main(int argc,char *argv[])
 {
@@ -131,7 +138,7 @@ main(int argc,char *argv[])
 		switch(ch) {
 		case 'a':
 			action = RAIDFRAME_ADD_HOT_SPARE;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			num_options++;
 			break;
 		case 'A':
@@ -159,19 +166,19 @@ main(int argc,char *argv[])
 			break;
 		case 'f':
 			action = RAIDFRAME_FAIL_DISK;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			do_recon = 0;
 			num_options++;
 			break;
 		case 'F':
 			action = RAIDFRAME_FAIL_DISK;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			do_recon = 1;
 			num_options++;
 			break;
 		case 'g':
 			action = RAIDFRAME_GET_COMPONENT_LABEL;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			openmode = O_RDONLY;
 			num_options++;
 			break;
@@ -209,16 +216,16 @@ main(int argc,char *argv[])
 			break;
 		case 'l': 
 			action = RAIDFRAME_SET_COMPONENT_LABEL;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			num_options++;
 			break;
 		case 'r':
 			action = RAIDFRAME_REMOVE_HOT_SPARE;
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			num_options++;
 			break;
 		case 'R':
-			strlcpy(component, optarg, sizeof(component));
+			get_comp(component, optarg, sizeof(component));
 			action = RAIDFRAME_REBUILD_IN_PLACE;
 			num_options++;
 			break;



CVS commit: src/sbin/raidctl

2020-09-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep 13 06:04:53 UTC 2020

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Allow components to be specified by wedge name.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2020-09-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Sep  6 05:31:46 UTC 2020

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
avoid trying to printf() a NULL as %s.  fixes likely bug.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.33 src/sbin/raidctl/rf_configure.c:1.34
--- src/sbin/raidctl/rf_configure.c:1.33	Thu Jan 18 00:32:49 2018
+++ src/sbin/raidctl/rf_configure.c	Sun Sep  6 05:31:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.33 2018/01/18 00:32:49 mrg Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.34 2020/09/06 05:31:46 mrg Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.33 2018/01/18 00:32:49 mrg Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.34 2020/09/06 05:31:46 mrg Exp $");
 #endif
 
 
@@ -286,7 +286,7 @@ rf_MakeConfig(char *configname, RF_Confi
 		b = getfsspecname(b1, sizeof(b1), buf);
 		if (b == NULL) {
 			warnx("Config file error: warning: unable to get "
-			"device file for spare disk %d: %s", c, b);
+			"device file for spare disk %d: %s", c, buf);
 			b = buf;
 		}
 



CVS commit: src/sbin/raidctl

2020-09-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Sep  6 05:31:46 UTC 2020

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
avoid trying to printf() a NULL as %s.  fixes likely bug.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:47:30 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Need MIN in userland. Also some more signed/unsigned clashes.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.70 src/sbin/raidctl/raidctl.c:1.71
--- src/sbin/raidctl/raidctl.c:1.70	Thu Sep 26 10:33:30 2019
+++ src/sbin/raidctl/raidctl.c	Thu Sep 26 10:47:30 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $   */
+/*  $NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.71 2019/09/26 10:47:30 mlelstv Exp $");
 #endif
 
 
@@ -442,7 +442,7 @@ rf_get_device_status(int fd)
 		   device_status(device_config.devs[i].status));
 	}
 
-	nspares = uimin(device_config.nspares,
+	nspares = MIN(device_config.nspares,
 	__arraycount(device_config.spares));
 
 	if (nspares > 0) {
@@ -607,7 +607,7 @@ rf_output_configuration(int fd, const ch
 {
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
-	int i;
+	int i, nspares;
 	RF_ComponentLabel_t component_label;
 	void *label_ptr;
 	int component_num;
@@ -619,6 +619,9 @@ rf_output_configuration(int fd, const ch
 	printf("\n");
 	do_ioctl(fd, RAIDFRAME_GET_INFO, _ptr, "RAIDFRAME_GET_INFO");
 
+	nspares = MIN(device_config.nspares,
+	__arraycount(device_config.spares));
+	
 	/*
 	 * After NetBSD 9, convert this to not output the numRow's value,
 	 * which is no longer required or ever used.
@@ -635,9 +638,9 @@ rf_output_configuration(int fd, const ch
 		rf_output_devname(device_config.devs[i].devname));
 	printf("\n");
 
-	if (device_config.nspares > 0) {
+	if (nspares > 0) {
 		printf("START spare\n");
-		for(i=0; i < device_config.nspares; i++)
+		for(i=0; i < nspares; i++)
 			printf("%s\n", device_config.spares[i].devname);
 		printf("\n");
 	}
@@ -679,7 +682,7 @@ get_component_number(int fd, char *compo
 {
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
-	int i;
+	int i, nspares;
 	int found;
 
 	*component_number = -1;
@@ -690,6 +693,9 @@ get_component_number(int fd, char *compo
 		 "RAIDFRAME_GET_INFO");
 
 	*num_columns = device_config.cols;
+
+	nspares = MIN(device_config.nspares,
+	__arraycount(device_config.spares));
 	
 	found = 0;
 	for(i=0; i < device_config.ndevs; i++) {
@@ -700,7 +706,7 @@ get_component_number(int fd, char *compo
 		}
 	}
 	if (!found) { /* maybe it's a spare? */
-		for(i=0; i < device_config.nspares; i++) {
+		for(i=0; i < nspares; i++) {
 			if (strncmp(component_name, 
 device_config.spares[i].devname,
 PATH_MAX)==0) {



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:47:30 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Need MIN in userland. Also some more signed/unsigned clashes.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:33:30 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
nspares is now unsigned. Validate and use as positive integer.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2019-09-26 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Sep 26 10:33:30 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
nspares is now unsigned. Validate and use as positive integer.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.69 src/sbin/raidctl/raidctl.c:1.70
--- src/sbin/raidctl/raidctl.c:1.69	Wed Feb  6 22:38:10 2019
+++ src/sbin/raidctl/raidctl.c	Thu Sep 26 10:33:30 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $   */
+/*  $NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $");
 #endif
 
 
@@ -430,7 +430,7 @@ rf_get_device_status(int fd)
 	RF_DeviceConfig_t device_config;
 	void *cfg_ptr;
 	int is_clean;
-	int i;
+	int i, nspares;
 
 	cfg_ptr = _config;
 
@@ -441,9 +441,13 @@ rf_get_device_status(int fd)
 		printf("%20s: %s\n", device_config.devs[i].devname, 
 		   device_status(device_config.devs[i].status));
 	}
-	if (device_config.nspares > 0) {
+
+	nspares = uimin(device_config.nspares,
+	__arraycount(device_config.spares));
+
+	if (nspares > 0) {
 		printf("Spares:\n");
-		for(i=0; i < device_config.nspares; i++) {
+		for(i=0; i < nspares; i++) {
 			printf("%20s: %s\n",
 			   device_config.spares[i].devname, 
 			   device_status(device_config.spares[i].status));
@@ -461,8 +465,8 @@ rf_get_device_status(int fd)
 		}
 	}
 
-	if (device_config.nspares > 0) {
-		for(i=0; i < device_config.nspares; i++) {
+	if (nspares > 0) {
+		for(i=0; i < nspares; i++) {
 			if ((device_config.spares[i].status == 
 			 rf_ds_optimal) ||
 			(device_config.spares[i].status == 



CVS commit: src/sbin/raidctl

2019-02-06 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Wed Feb  6 22:38:10 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Correct printed IOCTL name that was incorrect since rev 1.5.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.68 src/sbin/raidctl/raidctl.c:1.69
--- src/sbin/raidctl/raidctl.c:1.68	Mon Feb  4 09:31:22 2019
+++ src/sbin/raidctl/raidctl.c	Wed Feb  6 22:38:10 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.68 2019/02/04 09:31:22 mrg Exp $   */
+/*  $NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.68 2019/02/04 09:31:22 mrg Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $");
 #endif
 
 
@@ -823,7 +823,7 @@ init_component_labels(int fd, int serial
 	component_label.status = 0;
 	
 	do_ioctl( fd, RAIDFRAME_INIT_LABELS, _label,
-		  "RAIDFRAME_SET_COMPONENT_LABEL");
+		  "RAIDFRAME_INIT_LABELS");
 }
 
 static void



CVS commit: src/sbin/raidctl

2019-02-06 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Wed Feb  6 22:38:10 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Correct printed IOCTL name that was incorrect since rev 1.5.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 09:31:22 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
- add the string length as an explicit parameter to get_time_string()
- remove casts when the same type is used on both sides
- expand hours_buffer[] to fit the range of hours in an 'int'
- add a work around for the sprintf() truncation checker that fails
  to detect that 'minutes' and 'seconds' have a small range


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.67 src/sbin/raidctl/raidctl.c:1.68
--- src/sbin/raidctl/raidctl.c:1.67	Sat Mar 24 19:41:35 2018
+++ src/sbin/raidctl/raidctl.c	Mon Feb  4 09:31:22 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.67 2018/03/24 19:41:35 nakayama Exp $   */
+/*  $NetBSD: raidctl.c,v 1.68 2019/02/04 09:31:22 mrg Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.67 2018/03/24 19:41:35 nakayama Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.68 2019/02/04 09:31:22 mrg Exp $");
 #endif
 
 
@@ -83,7 +83,7 @@ static  void check_status(int,int);
 static  void check_parity(int,int, char *);
 static  void do_meter(int, u_long);
 static  void get_bar(char *, double, int);
-static  void get_time_string(char *, int);
+static  void get_time_string(char *, size_t, int);
 static  void rf_output_pmstat(int, int);
 static  void rf_pm_configure(int, int, char *, int[]);
 static  unsigned int xstrtouint(const char *);
@@ -1076,7 +1076,7 @@ do_meter(int fd, u_long option)
 			last_eta = simple_eta;
 		}
 
-		get_time_string(eta_buffer, simple_eta);
+		get_time_string(eta_buffer, sizeof eta_buffer, simple_eta);
 
 		fprintf(stdout,"\r%3d%% |%s| ETA: %s %c",
 			percent_done,bar_buffer,eta_buffer,tbits[tbit_value]);
@@ -1126,32 +1126,42 @@ get_bar(char *string, double percent, in
 }
 
 static void
-get_time_string(char *string, int simple_time)
+get_time_string(char *string, size_t len, int simple_time)
 {
 	int minutes, seconds, hours;
-	char hours_buffer[5];
+	char hours_buffer[8];
 	char minutes_buffer[5];
 	char seconds_buffer[5];
 
 	if (simple_time >= 0) {
 
-		minutes = (int) simple_time / 60;
-		seconds = ((int)simple_time - 60*minutes);
+		minutes = simple_time / 60;
+		seconds = simple_time - 60*minutes;
 		hours = minutes / 60;
 		minutes = minutes - 60*hours;
+#if defined(__GNUC__)
+		/*
+		 * snprintf() truncation checker fails to detect that seconds
+		 * and minutes will be 0-59 range.
+		 */
+		if (minutes < 0 || minutes > 60)
+			minutes = 60;
+		if (seconds < 0 || seconds > 60)
+			seconds = 60;
+#endif
 		
 		if (hours > 0) {
-			snprintf(hours_buffer,5,"%02d:",hours);
+			snprintf(hours_buffer,sizeof hours_buffer,"%02d:",hours);
 		} else {
-			snprintf(hours_buffer,5,"   ");
+			snprintf(hours_buffer,sizeof hours_buffer,"   ");
 		}
 		
-		snprintf(minutes_buffer,5,"%02d:",minutes);
-		snprintf(seconds_buffer,5,"%02d",seconds);
-		snprintf(string,1024,"%s%s%s",
+		snprintf(minutes_buffer,sizeof minutes_buffer,"%02d:",minutes);
+		snprintf(seconds_buffer,sizeof seconds_buffer,"%02d",seconds);
+		snprintf(string,len,"%s%s%s",
 			 hours_buffer, minutes_buffer, seconds_buffer);
 	} else {
-		snprintf(string,1024,"   --:--");
+		snprintf(string,len,"   --:--");
 	}
 	
 }



CVS commit: src/sbin/raidctl

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 09:31:22 UTC 2019

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
- add the string length as an explicit parameter to get_time_string()
- remove casts when the same type is used on both sides
- expand hours_buffer[] to fit the range of hours in an 'int'
- add a work around for the sprintf() truncation checker that fails
  to detect that 'minutes' and 'seconds' have a small range


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2018-03-24 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Mar 24 19:41:35 UTC 2018

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Follow the ioctl arg changes of RAIDFRAME_GET_COMPONENT_LABEL and
RAIDFRAME_CHECK_*_STATUS_EXT.

This should fix strange raidctl -s outputs reported in
current-users ML.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2018-03-24 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Mar 24 19:41:35 UTC 2018

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Follow the ioctl arg changes of RAIDFRAME_GET_COMPONENT_LABEL and
RAIDFRAME_CHECK_*_STATUS_EXT.

This should fix strange raidctl -s outputs reported in
current-users ML.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.66 src/sbin/raidctl/raidctl.c:1.67
--- src/sbin/raidctl/raidctl.c:1.66	Thu Jan 18 00:32:49 2018
+++ src/sbin/raidctl/raidctl.c	Sat Mar 24 19:41:35 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.66 2018/01/18 00:32:49 mrg Exp $   */
+/*  $NetBSD: raidctl.c,v 1.67 2018/03/24 19:41:35 nakayama Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.66 2018/01/18 00:32:49 mrg Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.67 2018/03/24 19:41:35 nakayama Exp $");
 #endif
 
 
@@ -653,7 +653,7 @@ rf_output_configuration(int fd, const ch
 	component_label.row = component_num / num_cols;
 	component_label.column = component_num % num_cols;
 	label_ptr = _label;
-	do_ioctl(fd, RAIDFRAME_GET_COMPONENT_LABEL, _ptr,
+	do_ioctl(fd, RAIDFRAME_GET_COMPONENT_LABEL, label_ptr,
 		  "RAIDFRAME_GET_COMPONENT_LABEL");
 
 	printf("START layout\n");
@@ -753,7 +753,7 @@ get_component_label(int fd, char *compon
 	component_label.column = component_num % num_cols;
 
 	label_ptr = _label;
-	do_ioctl( fd, RAIDFRAME_GET_COMPONENT_LABEL, _ptr,
+	do_ioctl( fd, RAIDFRAME_GET_COMPONENT_LABEL, label_ptr,
 		  "RAIDFRAME_GET_COMPONENT_LABEL");
 
 	printf("Component label for %s:\n",component);
@@ -1027,7 +1027,7 @@ do_meter(int fd, u_long option)
 	pInfoPtr=
 
 	percent_done = 0;
-	do_ioctl(fd, option, , "");
+	do_ioctl(fd, option, pInfoPtr, "");
 	start_value = progressInfo.completed;
 	current_time = start_time;
 	simple_eta = 0;
@@ -1090,7 +1090,7 @@ do_meter(int fd, u_long option)
 		if (gettimeofday(_time,NULL) == -1)
 			err(1, "gettimeofday failed!?!?");
 
-		do_ioctl( fd, option, , "");
+		do_ioctl( fd, option, pInfoPtr, "");
 		
 
 	}



CVS commit: src/sbin/raidctl

2017-11-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Nov 22 00:31:31 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Several more cleanups:
1. Don't force use of "for" when "while" works better.
2. No need to check c != '\0' when we also check (c == ' ' || c == '\t')
3. Use the size of the buffer we're using, rather than a different one
   (not really a concern, they're the same size)
4. Don't use fscanf() to read file data, use fgets() & sscanf().
5. After using a pointer as a char *, validate alignment before switching
   to int * (can only fail if kernel #define gets set stupidly)   Or #6...
6. Validate sparemap file name isn't too long for assigned space.
7. recognise that strlen() returns size_t - don't shove it into an int.
8. On out of mem, be more clear which allocation failed in warning msg.

ATF tests all pass.   But I don't think they use sparemap files.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.31 src/sbin/raidctl/rf_configure.c:1.32
--- src/sbin/raidctl/rf_configure.c:1.31	Tue Nov 21 16:31:37 2017
+++ src/sbin/raidctl/rf_configure.c	Wed Nov 22 00:31:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.31 2017/11/21 16:31:37 christos Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.32 2017/11/22 00:31:31 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.31 2017/11/21 16:31:37 christos Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.32 2017/11/22 00:31:31 kre Exp $");
 #endif
 
 
@@ -384,12 +384,18 @@ rf_MakeLayoutSpecificDeclustered(FILE *c
 	 * daemon that's responsible for finding the sparemaps
 	 */
 	if (distSpare) {
-		if (rf_get_next_nonblank_line(smbuf, sizeof(buf), configfp,
+		if (rf_get_next_nonblank_line(smbuf, sizeof(smbuf), configfp,
 		"Can't find sparemap file name in config file")) {
 			fclose(fp);
 			return EINVAL;
 		}
 		smname = rf_find_non_white(smbuf, 1);
+		if (strlen(smname) >= RF_SPAREMAP_NAME_LEN) {
+			warnx("sparemap file name '%s' too long (max %d)",
+			smname, RF_SPAREMAP_NAME_LEN - 1);
+			fclose(fp);
+			return EINVAL;
+		}
 	} else {
 		smbuf[0] = '\0';
 		smname = smbuf;
@@ -415,6 +421,13 @@ rf_MakeLayoutSpecificDeclustered(FILE *c
 		*p++ = '\0';
 		i++;
 	}
+	if ((i & (sizeof(int) - 1)) != 0) {
+		/* panic, unaligned data; RF_SPAREMAP_NAME_LEN invalid */
+		warnx("Program Bug: (RF_SPAREMAP_NAME_LEN(%d) %% %zd) != 0",
+		RF_SPAREMAP_NAME_LEN, sizeof(int));
+		fclose(fp);
+		return EINVAL;
+	}
 
 	/*
 	 * fill in the buffer with the block design parameters
@@ -454,8 +467,8 @@ rf_MakeLayoutSpecificDeclustered(FILE *c
 static char *
 rf_find_non_white(char *p, int eatnl)
 {
-	for (; *p != '\0' && (*p == ' ' || *p == '\t'); p++)
-		continue;
+	while (*p == ' ' || *p == '\t')
+		p++;
 	if (*p == '\n' && eatnl)
 		*p = '\0';
 	return p;
@@ -465,8 +478,8 @@ rf_find_non_white(char *p, int eatnl)
 static char *
 rf_find_white(char *p)
 {
-	for (; *p != '\0' && *p != ' ' && *p != '\t'; p++)
-		continue;
+	while (*p != '\0' && *p != ' ' && *p != '\t')
+		p++;
 	return p;
 }
 
@@ -497,17 +510,15 @@ static int
 rf_get_next_nonblank_line(char *buf, int len, FILE *fp, const char *errmsg)
 {
 	char *p;
-	int l;
+	size_t l;
 
 	while (fgets(buf, len, fp) != NULL) {
 		p = rf_find_non_white(buf, 0);
 		if (*p == '\n' || *p == '\0' || *p == '#')
 			continue;
-		l = strlen(buf) - 1;
-		while (l >= 0 && (buf[l] == ' ' || buf[l] == '\n')) {
+		l = strlen(buf);
+		while (l > 0 && (buf[--l] == ' ' || buf[l] == '\n'))
 			buf[l] = '\0';
-			l--;
-		}
 		return 0;
 	}
 	if (errmsg)
@@ -536,6 +547,7 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 	char buf[BUFSIZ], targString[BUFSIZ], errString[BUFSIZ];
 	RF_SpareTableEntry_t **table;
 	FILE *fp = NULL;
+	size_t len;
 
 	/* allocate and initialize the table */
 	table = calloc(req->TablesPerSpareRegion, sizeof(*table));
@@ -546,7 +558,7 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 	for (i = 0; i < req->TablesPerSpareRegion; i++) {
 		table[i] = calloc(req->BlocksPerTable, sizeof(**table));
 		if (table[i] == NULL) {
-			warn("%s: Unable to allocate table", __func__);
+			warn("%s: Unable to allocate table:%d", __func__, i);
 			goto out;
 		}
 		for (j = 0; j < req->BlocksPerTable; j++)
@@ -563,7 +575,7 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 	"Invalid sparemap file:  can't find header line"))
 		goto out;
 
-	size_t len = strlen(buf);
+	len = strlen(buf);
 	if (len != 0 && buf[len - 1] == '\n')
 		buf[len - 1] = '\0';
 
@@ -579,13 +591,21 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 	/* no more blank lines or comments allowed now */
 	linecount = req->TablesPerSpareRegion * req->TableDepthInPUs;
 	for (i = 0; i < 

CVS commit: src/sbin/raidctl

2017-11-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Nov 22 00:31:31 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Several more cleanups:
1. Don't force use of "for" when "while" works better.
2. No need to check c != '\0' when we also check (c == ' ' || c == '\t')
3. Use the size of the buffer we're using, rather than a different one
   (not really a concern, they're the same size)
4. Don't use fscanf() to read file data, use fgets() & sscanf().
5. After using a pointer as a char *, validate alignment before switching
   to int * (can only fail if kernel #define gets set stupidly)   Or #6...
6. Validate sparemap file name isn't too long for assigned space.
7. recognise that strlen() returns size_t - don't shove it into an int.
8. On out of mem, be more clear which allocation failed in warning msg.

ATF tests all pass.   But I don't think they use sparemap files.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-11-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 21 16:31:37 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Avoid needless pointer calisthenics: [0] -> foo


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.30 src/sbin/raidctl/rf_configure.c:1.31
--- src/sbin/raidctl/rf_configure.c:1.30	Tue Nov 21 11:19:31 2017
+++ src/sbin/raidctl/rf_configure.c	Tue Nov 21 11:31:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.30 2017/11/21 16:19:31 kre Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.31 2017/11/21 16:31:37 christos Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.30 2017/11/21 16:19:31 kre Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.31 2017/11/21 16:31:37 christos Exp $");
 #endif
 
 
@@ -190,7 +190,7 @@ rf_MakeConfig(char *configname, RF_Confi
 			cp = rf_find_non_white(buf, 0);
 			if (!strncmp(cp, "START", sizeof("START") - 1))
 break;
-			(void) strlcpy(>debugVars[c][0], cp,
+			(void) strlcpy(cfgPtr->debugVars[c], cp,
 			sizeof(cfgPtr->debugVars[c]));
 		}
 	}
@@ -257,7 +257,7 @@ rf_MakeConfig(char *configname, RF_Confi
 b = buf;
 			}
 
-			strlcpy(>devnames[r][c][0], b,
+			strlcpy(cfgPtr->devnames[r][c], b,
 			sizeof(cfgPtr->devnames[r][c]));
 		}
 	}
@@ -284,7 +284,7 @@ rf_MakeConfig(char *configname, RF_Confi
 			b = buf;
 		}
 
-	strlcpy(>spare_names[r][0], b,
+	strlcpy(cfgPtr->spare_names[r], b,
 		sizeof(cfgPtr->spare_names[r]));
 	}
 



CVS commit: src/sbin/raidctl

2017-11-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 21 16:31:37 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
Avoid needless pointer calisthenics: [0] -> foo


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-11-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Nov 21 16:19:31 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
With char bug[SIZE]  using sizeof(bug[0]) is kind of boring, use
sizeof(bug) instead...


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.29 src/sbin/raidctl/rf_configure.c:1.30
--- src/sbin/raidctl/rf_configure.c:1.29	Mon Nov 20 22:16:23 2017
+++ src/sbin/raidctl/rf_configure.c	Tue Nov 21 16:19:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.29 2017/11/20 22:16:23 kre Exp $ */
+/*	$NetBSD: rf_configure.c,v 1.30 2017/11/21 16:19:31 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.29 2017/11/20 22:16:23 kre Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.30 2017/11/21 16:19:31 kre Exp $");
 #endif
 
 
@@ -258,7 +258,7 @@ rf_MakeConfig(char *configname, RF_Confi
 			}
 
 			strlcpy(>devnames[r][c][0], b,
-			sizeof(cfgPtr->devnames[r][c][0]));
+			sizeof(cfgPtr->devnames[r][c]));
 		}
 	}
 
@@ -285,7 +285,7 @@ rf_MakeConfig(char *configname, RF_Confi
 		}
 
 	strlcpy(>spare_names[r][0], b,
-		sizeof(cfgPtr->spare_names[r][0]));
+		sizeof(cfgPtr->spare_names[r]));
 	}
 
 	/* scan the file for the block related to layout */



CVS commit: src/sbin/raidctl

2017-11-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Nov 21 16:19:31 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
With char bug[SIZE]  using sizeof(bug[0]) is kind of boring, use
sizeof(bug) instead...


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-11-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Nov 20 22:16:23 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
White space and comment formatting.   NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.28 src/sbin/raidctl/rf_configure.c:1.29
--- src/sbin/raidctl/rf_configure.c:1.28	Mon Nov 20 19:10:45 2017
+++ src/sbin/raidctl/rf_configure.c	Mon Nov 20 22:16:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.28 2017/11/20 19:10:45 christos Exp $	*/
+/*	$NetBSD: rf_configure.c,v 1.29 2017/11/20 22:16:23 kre Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.28 2017/11/20 19:10:45 christos Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.29 2017/11/20 22:16:23 kre Exp $");
 #endif
 
 
@@ -76,9 +76,11 @@ static int rf_get_next_nonblank_line(cha
 static int distSpareYes = 1;
 static int distSpareNo = 0;
 
-/* The mapsw[] table below contains all the various RAID types that might
-be supported by the kernel.  The actual supported types are found
-in sys/dev/raidframe/rf_layout.c. */
+/*
+ * The mapsw[] table below contains all the various RAID types that might
+ * be supported by the kernel.  The actual supported types are found
+ * in sys/dev/raidframe/rf_layout.c.
+ */
 
 static const RF_LayoutSW_t mapsw[] = {
 	/* parity declustering */
@@ -135,7 +137,7 @@ rf_GetLayout(RF_ParityConfig_t parityCon
  * version of the driver, and in the user-level program that configures
  * the system via ioctl.
  */
-int 
+int
 rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
 {
 	int numscanned, val, r, c, retcode, aa, bb, cc;
@@ -162,9 +164,9 @@ rf_MakeConfig(char *configname, RF_Confi
 	"and numCol");
 
 	/*
- * wackiness with aa, bb, cc to get around size problems on
- * different platforms
- */
+	 * wackiness with aa, bb, cc to get around size problems on
+	 * different platforms
+	 */
 	numscanned = sscanf(buf, "%d %d %d", , , );
 	if (numscanned != 3) {
 		warnx("Config file error (\"array\" section): unable to get "
@@ -195,6 +197,7 @@ rf_MakeConfig(char *configname, RF_Confi
 	rewind(fp);
 	strlcpy(cfgPtr->diskQueueType, "fifo", sizeof(cfgPtr->diskQueueType));
 	cfgPtr->maxOutstandingDiskReqs = 1;
+
 	/* scan the file for the block related to disk queues */
 	if (rf_search_file_for_start_of("queue", buf, sizeof(buf), fp) ||
 	rf_get_next_nonblank_line(buf, sizeof(buf), fp, NULL)) {
@@ -202,9 +205,11 @@ rf_MakeConfig(char *configname, RF_Confi
 		"Using %s.]", configname, cfgPtr->diskQueueType);
 	}
 
-	/* the queue specifier line contains two entries: 1st char of first
+	/*
+	 * the queue specifier line contains two entries: 1st char of first
 	 * word specifies queue to be used 2nd word specifies max num reqs
-	 * that can be outstanding on the disk itself (typically 1) */
+	 * that can be outstanding on the disk itself (typically 1)
+	 */
 	if (sscanf(buf, "%s %d", buf1, ) != 2) {
 		warnx("Can't determine queue type and/or max outstanding "
 		"reqs from line: %*s", (int)(sizeof(buf) - 1), buf);
@@ -244,13 +249,13 @@ rf_MakeConfig(char *configname, RF_Confi
 goto out;
 			}
 
-		b = getfsspecname(b1, sizeof(b1), buf);
-if (b == NULL) {
+			b = getfsspecname(b1, sizeof(b1), buf);
+			if (b == NULL) {
 warnx("Config file error: warning: unable to "
 "get device file for disk at row %d col "
 "%d: %s", r, c, b1);
 b = buf;
-			} 
+			}
 
 			strlcpy(>devnames[r][c][0], b,
 			sizeof(cfgPtr->devnames[r][c][0]));
@@ -279,7 +284,7 @@ rf_MakeConfig(char *configname, RF_Confi
 			b = buf;
 		}
 
-	strlcpy(>spare_names[r][0], b, 
+	strlcpy(>spare_names[r][0], b,
 		sizeof(cfgPtr->spare_names[r][0]));
 	}
 
@@ -326,10 +331,11 @@ out:
 }
 
 
-/* used in architectures such as RAID0 where there is no layout-specific
+/*
+ * used in architectures such as RAID0 where there is no layout-specific
  * information to be passed into the configuration code.
  */
-int 
+int
 rf_MakeLayoutSpecificNULL(FILE *fp, RF_Config_t *cfgPtr, void *ignored)
 {
 	cfgPtr->layoutSpecificSize = 0;
@@ -337,7 +343,7 @@ rf_MakeLayoutSpecificNULL(FILE *fp, RF_C
 	return 0;
 }
 
-int 
+int
 rf_MakeLayoutSpecificDeclustered(FILE *configfp, RF_Config_t *cfgPtr, void *arg)
 {
 	int b, v, k, r, lambda, norotate, i, val, distSpare;
@@ -373,8 +379,10 @@ rf_MakeLayoutSpecificDeclustered(FILE *c
 		fclose(fp);
 		return EINVAL;
 	}
-	/* set the sparemap directory.  In the in-kernel version, there's a
-	 * daemon that's responsible for finding the sparemaps */
+	/*
+	 * set the sparemap directory.  In the in-kernel version, there's 

CVS commit: src/sbin/raidctl

2017-11-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Nov 20 22:16:23 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
White space and comment formatting.   NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-11-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 20 19:10:45 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c rf_configure.h

Log Message:
stop using magic constants
wrap long lines
use warn{,x}
make static
knf


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sbin/raidctl/rf_configure.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/raidctl/rf_configure.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.27 src/sbin/raidctl/rf_configure.c:1.28
--- src/sbin/raidctl/rf_configure.c:1.27	Mon Nov 20 13:37:56 2017
+++ src/sbin/raidctl/rf_configure.c	Mon Nov 20 14:10:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.27 2017/11/20 18:37:56 kardel Exp $	*/
+/*	$NetBSD: rf_configure.c,v 1.28 2017/11/20 19:10:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.27 2017/11/20 18:37:56 kardel Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.28 2017/11/20 19:10:45 christos Exp $");
 #endif
 
 
@@ -66,23 +66,21 @@ __RCSID("$NetBSD: rf_configure.c,v 1.27 
 #include 
 #include "rf_configure.h"
 
-RF_LayoutSW_t *rf_GetLayout(RF_ParityConfig_t parityConfig);
-char   *rf_find_non_white(char *p);
-char   *rf_find_white(char *p);
+static char   *rf_find_non_white(char *, int);
+static char   *rf_find_white(char *);
+static int rf_search_file_for_start_of(const char *, char *, int, FILE *);
+static int rf_get_next_nonblank_line(char *, int, FILE *, const char *);
+
 #define RF_MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define RF_ERRORMSG(s)printf((s))
-#define RF_ERRORMSG1(s,a) printf((s),(a))
-#define RF_ERRORMSG2(s,a,b)   printf((s),(a),(b))
-#define RF_ERRORMSG3(s,a,b,c) printf((s),(a),(b),(c))
 
-int distSpareYes = 1;
-int distSpareNo = 0;
+static int distSpareYes = 1;
+static int distSpareNo = 0;
 
 /* The mapsw[] table below contains all the various RAID types that might
 be supported by the kernel.  The actual supported types are found
 in sys/dev/raidframe/rf_layout.c. */
 
-static RF_LayoutSW_t mapsw[] = {
+static const RF_LayoutSW_t mapsw[] = {
 	/* parity declustering */
 	{'T', "Parity declustering",
 	 rf_MakeLayoutSpecificDeclustered, },
@@ -116,25 +114,21 @@ static RF_LayoutSW_t mapsw[] = {
 	/* end-of-list marker */
 	{'\0', NULL, NULL, NULL}
 };
-RF_LayoutSW_t *
+
+static const RF_LayoutSW_t *
 rf_GetLayout(RF_ParityConfig_t parityConfig)
 {
-	RF_LayoutSW_t *p;
+	const RF_LayoutSW_t *p;
 
 	/* look up the specific layout */
 	for (p = [0]; p->parityConfig; p++)
 		if (p->parityConfig == parityConfig)
 			break;
 	if (!p->parityConfig)
-		return (NULL);
-	return (p);
+		return NULL;
+	return p;
 }
 
-static int rf_search_file_for_start_of(const char *string, char *buf,
-int len, FILE * fp);
-static int rf_get_next_nonblank_line(char *buf, int len, FILE * fp,
-const char *errmsg);
-
 /*
  * called from user level to read the configuration file and create
  * a configuration control structure.  This is used in the user-level
@@ -145,24 +139,27 @@ int 
 rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
 {
 	int numscanned, val, r, c, retcode, aa, bb, cc;
-	char buf[256], buf1[256], *cp;
-	RF_LayoutSW_t *lp;
+	char buf[BUFSIZ], buf1[BUFSIZ], *cp;
+	const RF_LayoutSW_t *lp;
 	FILE *fp;
 
-	bzero((char *) cfgPtr, sizeof(RF_Config_t));
+	memset(cfgPtr, 0, sizeof(*cfgPtr));
 
 	fp = fopen(configname, "r");
 	if (!fp) {
-		printf("Can't open config file %s\n", configname);
-		return (-1);
+		warnx("Can't open config file %s", configname);
+		return -1;
 	}
 	rewind(fp);
-	if (rf_search_file_for_start_of("array", buf, 256, fp)) {
-		printf("Unable to find start of \"array\" params in config file %s\n", configname);
+	if (rf_search_file_for_start_of("array", buf, sizeof(buf), fp)) {
+		warnx("Unable to find start of \"array\" params in config "
+		"file %s", configname);
 		retcode = -1;
 		goto out;
 	}
-	rf_get_next_nonblank_line(buf, 256, fp, "Config file error (\"array\" section):  unable to get numRow and numCol\n");
+	rf_get_next_nonblank_line(buf, sizeof(buf), fp,
+	"Config file error (\"array\" section):  unable to get numRow "
+	"and numCol");
 
 	/*
  * wackiness with aa, bb, cc to get around size problems on
@@ -170,7 +167,8 @@ rf_MakeConfig(char *configname, RF_Confi
  */
 	numscanned = sscanf(buf, "%d %d %d", , , );
 	if (numscanned != 3) {
-		printf("Config file error (\"array\" section):  unable to get numRow, numCol, numSpare\n");
+		warnx("Config file error (\"array\" section): unable to get "
+		"numRow, numCol, numSpare");
 		retcode = -1;
 		goto out;
 	}
@@ -182,12 +180,13 @@ rf_MakeConfig(char *configname, RF_Confi
 	for (c = 0; c < RF_MAXDBGV; c++)
 		cfgPtr->debugVars[c][0] = '\0';
 	rewind(fp);
-	if 

CVS commit: src/sbin/raidctl

2017-11-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 20 19:10:45 UTC 2017

Modified Files:
src/sbin/raidctl: rf_configure.c rf_configure.h

Log Message:
stop using magic constants
wrap long lines
use warn{,x}
make static
knf


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sbin/raidctl/rf_configure.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/raidctl/rf_configure.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-11-20 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Mon Nov 20 18:37:56 UTC 2017

Modified Files:
src/sbin/raidctl: raidctl.8 rf_configure.c

Log Message:
support NAME= syntax for disks and spares


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.26 -r1.27 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.72 src/sbin/raidctl/raidctl.8:1.73
--- src/sbin/raidctl/raidctl.8:1.72	Mon Jul  3 21:33:42 2017
+++ src/sbin/raidctl/raidctl.8	Mon Nov 20 18:37:56 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.72 2017/07/03 21:33:42 wiz Exp $
+.\" $NetBSD: raidctl.8,v 1.73 2017/11/20 18:37:56 kardel Exp $
 .\"
 .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -388,6 +388,7 @@ START disks
 .Ed
 .Pp
 specifies the three component disks to be used in the RAID device.
+Disk wedges may also be specified with the NAME= syntax.
 If any of the specified drives cannot be found when the RAID device is
 configured, then they will be marked as
 .Sq failed ,

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.26 src/sbin/raidctl/rf_configure.c:1.27
--- src/sbin/raidctl/rf_configure.c:1.26	Wed Mar  9 19:53:32 2016
+++ src/sbin/raidctl/rf_configure.c	Mon Nov 20 18:37:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.26 2016/03/09 19:53:32 christos Exp $	*/
+/*	$NetBSD: rf_configure.c,v 1.27 2017/11/20 18:37:56 kardel Exp $	*/
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.26 2016/03/09 19:53:32 christos Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.27 2017/11/20 18:37:56 kardel Exp $");
 #endif
 
 
@@ -58,6 +58,7 @@ __RCSID("$NetBSD: rf_configure.c,v 1.26 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -72,6 +73,7 @@ char   *rf_find_white(char *p);
 #define RF_ERRORMSG(s)printf((s))
 #define RF_ERRORMSG1(s,a) printf((s),(a))
 #define RF_ERRORMSG2(s,a,b)   printf((s),(a),(b))
+#define RF_ERRORMSG3(s,a,b,c) printf((s),(a),(b),(c))
 
 int distSpareYes = 1;
 int distSpareNo = 0;
@@ -231,12 +233,25 @@ rf_MakeConfig(char *configname, RF_Confi
 	}
 	for (r = 0; r < cfgPtr->numRow; r++) {
 		for (c = 0; c < cfgPtr->numCol; c++) {
+			char b1[80];
+			const char *b;
+
 			if (rf_get_next_nonblank_line(
-			>devnames[r][c][0], 50, fp, NULL)) {
+			buf, sizeof(buf), fp, NULL)) {
 RF_ERRORMSG2("Config file error: unable to get device file for disk at row %d col %d\n", r, c);
 retcode = -1;
 goto out;
 			}
+
+		b = getfsspecname(b1, sizeof(b1), buf);
+if (b == NULL) {
+RF_ERRORMSG3(
+"Config file error: warning: unable to get device file for disk at row %d col %d: %s\n",
+r, c, b1);
+b = buf;
+			} 
+
+			strncpy(>devnames[r][c][0], b, 50);
 		}
 	}
 
@@ -245,12 +260,23 @@ rf_MakeConfig(char *configname, RF_Confi
 	if (rf_search_file_for_start_of("spare", buf, 256, fp))
 		cfgPtr->numSpare = 0;
 	for (c = 0; c < cfgPtr->numSpare; c++) {
-		if (rf_get_next_nonblank_line(>spare_names[c][0],
-		256, fp, NULL)) {
+		char b1[80];
+		const char *b;
+
+		if (rf_get_next_nonblank_line(buf,
+		sizeof(buf), fp, NULL)) {
 			RF_ERRORMSG1("Config file error: unable to get device file for spare disk %d\n", c);
 			retcode = -1;
 			goto out;
 		}
+
+		b = getfsspecname(b1, sizeof(b1), buf);
+		if (b == NULL) {
+			RF_ERRORMSG2("Config file error: warning: unable to get device file for spare disk %d: %s\n", c, b);
+			b = buf;
+		}
+
+	strncpy(>spare_names[r][0], b, 50);
 	}
 
 	/* scan the file for the block related to layout */



CVS commit: src/sbin/raidctl

2017-11-20 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Mon Nov 20 18:37:56 UTC 2017

Modified Files:
src/sbin/raidctl: raidctl.8 rf_configure.c

Log Message:
support NAME= syntax for disks and spares


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.26 -r1.27 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 20:47:05 UTC 2017

Modified Files:
src/sbin/raidctl: raidctl_hostops.c

Log Message:
need  for fstat()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/raidctl/raidctl_hostops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 20:47:05 UTC 2017

Modified Files:
src/sbin/raidctl: raidctl_hostops.c

Log Message:
need  for fstat()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/raidctl/raidctl_hostops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl_hostops.c
diff -u src/sbin/raidctl/raidctl_hostops.c:1.2 src/sbin/raidctl/raidctl_hostops.c:1.3
--- src/sbin/raidctl/raidctl_hostops.c:1.2	Wed Feb  9 06:22:49 2011
+++ src/sbin/raidctl/raidctl_hostops.c	Tue Jan 10 15:47:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidctl_hostops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $	*/
+/*	$NetBSD: raidctl_hostops.c,v 1.3 2017/01/10 20:47:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,11 +28,12 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: raidctl_hostops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $");
+__RCSID("$NetBSD: raidctl_hostops.c,v 1.3 2017/01/10 20:47:05 christos Exp $");
 #endif /* !lint */
 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/sbin/raidctl

2016-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar  9 19:53:32 UTC 2016

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
PR/50921: David Binderman: Fix memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/rf_configure.c
diff -u src/sbin/raidctl/rf_configure.c:1.25 src/sbin/raidctl/rf_configure.c:1.26
--- src/sbin/raidctl/rf_configure.c:1.25	Wed Jan 27 13:34:02 2010
+++ src/sbin/raidctl/rf_configure.c	Wed Mar  9 14:53:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_configure.c,v 1.25 2010/01/27 18:34:02 christos Exp $	*/
+/*	$NetBSD: rf_configure.c,v 1.26 2016/03/09 19:53:32 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.25 2010/01/27 18:34:02 christos Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.26 2016/03/09 19:53:32 christos Exp $");
 #endif
 
 
@@ -495,21 +495,19 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 	spareDisk, spareBlkOffset;
 	char buf[1024], targString[100], errString[100];
 	RF_SpareTableEntry_t **table;
-	FILE *fp;
+	FILE *fp = NULL;
 
 	/* allocate and initialize the table */
-	table = malloc(req->TablesPerSpareRegion * 
-		   sizeof(RF_SpareTableEntry_t *));
+	table = calloc(req->TablesPerSpareRegion, sizeof(*table));
 	if (table == NULL) {
-		warnx("rf_ReadSpareTable: Unable to allocate table");
-		return (NULL);
+		warn("%s: Unable to allocate table", __func__);
+		return NULL;
 	}
 	for (i = 0; i < req->TablesPerSpareRegion; i++) {
-		table[i] = malloc(req->BlocksPerTable * 
-  sizeof(RF_SpareTableEntry_t));
+		table[i] = calloc(req->BlocksPerTable, sizeof(**table));
 		if (table[i] == NULL) {
-			warnx("rf_ReadSpareTable: Unable to allocate table");
-			return (NULL);  /* XXX should cleanup too! */
+			warn("%s: Unable to allocate table", __func__);
+			goto out;
 		}
 		for (j = 0; j < req->BlocksPerTable; j++)
 			table[i][j].spareDisk =
@@ -518,22 +516,22 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 
 	/* 2.  open sparemap file, sanity check */
 	if ((fp = fopen(fname, "r")) == NULL) {
-		warn("rf_ReadSpareTable: Can't open sparemap file %s", fname);
-		return (NULL);
+		warn("%s: Can't open sparemap file %s", __func__, fname);
+		goto out;
 	}
 	if (rf_get_next_nonblank_line(buf, 1024, fp,
-	"Invalid sparemap file:  can't find header line\n")) {
-		fclose(fp);
-		return (NULL);
-	}
-	if (buf[strlen(buf) - 1] == '\n')
-		buf[strlen(buf) - 1] = '\0';
+	"Invalid sparemap file:  can't find header line\n"))
+		goto out;
+
+	size_t len = strlen(buf);
+	if (len != 0 && buf[len - 1] == '\n')
+		buf[len - 1] = '\0';
 
 	snprintf(targString, sizeof(targString), "fdisk %d\n", req->fcol);
 	snprintf(errString, sizeof(errString),
 	"Invalid sparemap file:  can't find \"fdisk %d\" line\n",
 	req->fcol);
-	while (1) {
+	for (;;) {
 		rf_get_next_nonblank_line(buf, 1024, fp, errString);
 		if (!strncmp(buf, targString, strlen(targString)))
 			break;
@@ -547,8 +545,7 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 		if (numFound != 4) {
 			warnx("Sparemap file prematurely exhausted after %d "
 			"of %d lines", i, linecount);
-			fclose(fp);
-			return (NULL);
+			goto out;
 		}
 
 		table[tableNum][tupleNum].spareDisk = spareDisk;
@@ -558,4 +555,11 @@ rf_ReadSpareTable(RF_SparetWait_t *req, 
 
 	fclose(fp);
 	return ((void *) table);
+out:
+	if (fp)
+		fclose(fp);
+	for (i = 0; i < req->TablesPerSpareRegion; i++)
+		free(table[i]);
+	free(table);
+	return NULL;
 }



CVS commit: src/sbin/raidctl

2016-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar  9 19:53:32 UTC 2016

Modified Files:
src/sbin/raidctl: rf_configure.c

Log Message:
PR/50921: David Binderman: Fix memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/raidctl/rf_configure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2016-01-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  6 17:41:36 UTC 2016

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Access to the SET_LAST_UNIT ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.63 -r1.64 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.69 src/sbin/raidctl/raidctl.8:1.70
--- src/sbin/raidctl/raidctl.8:1.69	Tue Jun 30 18:16:12 2015
+++ src/sbin/raidctl/raidctl.8	Wed Jan  6 12:41:36 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.69 2015/06/30 22:16:12 wiz Exp $
+.\" $NetBSD: raidctl.8,v 1.70 2016/01/06 17:41:36 christos 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 June 30, 2015
+.Dd January 6, 2016
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -125,6 +125,9 @@
 .Nm
 .Op Fl v
 .Fl u Ar dev
+.Nm
+.Op Fl v
+.Fl U Ar unit Ar dev
 .Sh DESCRIPTION
 .Nm
 is the user-land control program for
@@ -318,6 +321,12 @@ achieved in each of these areas.
 Unconfigure the RAIDframe device.
 This does not remove any component labels or change any configuration
 settings (e.g. auto-configuration settings) for the RAID set.
+.It Fl U Ar unit Ar dev
+Set the
+.Dv last_unit
+field in all the raid components, so that the next time the raid
+will be autoconfigured it uses that
+.Ar unit .
 .It Fl v
 Be more verbose.
 For operations such as reconstructions, parity

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.63 src/sbin/raidctl/raidctl.c:1.64
--- src/sbin/raidctl/raidctl.c:1.63	Tue Sep  8 04:59:09 2015
+++ src/sbin/raidctl/raidctl.c	Wed Jan  6 12:41:36 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.63 2015/09/08 08:59:09 bad Exp $   */
+/*  $NetBSD: raidctl.c,v 1.64 2016/01/06 17:41:36 christos Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.63 2015/09/08 08:59:09 bad Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.64 2016/01/06 17:41:36 christos Exp $");
 #endif
 
 
@@ -114,6 +114,7 @@ main(int argc,char *argv[])
 	int fd;
 	int force;
 	int openmode;
+	int last_unit;
 
 	num_options = 0;
 	action = 0;
@@ -122,9 +123,10 @@ main(int argc,char *argv[])
 	do_rewrite = 0;
 	serial_number = 0;
 	force = 0;
+	last_unit = 0;
 	openmode = O_RDWR;	/* default to read/write */
 
-	while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv")) 
+	while ((ch = getopt(argc, argv, "a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuU:v"))
 	   != -1)
 		switch(ch) {
 		case 'a':
@@ -244,6 +246,13 @@ main(int argc,char *argv[])
 			action = RAIDFRAME_SHUTDOWN;
 			num_options++;
 			break;
+		case 'U':
+			action = RAIDFRAME_SET_LAST_UNIT;
+			num_options++;
+			last_unit = atoi(optarg);
+			if (last_unit < 0)
+errx(1, "Bad last unit %s", optarg);
+			break;
 		case 'v':
 			verbose = 1;
 			/* Don't bump num_options, as '-v' is not 
@@ -342,6 +351,10 @@ main(int argc,char *argv[])
 	case RAIDFRAME_SHUTDOWN:
 		do_ioctl(fd, RAIDFRAME_SHUTDOWN, NULL, "RAIDFRAME_SHUTDOWN");
 		break;
+	case RAIDFRAME_SET_LAST_UNIT:
+		do_ioctl(fd, RAIDFRAME_SET_LAST_UNIT, _unit,
+		"RAIDFRAME_SET_LAST_UNIT");
+		break;
 	default:
 		break;
 	}



CVS commit: src/sbin/raidctl

2016-01-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  6 17:41:36 UTC 2016

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Access to the SET_LAST_UNIT ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.63 -r1.64 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2016-01-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan  6 22:57:44 UTC 2016

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Use standard sort order for options.

Add -U to usage.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.64 -r1.65 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.70 src/sbin/raidctl/raidctl.8:1.71
--- src/sbin/raidctl/raidctl.8:1.70	Wed Jan  6 17:41:36 2016
+++ src/sbin/raidctl/raidctl.8	Wed Jan  6 22:57:44 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.70 2016/01/06 17:41:36 christos Exp $
+.\" $NetBSD: raidctl.8,v 1.71 2016/01/06 22:57:44 wiz Exp $
 .\"
 .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -62,41 +62,38 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl v
-.Fl a Ar component Ar dev
-.Nm
-.Op Fl v
 .Fl A Op yes | no | forceroot | softroot
 .Ar dev
 .Nm
 .Op Fl v
-.Fl B Ar dev
+.Fl a Ar component Ar dev
 .Nm
 .Op Fl v
-.Fl c Ar config_file Ar dev
+.Fl B Ar dev
 .Nm
 .Op Fl v
 .Fl C Ar config_file Ar dev
 .Nm
 .Op Fl v
-.Fl f Ar component Ar dev
+.Fl c Ar config_file Ar dev
 .Nm
 .Op Fl v
 .Fl F Ar component Ar dev
 .Nm
 .Op Fl v
-.Fl g Ar component Ar dev
+.Fl f Ar component Ar dev
 .Nm
 .Op Fl v
 .Fl G Ar dev
 .Nm
 .Op Fl v
-.Fl i Ar dev
+.Fl g Ar component Ar dev
 .Nm
 .Op Fl v
 .Fl I Ar serial_number Ar dev
 .Nm
 .Op Fl v
-.Fl m Ar dev
+.Fl i Ar dev
 .Nm
 .Op Fl v
 .Fl M
@@ -106,28 +103,31 @@
 .Ar dev
 .Nm
 .Op Fl v
-.Fl p Ar dev
+.Fl m Ar dev
 .Nm
 .Op Fl v
 .Fl P Ar dev
 .Nm
 .Op Fl v
-.Fl r Ar component Ar dev
+.Fl p Ar dev
 .Nm
 .Op Fl v
 .Fl R Ar component Ar dev
 .Nm
 .Op Fl v
-.Fl s Ar dev
+.Fl r Ar component Ar dev
 .Nm
 .Op Fl v
 .Fl S Ar dev
 .Nm
 .Op Fl v
-.Fl u Ar dev
+.Fl s Ar dev
 .Nm
 .Op Fl v
 .Fl U Ar unit Ar dev
+.Nm
+.Op Fl v
+.Fl u Ar dev
 .Sh DESCRIPTION
 .Nm
 is the user-land control program for
@@ -146,16 +146,6 @@ The command-line options for
 .Nm
 are as follows:
 .Bl -tag -width indent
-.It Fl a Ar component Ar dev
-Add
-.Ar component
-as a hot spare for the device
-.Ar dev .
-Component labels (which identify the location of a given
-component within a particular RAID set) are automatically added to the
-hot spare after it has been used and are not required for
-.Ar component
-before it is used.
 .It Fl A Ic yes Ar dev
 Make the RAID set auto-configurable.
 The RAID set will be automatically configured at boot
@@ -192,11 +182,27 @@ can be used as an alias for
 Like
 .Ic forceroot ,
 but only change the root device if the boot device is part of the RAID set.
+.It Fl a Ar component Ar dev
+Add
+.Ar component
+as a hot spare for the device
+.Ar dev .
+Component labels (which identify the location of a given
+component within a particular RAID set) are automatically added to the
+hot spare after it has been used and are not required for
+.Ar component
+before it is used.
 .It Fl B Ar dev
 Initiate a copyback of reconstructed data from a spare disk to
 its original disk.
 This is performed after a component has failed,
 and the failed drive has been reconstructed onto a spare drive.
+.It Fl C Ar config_file Ar dev
+As for
+.Fl c ,
+but forces the configuration to take place.
+Fatal errors due to uninitialized components are ignored.
+This is required the first time a RAID set is configured.
 .It Fl c Ar config_file Ar dev
 Configure the RAIDframe device
 .Ar dev
@@ -205,16 +211,6 @@ according to the configuration given in
 A description of the contents of
 .Ar config_file
 is given later.
-.It Fl C Ar config_file Ar dev
-As for
-.Fl c ,
-but forces the configuration to take place.
-Fatal errors due to uninitialized components are ignored.
-This is required the first time a RAID set is configured.
-.It Fl f Ar component Ar dev
-This marks the specified
-.Ar component
-as having failed, but does not initiate a reconstruction of that component.
 .It Fl F Ar component Ar dev
 Fails the specified
 .Ar component
@@ -222,8 +218,10 @@ of the device, and immediately begin a r
 disk onto an available hot spare.
 This is one of the mechanisms used to start
 the reconstruction process if a component does have a hardware failure.
-.It Fl g Ar component Ar dev
-Get the component label for the specified component.
+.It Fl f Ar component Ar dev
+This marks the specified
+.Ar component
+as having failed, but does not initiate a reconstruction of that component.
 .It Fl G Ar dev
 Generate the configuration of the RAIDframe device in a format suitable for
 use with the
@@ -231,15 +229,8 @@ use with the
 or
 .Fl C
 options.
-.It Fl i Ar dev
-Initialize the RAID device.
-In particular, (re-)write the parity on the selected device.
-This
-.Em MUST
-be done for
-.Em all
-RAID sets before the RAID device is labeled and before
-file systems are created on the RAID device.

CVS commit: src/sbin/raidctl

2016-01-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan  6 22:57:44 UTC 2016

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Use standard sort order for options.

Add -U to usage.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.64 -r1.65 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-09-08 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Tue Sep  8 08:59:09 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Rename argument of rf_output_devname() from devname to name to avoid a
warning about shadowing a global symbol when compiled by buildrump.sh.
Discussed with mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.62 src/sbin/raidctl/raidctl.c:1.63
--- src/sbin/raidctl/raidctl.c:1.62	Tue Jul 21 05:54:44 2015
+++ src/sbin/raidctl/raidctl.c	Tue Sep  8 08:59:09 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.62 2015/07/21 05:54:44 mrg Exp $   */
+/*  $NetBSD: raidctl.c,v 1.63 2015/09/08 08:59:09 bad Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.62 2015/07/21 05:54:44 mrg Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.63 2015/09/08 08:59:09 bad Exp $");
 #endif
 
 
@@ -577,12 +577,12 @@ rf_pm_configure(int fd, int raidID, char
 }
 
 /* convert "component0" into "absent" */
-static const char *rf_output_devname(const char *devname)
+static const char *rf_output_devname(const char *name)
 {
 
-	if (strncmp(devname, "component", 9) == 0)
+	if (strncmp(name, "component", 9) == 0)
 		return "absent";
-	return devname;
+	return name;
 }
 
 static void



CVS commit: src/sbin/raidctl

2015-09-08 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Tue Sep  8 08:59:09 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Rename argument of rf_output_devname() from devname to name to avoid a
warning about shadowing a global symbol when compiled by buildrump.sh.
Discussed with mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-07-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Jul 21 05:54:44 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
convert component* into absent for START disks part of the
output from raidctl -G.  now this actually works when fed back
into raidctl -[cC].


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-07-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Jul 21 05:54:44 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
convert component* into absent for START disks part of the
output from raidctl -G.  now this actually works when fed back
into raidctl -[cC].


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.61 src/sbin/raidctl/raidctl.c:1.62
--- src/sbin/raidctl/raidctl.c:1.61	Tue Jun 30 17:02:14 2015
+++ src/sbin/raidctl/raidctl.c	Tue Jul 21 05:54:44 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.61 2015/06/30 17:02:14 sborrill Exp $   */
+/*  $NetBSD: raidctl.c,v 1.62 2015/07/21 05:54:44 mrg 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.61 2015/06/30 17:02:14 sborrill Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.62 2015/07/21 05:54:44 mrg Exp $);
 #endif
 
 
@@ -576,6 +576,14 @@ rf_pm_configure(int fd, int raidID, char
 	raidID, dis ? dis : en);
 }
 
+/* convert component0 into absent */
+static const char *rf_output_devname(const char *devname)
+{
+
+	if (strncmp(devname, component, 9) == 0)
+		return absent;
+	return devname;
+}
 
 static void
 rf_output_configuration(int fd, const char *name)
@@ -602,7 +610,8 @@ rf_output_configuration(int fd, const ch
 
 	printf(START disks\n);
 	for(i=0; i  device_config.ndevs; i++)
-		printf(%s\n, device_config.devs[i].devname);
+		printf(%s\n,
+		rf_output_devname(device_config.devs[i].devname));
 	printf(\n);
 
 	if (device_config.nspares  0) {



CVS commit: src/sbin/raidctl

2015-06-30 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue Jun 30 17:18:14 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Clarify that what was previously known as -A root is now -A forceroot, not
-A softroot and that -A root can still be used for historical reasons.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-06-30 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue Jun 30 17:02:14 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Compare correct length string for force option to -A


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.60 src/sbin/raidctl/raidctl.c:1.61
--- src/sbin/raidctl/raidctl.c:1.60	Fri Jun 26 01:16:54 2015
+++ src/sbin/raidctl/raidctl.c	Tue Jun 30 17:02:14 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $   */
+/*  $NetBSD: raidctl.c,v 1.61 2015/06/30 17:02:14 sborrill 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.60 2015/06/26 01:16:54 pooka Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.61 2015/06/30 17:02:14 sborrill Exp $);
 #endif
 
 
@@ -812,7 +812,7 @@ set_autoconfig(int fd, int raidID, char 
 
 	if (strncasecmp(autoconf, root, 4) == 0 ||
 	strncasecmp(autoconf, hard, 4) == 0 ||
-	strncasecmp(autoconf, force, 4) == 0) {
+	strncasecmp(autoconf, force, 5) == 0) {
 		root_config = 1;
 	} else if (strncasecmp(autoconf, soft, 4) == 0) {
 		root_config = 2;



CVS commit: src/sbin/raidctl

2015-06-30 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue Jun 30 17:18:14 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Clarify that what was previously known as -A root is now -A forceroot, not
-A softroot and that -A root can still be used for historical reasons.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.67 src/sbin/raidctl/raidctl.8:1.68
--- src/sbin/raidctl/raidctl.8:1.67	Thu Apr  3 18:54:10 2014
+++ src/sbin/raidctl/raidctl.8	Tue Jun 30 17:18:13 2015
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.67 2014/04/03 18:54:10 christos Exp $
+.\ $NetBSD: raidctl.8,v 1.68 2015/06/30 17:18:13 sborrill Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -175,6 +175,16 @@ in the disklabel.
 Note that only certain architectures
 .Pq currently alpha, amd64, i386, pmax, sandpoint, sparc, sparc64, and vax
 support booting a kernel directly from a RAID set.
+Please note that
+.Ic forceroot
+mode was referred to as
+.Ic root
+mode on earlier versions of
+.Nx .
+For compatibility reasons,
+.Ic root
+can be used as an alias for
+.Ic forceroot.
 .It Fl A Ic softroot Ar dev
 Like
 .Ic forceroot ,
@@ -1265,7 +1275,7 @@ partition of such a RAID set being used 
 .Pa / .
 To use raid0a as the root file system, simply use:
 .Bd -literal -offset indent
-raidctl -A root raid0
+raidctl -A forceroot raid0
 .Ed
 .Pp
 To return raid0a to be just an auto-configuring set simply use the



CVS commit: src/sbin/raidctl

2015-06-30 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue Jun 30 17:02:14 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Compare correct length string for force option to -A


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-06-30 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jun 30 22:16:12 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Bump date for previous. Add whitespace.
Fix some mandoc warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.68 src/sbin/raidctl/raidctl.8:1.69
--- src/sbin/raidctl/raidctl.8:1.68	Tue Jun 30 17:18:13 2015
+++ src/sbin/raidctl/raidctl.8	Tue Jun 30 22:16:12 2015
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.68 2015/06/30 17:18:13 sborrill Exp $
+.\ $NetBSD: raidctl.8,v 1.69 2015/06/30 22:16:12 wiz 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 April 3, 2014
+.Dd June 30, 2015
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -184,7 +184,7 @@ mode on earlier versions of
 For compatibility reasons,
 .Ic root
 can be used as an alias for
-.Ic forceroot.
+.Ic forceroot .
 .It Fl A Ic softroot Ar dev
 Like
 .Ic forceroot ,
@@ -1486,49 +1486,41 @@ Configure the RAID set with:
 .Bd -literal -offset indent
 raidctl -C raid0.conf raid0
 .Ed
-.Pp
 .It
 Initialize the component labels with:
 .Bd -literal -offset indent
 raidctl -I 123456 raid0
 .Ed
-.Pp
 .It
 Initialize other important parts of the set with:
 .Bd -literal -offset indent
 raidctl -i raid0
 .Ed
-.Pp
 .It
 Get the default label for the RAID set:
 .Bd -literal -offset indent
 disklabel raid0 \*[Gt] /tmp/label
 .Ed
-.Pp
 .It
 Edit the label:
 .Bd -literal -offset indent
 vi /tmp/label
 .Ed
-.Pp
 .It
 Put the new label on the RAID set:
 .Bd -literal -offset indent
 disklabel -R -r raid0 /tmp/label
 .Ed
-.Pp
 .It
 Create the file system:
 .Bd -literal -offset indent
 newfs /dev/rraid0e
 .Ed
-.Pp
 .It
 Mount the file system:
 .Bd -literal -offset indent
 mount /dev/raid0e /mnt
 .Ed
-.Pp
 .It
 Use:
 .Bd -literal -offset indent



CVS commit: src/sbin/raidctl

2015-06-30 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jun 30 22:16:12 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Bump date for previous. Add whitespace.
Fix some mandoc warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-06-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Jun 26 01:16:54 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
stars[offset] - stars+offset.  It's shorter!

Coincidentally, the change also works around a gcc 5.1 bug which causes
a segmentation fault when trying to compile the longer version (guess
the compiler got exhausted, or something).
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66345


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.59 src/sbin/raidctl/raidctl.c:1.60
--- src/sbin/raidctl/raidctl.c:1.59	Wed May 27 17:55:23 2015
+++ src/sbin/raidctl/raidctl.c	Fri Jun 26 01:16:54 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.59 2015/05/27 17:55:23 christos Exp $   */
+/*  $NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka 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.59 2015/05/27 17:55:23 christos Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $);
 #endif
 
 
@@ -1097,7 +1097,7 @@ get_bar(char *string, double percent, in
 		(int)((percent * max_strlen)/ 100);
 	if (offset  0)
 		offset = 0;
-	snprintf(string,max_strlen,%s,stars[offset]);
+	snprintf(string,max_strlen,%s,stars+offset);
 }
 
 static void



CVS commit: src/sbin/raidctl

2015-06-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Jun 26 01:16:54 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
stars[offset] - stars+offset.  It's shorter!

Coincidentally, the change also works around a gcc 5.1 bug which causes
a segmentation fault when trying to compile the longer version (guess
the compiler got exhausted, or something).
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66345


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sbin/raidctl

2015-05-28 Thread Joerg Sonnenberger
On Wed, May 27, 2015 at 03:31:15PM +, Emmanuel Dreyfus wrote:
 Module Name:  src
 Committed By: manu
 Date: Wed May 27 15:31:15 UTC 2015
 
 Modified Files:
   src/sbin/raidctl: raidctl.c
 
 Log Message:
 Better sanity check numbers given to raidctl(8)
 
 Replace atoi(3) by strtol(3), and check that numbers are valid,
 positive, and in int32_t range. The previous lack of check could
 silently lead to the same serial being set to all RAID volumes
 for instance because given numbers were bigger than INT_MAX. The
 consequence is in an awful mess when RAIDframe would mix volumes...

strtoi?

Joerg


CVS commit: src/sbin/raidctl

2015-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 27 17:55:23 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
use strtou


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.58 src/sbin/raidctl/raidctl.c:1.59
--- src/sbin/raidctl/raidctl.c:1.58	Wed May 27 11:31:15 2015
+++ src/sbin/raidctl/raidctl.c	Wed May 27 13:55:23 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.58 2015/05/27 15:31:15 manu Exp $   */
+/*  $NetBSD: raidctl.c,v 1.59 2015/05/27 17:55:23 christos 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.58 2015/05/27 15:31:15 manu Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.59 2015/05/27 17:55:23 christos Exp $);
 #endif
 
 
@@ -55,6 +55,7 @@ __RCSID($NetBSD: raidctl.c,v 1.58 2015/
 #include stdio.h
 #include stdlib.h
 #include string.h
+#include inttypes.h
 #include unistd.h
 #include util.h
 
@@ -85,7 +86,7 @@ static  void get_bar(char *, double, int
 static  void get_time_string(char *, int);
 static  void rf_output_pmstat(int, int);
 static  void rf_pm_configure(int, int, char *, int[]);
-static  unsigned int _strtoud(char *);
+static  unsigned int xstrtouint(const char *);
 
 int verbose;
 
@@ -184,7 +185,7 @@ main(int argc,char *argv[])
 			break;
 		case 'I':
 			action = RAIDFRAME_INIT_LABELS;
-			serial_number = _strtoud(optarg);
+			serial_number = xstrtouint(optarg);
 			num_options++;
 			break;
 		case 'm':
@@ -200,7 +201,7 @@ main(int argc,char *argv[])
 			i = 0;
 			while (i  3  optind  argc 
 			isdigit((int)argv[optind][0]))
-parityparams[i++] = _strtoud(argv[optind++]);
+parityparams[i++] = xstrtouint(argv[optind++]);
 			while (i  3)
 parityparams[i++] = 0;
 			break;
@@ -1161,24 +1162,11 @@ usage(void)
 }
 
 static unsigned int
-_strtoud(char *str)
+xstrtouint(const char *str)
 {
-	long num;
-	char *ep;
-
-	errno = 0;
-	num = strtol(str, ep, 10);
-	if (str[0] == '\0' || *ep != '\0')
-		errx(1, Not a number: %s, str);
-
-	if (errno)
-		err(1, Inavlid number %s, str);
-
-	if (num  0)
-		errx(1, Negative number: %s, str);
-
-	if (num  INT_MAX)
-		errx(1, Number too large: %s, str);
-
-	return (unsigned int)num;
+	int e;
+	unsigned int num = (unsigned int)strtou(str, NULL, 10, 0, INT_MAX, e);
+	if (e)
+		errc(EXIT_FAILURE, e, Bad number `%s', str);
+	return num;
 }



CVS commit: src/sbin/raidctl

2015-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 27 17:55:23 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
use strtou


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 27 15:31:15 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Better sanity check numbers given to raidctl(8)

Replace atoi(3) by strtol(3), and check that numbers are valid,
positive, and in int32_t range. The previous lack of check could
silently lead to the same serial being set to all RAID volumes
for instance because given numbers were bigger than INT_MAX. The
consequence is in an awful mess when RAIDframe would mix volumes...


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2015-05-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 27 15:31:15 UTC 2015

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Better sanity check numbers given to raidctl(8)

Replace atoi(3) by strtol(3), and check that numbers are valid,
positive, and in int32_t range. The previous lack of check could
silently lead to the same serial being set to all RAID volumes
for instance because given numbers were bigger than INT_MAX. The
consequence is in an awful mess when RAIDframe would mix volumes...


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.57 src/sbin/raidctl/raidctl.c:1.58
--- src/sbin/raidctl/raidctl.c:1.57	Thu Apr  3 18:54:10 2014
+++ src/sbin/raidctl/raidctl.c	Wed May 27 15:31:15 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $   */
+/*  $NetBSD: raidctl.c,v 1.58 2015/05/27 15:31:15 manu 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.57 2014/04/03 18:54:10 christos Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.58 2015/05/27 15:31:15 manu Exp $);
 #endif
 
 
@@ -85,6 +85,7 @@ static  void get_bar(char *, double, int
 static  void get_time_string(char *, int);
 static  void rf_output_pmstat(int, int);
 static  void rf_pm_configure(int, int, char *, int[]);
+static  unsigned int _strtoud(char *);
 
 int verbose;
 
@@ -183,7 +184,7 @@ main(int argc,char *argv[])
 			break;
 		case 'I':
 			action = RAIDFRAME_INIT_LABELS;
-			serial_number = atoi(optarg);
+			serial_number = _strtoud(optarg);
 			num_options++;
 			break;
 		case 'm':
@@ -195,11 +196,11 @@ main(int argc,char *argv[])
 			action = RAIDFRAME_PARITYMAP_SET_DISABLE;
 			parityconf = strdup(optarg);
 			num_options++;
-			/* XXXjld: should rf_pm_configure do the atoi()s? */
+			/* XXXjld: should rf_pm_configure do the strtol()s? */
 			i = 0;
 			while (i  3  optind  argc 
 			isdigit((int)argv[optind][0]))
-parityparams[i++] = atoi(argv[optind++]);
+parityparams[i++] = _strtoud(argv[optind++]);
 			while (i  3)
 parityparams[i++] = 0;
 			break;
@@ -1158,3 +1159,26 @@ usage(void)
 	exit(1);
 	/* NOTREACHED */
 }
+
+static unsigned int
+_strtoud(char *str)
+{
+	long num;
+	char *ep;
+
+	errno = 0;
+	num = strtol(str, ep, 10);
+	if (str[0] == '\0' || *ep != '\0')
+		errx(1, Not a number: %s, str);
+
+	if (errno)
+		err(1, Inavlid number %s, str);
+
+	if (num  0)
+		errx(1, Negative number: %s, str);
+
+	if (num  INT_MAX)
+		errx(1, Number too large: %s, str);
+
+	return (unsigned int)num;
+}



CVS commit: src/sbin/raidctl

2014-04-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  3 18:54:10 UTC 2014

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Add the ability to softroot mount (i.e. mount root only when the raid
set contains the boot device), as opposed to hardroot (the previous
default which forces the raid to be root no matter what).


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.56 -r1.57 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.66 src/sbin/raidctl/raidctl.8:1.67
--- src/sbin/raidctl/raidctl.8:1.66	Mon Oct  7 06:50:37 2013
+++ src/sbin/raidctl/raidctl.8	Thu Apr  3 14:54:10 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.66 2013/10/07 10:50:37 jdc Exp $
+.\ $NetBSD: raidctl.8,v 1.67 2014/04/03 18:54:10 christos 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 October 7, 2013
+.Dd April 3, 2014
 .Dt RAIDCTL 8
 .Os
 .Sh NAME
@@ -65,7 +65,7 @@
 .Fl a Ar component Ar dev
 .Nm
 .Op Fl v
-.Fl A Op yes | no | root
+.Fl A Op yes | no | forceroot | softroot
 .Ar dev
 .Nm
 .Op Fl v
@@ -163,7 +163,7 @@ Note that all components of the set must
 in the disklabel.
 .It Fl A Ic no Ar dev
 Turn off auto-configuration for the RAID set.
-.It Fl A Ic root Ar dev
+.It Fl A Ic forceroot Ar dev
 Make the RAID set auto-configurable, and also mark the set as being
 eligible to be the root partition.
 A RAID set configured this way will
@@ -175,6 +175,10 @@ in the disklabel.
 Note that only certain architectures
 .Pq currently alpha, amd64, i386, pmax, sandpoint, sparc, sparc64, and vax
 support booting a kernel directly from a RAID set.
+.It Fl A Ic softroot Ar dev
+Like
+.Ic forceroot ,
+but only change the root device if the boot device is part of the RAID set.
 .It Fl B Ar dev
 Initiate a copyback of reconstructed data from a spare disk to
 its original disk.

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.56 src/sbin/raidctl/raidctl.c:1.57
--- src/sbin/raidctl/raidctl.c:1.56	Fri Oct 18 21:09:59 2013
+++ src/sbin/raidctl/raidctl.c	Thu Apr  3 14:54:10 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.56 2013/10/19 01:09:59 christos Exp $   */
+/*  $NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos 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.56 2013/10/19 01:09:59 christos Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $);
 #endif
 
 
@@ -88,6 +88,8 @@ static  void rf_pm_configure(int, int, c
 
 int verbose;
 
+static const char *rootpart[] = { No, Force, Soft, *invalid* };
+
 int
 main(int argc,char *argv[])
 {
@@ -748,7 +750,7 @@ get_component_label(int fd, char *compon
 	printf(   Autoconfig: %s\n, 
 	   component_label.autoconfigure ? Yes : No );
 	printf(   Root partition: %s\n,
-	   component_label.root_partition ? Yes : No );
+	   rootpart[component_label.root_partition  3]);
 	printf(   Last configured as: raid%d\n, component_label.last_unit );
 }
 
@@ -806,12 +808,16 @@ set_autoconfig(int fd, int raidID, char 
 	auto_config = 0;
 	root_config = 0;
 
-	if (strncasecmp(autoconf,root, 4) == 0) {
+	if (strncasecmp(autoconf, root, 4) == 0 ||
+	strncasecmp(autoconf, hard, 4) == 0 ||
+	strncasecmp(autoconf, force, 4) == 0) {
 		root_config = 1;
+	} else if (strncasecmp(autoconf, soft, 4) == 0) {
+		root_config = 2;
 	}
 
 	if ((strncasecmp(autoconf,yes, 3) == 0) ||
-	root_config == 1) {
+	root_config  0) {
 		auto_config = 1;
 	}
 
@@ -824,9 +830,8 @@ set_autoconfig(int fd, int raidID, char 
 	printf(raid%d: Autoconfigure: %s\n, raidID,
 	   auto_config ? Yes : No);
 
-	if (root_config == 1) {
-		printf(raid%d: Root: %s\n, raidID,
-		   auto_config ? Yes : No);
+	if (auto_config == 1) {
+		printf(raid%d: Root: %s\n, raidID, rootpart[root_config]);
 	}
 }
 
@@ -1130,7 +1135,7 @@ usage(void)
 	const char *progname = getprogname();
 
 	fprintf(stderr, usage: %s [-v] -a component dev\n, progname);
-	fprintf(stderr,%s [-v] -A [yes | no | root] dev\n, progname);
+	fprintf(stderr,%s [-v] -A [yes | no | softroot | hardroot] dev\n, progname);
 	fprintf(stderr,%s [-v] -B dev\n, progname);
 	fprintf(stderr,%s [-v] -c config_file dev\n, progname);
 	fprintf(stderr,%s [-v] -C config_file dev\n, progname);



CVS commit: src/sbin/raidctl

2014-04-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  3 18:54:10 UTC 2014

Modified Files:
src/sbin/raidctl: raidctl.8 raidctl.c

Log Message:
Add the ability to softroot mount (i.e. mount root only when the raid
set contains the boot device), as opposed to hardroot (the previous
default which forces the raid to be root no matter what).


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sbin/raidctl/raidctl.8
cvs rdiff -u -r1.56 -r1.57 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2013-09-20 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Fri Sep 20 06:43:57 UTC 2013

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Note that NetBSD/amd64 can boot of RAID volumes.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.64 src/sbin/raidctl/raidctl.8:1.65
--- src/sbin/raidctl/raidctl.8:1.64	Fri Mar 23 18:28:13 2012
+++ src/sbin/raidctl/raidctl.8	Fri Sep 20 06:43:57 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.64 2012/03/23 18:28:13 njoly Exp $
+.\ $NetBSD: raidctl.8,v 1.65 2013/09/20 06:43:57 tron Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -173,7 +173,7 @@ All components of the set must be of typ
 .Dv RAID
 in the disklabel.
 Note that only certain architectures
-.Pq currently alpha, i386, pmax, sparc, sparc64, and vax
+.Pq currently alpha, amd64, i386, pmax, sparc, sparc64, and vax
 support booting a kernel directly from a RAID set.
 .It Fl B Ar dev
 Initiate a copyback of reconstructed data from a spare disk to



CVS commit: src/sbin/raidctl

2013-09-20 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Fri Sep 20 06:43:57 UTC 2013

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Note that NetBSD/amd64 can boot of RAID volumes.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2012-03-23 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri Mar 23 18:28:13 UTC 2012

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Remove unexpected newline between Em macro and text.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.63 src/sbin/raidctl/raidctl.8:1.64
--- src/sbin/raidctl/raidctl.8:1.63	Tue Aug  2 10:28:00 2011
+++ src/sbin/raidctl/raidctl.8	Fri Mar 23 18:28:13 2012
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.63 2011/08/02 10:28:00 wiz Exp $
+.\ $NetBSD: raidctl.8,v 1.64 2012/03/23 18:28:13 njoly Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -1603,8 +1603,7 @@ idea to zero out the first 64 blocks of 
 RAIDframe driver doesn't erroneously detect a component label in the
 new component.
 This is particularly true on
-.Em
-RAID 1
+.Em RAID 1
 sets because there is at most one correct component label in a failed RAID
 1 installation, and the RAIDframe driver picks the component label with the
 highest serial number and modification value as the authoritative source



CVS commit: src/sbin/raidctl

2012-03-23 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri Mar 23 18:28:13 UTC 2012

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Remove unexpected newline between Em macro and text.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2011-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 12 16:45:37 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
PR/45456: Tetsuya Isaki: Don't mix stdio and write.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.54 src/sbin/raidctl/raidctl.c:1.55
--- src/sbin/raidctl/raidctl.c:1.54	Wed Sep 28 06:29:41 2011
+++ src/sbin/raidctl/raidctl.c	Wed Oct 12 12:45:37 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.54 2011/09/28 10:29:41 mrg Exp $   */
+/*  $NetBSD: raidctl.c,v 1.55 2011/10/12 16:45:37 christos 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.54 2011/09/28 10:29:41 mrg Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.55 2011/10/12 16:45:37 christos Exp $);
 #endif
 
 
@@ -988,7 +988,6 @@ do_meter(int fd, u_long option)
 	double rate;
 	RF_uint64 amount;
 	int tbit_value;
-	char buffer[1024];
 	char bar_buffer[1024];
 	char eta_buffer[1024];
 
@@ -1049,10 +1048,8 @@ do_meter(int fd, u_long option)
 
 		get_time_string(eta_buffer, simple_eta);
 
-		snprintf(buffer,1024,\r%3d%% |%s| ETA: %s %c,
-			 percent_done,bar_buffer,eta_buffer,tbits[tbit_value]);
-
-		write(fileno(stdout),buffer,strlen(buffer));
+		fprintf(stdout,\r%3d%% |%s| ETA: %s %c,
+			percent_done,bar_buffer,eta_buffer,tbits[tbit_value]);
 		fflush(stdout);
 
 		if (++tbit_value3) 



CVS commit: src/sbin/raidctl

2011-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 12 16:45:37 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
PR/45456: Tetsuya Isaki: Don't mix stdio and write.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2011-09-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep 28 10:29:42 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
print the serial number as an unsigned number.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.53 src/sbin/raidctl/raidctl.c:1.54
--- src/sbin/raidctl/raidctl.c:1.53	Mon Aug 29 14:35:03 2011
+++ src/sbin/raidctl/raidctl.c	Wed Sep 28 10:29:41 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.53 2011/08/29 14:35:03 joerg Exp $   */
+/*  $NetBSD: raidctl.c,v 1.54 2011/09/28 10:29:41 mrg 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.53 2011/08/29 14:35:03 joerg Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.54 2011/09/28 10:29:41 mrg Exp $);
 #endif
 
 
@@ -734,7 +734,7 @@ get_component_label(int fd, char *compon
 	printf(   Row: %d, Column: %d, Num Rows: %d, Num Columns: %d\n,
 	   component_label.row, component_label.column, 
 	   component_label.num_rows, component_label.num_columns);
-	printf(   Version: %d, Serial Number: %d, Mod Counter: %d\n,
+	printf(   Version: %d, Serial Number: %u, Mod Counter: %d\n,
 	   component_label.version, component_label.serial_number,
 	   component_label.mod_counter);
 	printf(   Clean: %s, Status: %d\n,



CVS commit: src/sbin/raidctl

2011-09-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep 28 10:29:42 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
print the serial number as an unsigned number.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2011-08-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  2 10:28:00 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.62 src/sbin/raidctl/raidctl.8:1.63
--- src/sbin/raidctl/raidctl.8:1.62	Thu Jul 28 18:25:22 2011
+++ src/sbin/raidctl/raidctl.8	Tue Aug  2 10:28:00 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.62 2011/07/28 18:25:22 buhrow Exp $
+.\ $NetBSD: raidctl.8,v 1.63 2011/08/02 10:28:00 wiz Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -1600,8 +1600,9 @@
 .Pp
 When replacing a failed component of a RAID set, it is a good
 idea to zero out the first 64 blocks of the new component to insure the
-RAIDframe driver doesn't erroneously detect a component label in the 
-new component.  This is particularly true on
+RAIDframe driver doesn't erroneously detect a component label in the
+new component.
+This is particularly true on
 .Em
 RAID 1
 sets because there is at most one correct component label in a failed RAID



CVS commit: src/sbin/raidctl

2011-08-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  2 10:28:00 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2011-07-28 Thread Brian Buhrow
Module Name:src
Committed By:   buhrow
Date:   Thu Jul 28 18:25:22 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Document the need for zeroing out the first 64 blocks of a replacement
component in a failed RAID set in order to avoid potentially configuring
RAId 1 sets with erroneous values taken from random extent data in the
replacement component partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.8
diff -u src/sbin/raidctl/raidctl.8:1.61 src/sbin/raidctl/raidctl.8:1.62
--- src/sbin/raidctl/raidctl.8:1.61	Wed Jan 27 09:26:16 2010
+++ src/sbin/raidctl/raidctl.8	Thu Jul 28 18:25:22 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: raidctl.8,v 1.61 2010/01/27 09:26:16 wiz Exp $
+.\ $NetBSD: raidctl.8,v 1.62 2011/07/28 18:25:22 buhrow Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -1597,5 +1597,17 @@
 additional space and speed, than it is to use parity, but
 not keep the parity correct.
 At least with RAID 0 there is no perception of increased data security.
+.Pp
+When replacing a failed component of a RAID set, it is a good
+idea to zero out the first 64 blocks of the new component to insure the
+RAIDframe driver doesn't erroneously detect a component label in the 
+new component.  This is particularly true on
+.Em
+RAID 1
+sets because there is at most one correct component label in a failed RAID
+1 installation, and the RAIDframe driver picks the component label with the
+highest serial number and modification value as the authoritative source
+for the failed RAID set when choosing which component label to use to
+configure the RAID set.
 .Sh BUGS
 Hot-spare removal is currently not available.



CVS commit: src/sbin/raidctl

2011-07-28 Thread Brian Buhrow
Module Name:src
Committed By:   buhrow
Date:   Thu Jul 28 18:25:22 UTC 2011

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Document the need for zeroing out the first 64 blocks of a replacement
component in a failed RAID set in order to avoid potentially configuring
RAId 1 sets with erroneous values taken from random extent data in the
replacement component partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2011-02-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Feb  9 11:22:49 UTC 2011

Modified Files:
src/sbin/raidctl: prog_ops.h raidctl.c raidctl_hostops.c
raidctl_rumpops.c

Log Message:
Exterminate a bug I created in 2009.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/raidctl/prog_ops.h \
src/sbin/raidctl/raidctl_hostops.c src/sbin/raidctl/raidctl_rumpops.c
cvs rdiff -u -r1.50 -r1.51 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/prog_ops.h
diff -u src/sbin/raidctl/prog_ops.h:1.1 src/sbin/raidctl/prog_ops.h:1.2
--- src/sbin/raidctl/prog_ops.h:1.1	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/prog_ops.h	Wed Feb  9 11:22:49 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.2 2011/02/09 11:22:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 
 	int (*op_open)(const char *, int, ...);
 	int (*op_ioctl)(int, unsigned long, ...);
+	int (*op_fstat)(int, struct stat *);
 	int (*op_close)(int);
 };
 extern const struct prog_ops prog_ops;
@@ -44,11 +45,13 @@
 #define prog_init prog_ops.op_init
 #define prog_open prog_ops.op_open
 #define prog_ioctl prog_ops.op_ioctl
+#define prog_fstat prog_ops.op_fstat
 #define prog_close prog_ops.op_close
 #else
 #define prog_init ((int (*)(void))NULL)
 #define prog_open open
 #define prog_ioctl ioctl
+#define prog_fstat fstat
 #define prog_close close
 #endif
 
Index: src/sbin/raidctl/raidctl_hostops.c
diff -u src/sbin/raidctl/raidctl_hostops.c:1.1 src/sbin/raidctl/raidctl_hostops.c:1.2
--- src/sbin/raidctl/raidctl_hostops.c:1.1	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/raidctl_hostops.c	Wed Feb  9 11:22:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidctl_hostops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+/*	$NetBSD: raidctl_hostops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: raidctl_hostops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $);
+__RCSID($NetBSD: raidctl_hostops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -42,5 +42,6 @@
 const struct prog_ops prog_ops = {
 	.op_open = open,
 	.op_ioctl = ioctl,
+	.op_fstat = fstat,
 	.op_close = close,
 };
Index: src/sbin/raidctl/raidctl_rumpops.c
diff -u src/sbin/raidctl/raidctl_rumpops.c:1.1 src/sbin/raidctl/raidctl_rumpops.c:1.2
--- src/sbin/raidctl/raidctl_rumpops.c:1.1	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/raidctl_rumpops.c	Wed Feb  9 11:22:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidctl_rumpops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+/*	$NetBSD: raidctl_rumpops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: raidctl_rumpops.c,v 1.1 2010/12/15 18:37:55 pooka Exp $);
+__RCSID($NetBSD: raidctl_rumpops.c,v 1.2 2011/02/09 11:22:49 pooka Exp $);
 #endif /* !lint */
 
 #include sys/types.h
@@ -44,5 +44,6 @@
 
 	.op_open =	rump_sys_open,
 	.op_ioctl =	rump_sys_ioctl,
+	.op_fstat =	rump_sys_fstat,
 	.op_close =	rump_sys_close,
 };

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.50 src/sbin/raidctl/raidctl.c:1.51
--- src/sbin/raidctl/raidctl.c:1.50	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/raidctl.c	Wed Feb  9 11:22:49 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.50 2010/12/15 18:37:55 pooka Exp $   */
+/*  $NetBSD: raidctl.c,v 1.51 2011/02/09 11:22:49 pooka 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.50 2010/12/15 18:37:55 pooka Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.51 2011/02/09 11:22:49 pooka Exp $);
 #endif
 
 
@@ -265,7 +265,7 @@
 	prog_open);
 	if (fd == -1)
 		err(1, Unable to open device file: %s, name);
-	if (fstat(fd, st) == -1)
+	if (prog_fstat(fd, st) == -1)
 		err(1, stat failure on: %s, dev_name);
 	if (!S_ISBLK(st.st_mode)  !S_ISCHR(st.st_mode))
 		err(1, invalid device: %s, dev_name);



CVS commit: src/sbin/raidctl

2011-02-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Feb  9 11:22:49 UTC 2011

Modified Files:
src/sbin/raidctl: prog_ops.h raidctl.c raidctl_hostops.c
raidctl_rumpops.c

Log Message:
Exterminate a bug I created in 2009.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/raidctl/prog_ops.h \
src/sbin/raidctl/raidctl_hostops.c src/sbin/raidctl/raidctl_rumpops.c
cvs rdiff -u -r1.50 -r1.51 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2010-12-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Dec 15 18:37:55 UTC 2010

Modified Files:
src/sbin/raidctl: Makefile raidctl.c
Added Files:
src/sbin/raidctl: prog_ops.h raidctl_hostops.c raidctl_rumpops.c

Log Message:
Use RUMPPRG.

ok Greg Oster


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/raidctl/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/raidctl/prog_ops.h \
src/sbin/raidctl/raidctl_hostops.c src/sbin/raidctl/raidctl_rumpops.c
cvs rdiff -u -r1.49 -r1.50 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/Makefile
diff -u src/sbin/raidctl/Makefile:1.15 src/sbin/raidctl/Makefile:1.16
--- src/sbin/raidctl/Makefile:1.15	Mon Nov  8 12:42:35 2010
+++ src/sbin/raidctl/Makefile	Wed Dec 15 18:37:55 2010
@@ -1,16 +1,10 @@
-#	$NetBSD: Makefile,v 1.15 2010/11/08 12:42:35 pooka Exp $
+#	$NetBSD: Makefile,v 1.16 2010/12/15 18:37:55 pooka Exp $
 
-PROG=	raidctl 
+RUMPPRG=raidctl 
 SRCS=	rf_configure.c raidctl.c
 MAN=	raidctl.8
 
 DPADD=  ${LIBUTIL}
 LDADD=  -lutil
 
-.ifdef RUMP_ACTION
-CPPFLAGS+=	-DRUMP_ACTION -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
-LDADD+=		-lrumpclient
-DBG=		-g
-.endif
-
 .include bsd.prog.mk

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.49 src/sbin/raidctl/raidctl.c:1.50
--- src/sbin/raidctl/raidctl.c:1.49	Mon Nov  8 12:42:35 2010
+++ src/sbin/raidctl/raidctl.c	Wed Dec 15 18:37:55 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.49 2010/11/08 12:42:35 pooka Exp $   */
+/*  $NetBSD: raidctl.c,v 1.50 2010/12/15 18:37:55 pooka 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.49 2010/11/08 12:42:35 pooka Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.50 2010/12/15 18:37:55 pooka Exp $);
 #endif
 
 
@@ -58,15 +58,10 @@
 #include unistd.h
 #include util.h
 
-#ifdef RUMP_ACTION
-#include rump/rump.h
-#include rump/rumpclient.h
-#include rump/rump_syscalls.h
-#endif
-
 #include dev/raidframe/raidframevar.h
 #include dev/raidframe/raidframeio.h
 #include rf_configure.h
+#include prog_ops.h
 
 void	do_ioctl(int, u_long, void *, const char *);
 static  void rf_configure(int, char*, int);
@@ -127,11 +122,6 @@
 	force = 0;
 	openmode = O_RDWR;	/* default to read/write */
 
-#ifdef RUMP_ACTION
-	if (rumpclient_init() == -1)
-		err(1, rump client init failed);
-#endif
-
 	while ((ch = getopt(argc, argv, a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv)) 
 	   != -1)
 		switch(ch) {
@@ -267,13 +257,12 @@
 	if ((num_options  1) || (argc == 0)) 
 		usage();
 
+	if (prog_init  prog_init() == -1)
+		err(1, init failed);
+
 	strlcpy(name, argv[0], sizeof(name));
-#ifdef RUMP_ACTION
 	fd = opendisk1(name, openmode, dev_name, sizeof(dev_name), 0,
-	rump_sys_open);
-#else
-	fd = opendisk(name, openmode, dev_name, sizeof(dev_name), 0);
-#endif
+	prog_open);
 	if (fd == -1)
 		err(1, Unable to open device file: %s, name);
 	if (fstat(fd, st) == -1)
@@ -355,14 +344,14 @@
 		break;
 	}
 
-	close(fd);
+	prog_close(fd);
 	exit(0);
 }
 
 void
 do_ioctl(int fd, unsigned long command, void *arg, const char *ioctl_name)
 {
-	if (ioctl(fd, command, arg) == -1)
+	if (prog_ioctl(fd, command, arg) == -1)
 		err(1, ioctl (%s) failed, ioctl_name);
 }
 
@@ -491,7 +480,7 @@
 	int dis, dr;
 	struct rf_pmstat st;
 
-	if (ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, st) == -1) {
+	if (prog_ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, st) == -1) {
 		if (errno == EINVAL) {
 			printf(raid%d: has no parity; parity map disabled\n,
 raidID);

Added files:

Index: src/sbin/raidctl/prog_ops.h
diff -u /dev/null src/sbin/raidctl/prog_ops.h:1.1
--- /dev/null	Wed Dec 15 18:37:55 2010
+++ src/sbin/raidctl/prog_ops.h	Wed Dec 15 18:37:55 2010
@@ -0,0 +1,55 @@
+/*  $NetBSD: prog_ops.h,v 1.1 2010/12/15 18:37:55 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * 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 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 

CVS commit: src/sbin/raidctl

2010-11-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov  8 12:42:35 UTC 2010

Modified Files:
src/sbin/raidctl: Makefile raidctl.c

Log Message:
Update RUMP_ACTION to use rumpclient.

The server must of course have some disks configured.  Let's say
we have this simple server with disks as a few sparse host files:

main()
{
rump_init();
rump_pub_etfs_register(/disk1, ./disk1.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk2, ./disk2.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk3, ./disk3.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk4, ./disk4.img, RUMP_ETFS_BLK);
pause();
}

And we run the server:

mainbus0 (root)
Kernelized RAIDframe activated
/disk1: hostpath ./disk1.img (97 GB)
/disk2: hostpath ./disk2.img (97 GB)
/disk3: hostpath ./disk3.img (97 GB)
/disk4: hostpath ./disk4.img (97 GB)

We can then configure the raid against the server:

 ./raidctl -c theraid.conf raid0

And lo, we have evidence of a level1 raid in the server dmesg:

raid0: RAID Level 1
raid0: Components: /disk1 /disk2 /disk3 /disk4
raid0: Total Sectors: 409599744 (19 MB)

yea, i initialized it already in a previous run:

 ./raidctl -S raid0
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/raidctl/Makefile
cvs rdiff -u -r1.48 -r1.49 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/Makefile
diff -u src/sbin/raidctl/Makefile:1.14 src/sbin/raidctl/Makefile:1.15
--- src/sbin/raidctl/Makefile:1.14	Sun Oct 11 12:51:58 2009
+++ src/sbin/raidctl/Makefile	Mon Nov  8 12:42:35 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14 2009/10/11 12:51:58 pooka Exp $
+#	$NetBSD: Makefile,v 1.15 2010/11/08 12:42:35 pooka Exp $
 
 PROG=	raidctl 
 SRCS=	rf_configure.c raidctl.c
@@ -9,8 +9,7 @@
 
 .ifdef RUMP_ACTION
 CPPFLAGS+=	-DRUMP_ACTION -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
-LDADD+=		-lrumpdev_disk -lrumpdev_raidframe -lrumpdev
-LDADD+=		-lrumpvfs -lrump -lrumpuser -lpthread
+LDADD+=		-lrumpclient
 DBG=		-g
 .endif
 

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.48 src/sbin/raidctl/raidctl.c:1.49
--- src/sbin/raidctl/raidctl.c:1.48	Tue Mar 16 03:23:47 2010
+++ src/sbin/raidctl/raidctl.c	Mon Nov  8 12:42:35 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.48 2010/03/16 03:23:47 jld Exp $   */
+/*  $NetBSD: raidctl.c,v 1.49 2010/11/08 12:42:35 pooka 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.48 2010/03/16 03:23:47 jld Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.49 2010/11/08 12:42:35 pooka Exp $);
 #endif
 
 
@@ -58,8 +58,11 @@
 #include unistd.h
 #include util.h
 
+#ifdef RUMP_ACTION
 #include rump/rump.h
+#include rump/rumpclient.h
 #include rump/rump_syscalls.h
+#endif
 
 #include dev/raidframe/raidframevar.h
 #include dev/raidframe/raidframeio.h
@@ -125,7 +128,8 @@
 	openmode = O_RDWR;	/* default to read/write */
 
 #ifdef RUMP_ACTION
-	rump_init();
+	if (rumpclient_init() == -1)
+		err(1, rump client init failed);
 #endif
 
 	while ((ch = getopt(argc, argv, a:A:Bc:C:f:F:g:GiI:l:mM:r:R:sSpPuv)) 



CVS commit: src/sbin/raidctl

2010-11-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov  8 12:42:35 UTC 2010

Modified Files:
src/sbin/raidctl: Makefile raidctl.c

Log Message:
Update RUMP_ACTION to use rumpclient.

The server must of course have some disks configured.  Let's say
we have this simple server with disks as a few sparse host files:

main()
{
rump_init();
rump_pub_etfs_register(/disk1, ./disk1.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk2, ./disk2.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk3, ./disk3.img, RUMP_ETFS_BLK);
rump_pub_etfs_register(/disk4, ./disk4.img, RUMP_ETFS_BLK);
pause();
}

And we run the server:

mainbus0 (root)
Kernelized RAIDframe activated
/disk1: hostpath ./disk1.img (97 GB)
/disk2: hostpath ./disk2.img (97 GB)
/disk3: hostpath ./disk3.img (97 GB)
/disk4: hostpath ./disk4.img (97 GB)

We can then configure the raid against the server:

 ./raidctl -c theraid.conf raid0

And lo, we have evidence of a level1 raid in the server dmesg:

raid0: RAID Level 1
raid0: Components: /disk1 /disk2 /disk3 /disk4
raid0: Total Sectors: 409599744 (19 MB)

yea, i initialized it already in a previous run:

 ./raidctl -S raid0
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/raidctl/Makefile
cvs rdiff -u -r1.48 -r1.49 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2010-03-15 Thread Jed Davis
Module Name:src
Committed By:   jld
Date:   Tue Mar 16 03:23:47 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Give a more polite message for `raidctl -m` on a non-parity RAID set.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.47 src/sbin/raidctl/raidctl.c:1.48
--- src/sbin/raidctl/raidctl.c:1.47	Sat Mar 13 13:45:05 2010
+++ src/sbin/raidctl/raidctl.c	Tue Mar 16 03:23:47 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.47 2010/03/13 13:45:05 plunky Exp $   */
+/*  $NetBSD: raidctl.c,v 1.48 2010/03/16 03:23:47 jld 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.47 2010/03/13 13:45:05 plunky Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.48 2010/03/16 03:23:47 jld Exp $);
 #endif
 
 
@@ -487,8 +487,15 @@
 	int dis, dr;
 	struct rf_pmstat st;
 
-	do_ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, st,
-	RAIDFRAME_PARITYMAP_STATUS);
+	if (ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, st) == -1) {
+		if (errno == EINVAL) {
+			printf(raid%d: has no parity; parity map disabled\n,
+raidID);
+			return;
+		}
+		err(1, ioctl (%s) failed, RAIDFRAME_PARITYMAP_STATUS);
+	}
+
 	if (st.enabled) {
 		if (0  humanize_number(srs, 7, st.region_size * DEV_BSIZE, 
 			B, HN_AUTOSCALE, HN_NOSPACE))



CVS commit: src/sbin/raidctl

2010-03-13 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Mar 13 13:45:05 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
fix sign-compare issue


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.46 src/sbin/raidctl/raidctl.c:1.47
--- src/sbin/raidctl/raidctl.c:1.46	Sat Mar 13 07:21:37 2010
+++ src/sbin/raidctl/raidctl.c	Sat Mar 13 13:45:05 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.46 2010/03/13 07:21:37 jld Exp $   */
+/*  $NetBSD: raidctl.c,v 1.47 2010/03/13 13:45:05 plunky 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.46 2010/03/13 07:21:37 jld Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.47 2010/03/13 13:45:05 plunky Exp $);
 #endif
 
 
@@ -483,8 +483,8 @@
 rf_output_pmstat(int fd, int raidID)
 {
 	char srs[7];
-	int i, j, dr;
-	int dis;
+	unsigned int i, j;
+	int dis, dr;
 	struct rf_pmstat st;
 
 	do_ioctl(fd, RAIDFRAME_PARITYMAP_STATUS, st,



CVS commit: src/sbin/raidctl

2010-03-12 Thread Jed Davis
Module Name:src
Committed By:   jld
Date:   Sat Mar 13 07:21:38 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
Exclude parity map regions that don't actually exist from the dirty region count
in `raidctl -m`.  Makes for less confusing output during `raidctl -i`.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/raidctl/raidctl.c
diff -u src/sbin/raidctl/raidctl.c:1.45 src/sbin/raidctl/raidctl.c:1.46
--- src/sbin/raidctl/raidctl.c:1.45	Wed Jan 27 18:34:02 2010
+++ src/sbin/raidctl/raidctl.c	Sat Mar 13 07:21:37 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: raidctl.c,v 1.45 2010/01/27 18:34:02 christos Exp $   */
+/*  $NetBSD: raidctl.c,v 1.46 2010/03/13 07:21:37 jld 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.45 2010/01/27 18:34:02 christos Exp $);
+__RCSID($NetBSD: raidctl.c,v 1.46 2010/03/13 07:21:37 jld Exp $);
 #endif
 
 
@@ -504,7 +504,7 @@
 		st.ctrs.nwrite, st.ctrs.ncachesync, st.ctrs.nclearing);
 
 		dr = 0;
-		for (i = 0; i  RF_PARITYMAP_NREG; i++)
+		for (i = 0; i  st.params.regions; i++)
 			if (isset(st.dirty, i))
 dr++;
 		printf(raid%d: %d dirty region%s\n, raidID, dr,



CVS commit: src/sbin/raidctl

2010-01-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 27 08:56:08 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
Consistently use START disks in examples. Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2010-01-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 27 09:26:16 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.8

Log Message:
+ Fatal errors due to uninitialized components are ignored.
for -C. For dillo@


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/raidctl/raidctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/raidctl

2010-01-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jan 27 17:02:06 UTC 2010

Modified Files:
src/sbin/raidctl: raidctl.c

Log Message:
error message: \n\n - \n


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sbin/raidctl/raidctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   >