CVS commit: src/sbin/cgdconfig

2024-04-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Apr 29 00:28:18 UTC 2024

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

Log Message:
cgdconfig(8): KNF in cgdconfig.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/cgdconfig/cgdconfig.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/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.61 src/sbin/cgdconfig/cgdconfig.c:1.62
--- src/sbin/cgdconfig/cgdconfig.c:1.61	Thu Nov 17 06:40:38 2022
+++ src/sbin/cgdconfig/cgdconfig.c	Mon Apr 29 00:28:18 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.61 2022/11/17 06:40:38 chs Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.62 2024/04/29 00:28:18 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.61 2022/11/17 06:40:38 chs Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.62 2024/04/29 00:28:18 riastradh Exp $");
 #endif
 
 #ifdef HAVE_ARGON2
@@ -1507,7 +1507,8 @@ iv_method(int mode)
 
 
 static void
-show(const char *dev) {
+show(const char *dev)
+{
 	char path[64];
 	struct cgd_user cgu;
 	int fd;
@@ -1532,11 +1533,13 @@ show(const char *dev) {
 	}
 
 	dev = devname(cgu.cgu_dev, S_IFBLK);
-	if (dev != NULL)
+	if (dev != NULL) {
 		printf("%s ", dev);
-	else
-		printf("dev %llu,%llu ", (unsigned long long)major(cgu.cgu_dev),
+	} else {
+		printf("dev %llu,%llu ",
+		(unsigned long long)major(cgu.cgu_dev),
 		(unsigned long long)minor(cgu.cgu_dev));
+	}
 
 	if (verbose)
 		printf("%s ", cgu.cgu_alg);



CVS commit: src/sbin/cgdconfig

2024-04-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Apr 29 00:28:18 UTC 2024

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

Log Message:
cgdconfig(8): KNF in cgdconfig.c.

No functional change intended.


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

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



CVS commit: src/sbin/ifconfig

2024-04-09 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Apr  9 08:53:08 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): allocate memory for struct lagg_req by calloc(3)
to fix build error on clang


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/lagg.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/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.7 src/sbin/ifconfig/lagg.c:1.8
--- src/sbin/ifconfig/lagg.c:1.7	Mon Apr  8 00:50:49 2024
+++ src/sbin/ifconfig/lagg.c	Tue Apr  9 08:53:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.8 2024/04/09 08:53:08 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -393,15 +393,13 @@ setlaggproto(prop_dictionary_t env, prop
 static int
 setlaggport(prop_dictionary_t env, prop_dictionary_t oenv __unused)
 {
-	struct {
-		struct lagg_req req;
-		struct laggreqport port[1];
-	} _req;
 	struct lagg_req *req;
 	struct laggreqport *rp;
 	const char *ifname;
 	enum lagg_ioctl ioc;
 	int64_t lpcmd, pri;
+	int rv;
+	size_t sz;
 
 	if (!prop_dictionary_get_string(env, "laggport", )) {
 		if (lagg_debug)
@@ -410,11 +408,15 @@ setlaggport(prop_dictionary_t env, prop_
 		return -1;
 	}
 
-	memset(&_req, 0, sizeof(_req));
-	req = (struct lagg_req *)&_req;
-	rp = >lrq_reqports[0];
-	req->lrq_nports = 1;
+	sz = sizeof(*req) + sizeof(req->lrq_reqports[0]) * 1;
+	req = calloc(1, sz);
+	if (req == NULL) {
+		errno = ENOBUFS;
+		return -1;
+	}
 
+	req->lrq_nports = 1;
+	rp = >lrq_reqports[0];
 	strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname));
 	ioc = LAGGIOC_NOCMD;
 
@@ -433,15 +435,16 @@ setlaggport(prop_dictionary_t env, prop_
 
 	if (ioc != LAGGIOC_NOCMD) {
 		req->lrq_ioctl = ioc;
-		if (indirect_ioctl(env, SIOCSLAGG, req) == -1) {
-			if (lagg_debug) {
-warn("cmd=%d", ioc);
-			}
-			return -1;
-		}
+		rv = indirect_ioctl(env, SIOCSLAGG, req);
+		if (lagg_debug && rv == -1)
+			warn("cmd=%d", ioc);
+	} else {
+		rv = 0;
 	}
 
-	return 0;
+	free(req);
+
+	return rv;
 }
 
 static int



CVS commit: src/sbin/ifconfig

2024-04-09 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Tue Apr  9 08:53:08 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): allocate memory for struct lagg_req by calloc(3)
to fix build error on clang


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr  8 20:28:34 UTC 2024

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

Log Message:
Update the date of the documentation to reflect recent changes.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/ifconfig/ifconfig.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/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.128 src/sbin/ifconfig/ifconfig.8:1.129
--- src/sbin/ifconfig/ifconfig.8:1.128	Mon Apr  8 12:32:57 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 20:28:34 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.128 2024/04/08 12:32:57 uwe Exp $
+.\"	$NetBSD: ifconfig.8,v 1.129 2024/04/08 20:28:34 andvar Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd November 25, 2022
+.Dd April 8, 2024
 .Dt IFCONFIG 8
 .Os
 .Sh NAME



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Apr  8 20:28:34 UTC 2024

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

Log Message:
Update the date of the documentation to reflect recent changes.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr  8 12:32:57 UTC 2024

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

Log Message:
ifconfig(8): move laggportpri next to laggport


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sbin/ifconfig/ifconfig.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/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.127 src/sbin/ifconfig/ifconfig.8:1.128
--- src/sbin/ifconfig/ifconfig.8:1.127	Mon Apr  8 09:25:25 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 12:32:57 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.127 2024/04/08 09:25:25 kre Exp $
+.\"	$NetBSD: ifconfig.8,v 1.128 2024/04/08 12:32:57 uwe Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -630,6 +630,13 @@ Remove the interface named by
 from the
 .Xr lagg 4
 interface.
+.It Cm laggportpri Ar interface Ar n
+If the interface is a
+.Xr lagg 4
+pseudo-interface, set the priority of
+.Ar interface
+to
+.Ar n
 .It Cm laggproto Ar proto
 Set the aggregation protocol of
 .Xr lagg 4 .
@@ -641,13 +648,6 @@ The available options are
 .Li loadbalance ,
 and
 .Li none .
-.It Cm laggportpri Ar interface Ar n
-If the interface is a
-.Xr lagg 4
-pseudo-interface, set the priority of
-.Ar interface
-to
-.Ar n
 .It Cm eee
 Enable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm -eee



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr  8 12:32:57 UTC 2024

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

Log Message:
ifconfig(8): move laggportpri next to laggport


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr  8 09:25:25 UTC 2024

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

Log Message:
Correct a very minor typo (s/id/is/)


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/ifconfig/ifconfig.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/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.126 src/sbin/ifconfig/ifconfig.8:1.127
--- src/sbin/ifconfig/ifconfig.8:1.126	Mon Apr  8 04:29:52 2024
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 09:25:25 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.126 2024/04/08 04:29:52 yamaguchi Exp $
+.\"	$NetBSD: ifconfig.8,v 1.127 2024/04/08 09:25:25 kre Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -642,7 +642,7 @@ The available options are
 and
 .Li none .
 .It Cm laggportpri Ar interface Ar n
-If the interface id a
+If the interface is a
 .Xr lagg 4
 pseudo-interface, set the priority of
 .Ar interface



CVS commit: src/sbin/ifconfig

2024-04-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr  8 09:25:25 UTC 2024

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

Log Message:
Correct a very minor typo (s/id/is/)


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/ifconfig/ifconfig.8

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



Re: CVS commit: src/sbin/ifconfig

2024-04-08 Thread Andrius V
Hi,

It's likely minor, but I believe these changes are enough to also
update the documentation date:
Index: ./src/sbin/ifconfig/ifconfig.8

-.Dd November 25, 2022
+.Dd April 8, 2024

Also "If the interface id a lagg(4) pseudo-interface" probably was
meant to be "If the interface is a lagg(4)..."  (id->is).

Thank you for the changes!

Regards,
Andrius V

On Mon, Apr 8, 2024 at 7:29 AM Shoichi YAMAGUCHI  wrote:
>
> Module Name:src
> Committed By:   yamaguchi
> Date:   Mon Apr  8 04:29:52 UTC 2024
>
> Modified Files:
> src/sbin/ifconfig: ifconfig.8
>
> Log Message:
> Added documents about parameters related to lagg(4)
>
> PR misc/58125
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>


CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 04:29:52 UTC 2024

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

Log Message:
Added documents about parameters related to lagg(4)

PR misc/58125


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.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/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.125 src/sbin/ifconfig/ifconfig.8:1.126
--- src/sbin/ifconfig/ifconfig.8:1.125	Sun Mar 26 01:04:16 2023
+++ src/sbin/ifconfig/ifconfig.8	Mon Apr  8 04:29:52 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.125 2023/03/26 01:04:16 mlelstv Exp $
+.\"	$NetBSD: ifconfig.8,v 1.126 2024/04/08 04:29:52 yamaguchi Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -614,6 +614,40 @@ Remove
 from the
 .Xr agr 4
 interface.
+.It Cm laggport Ar interface Oo Cm pri Ar n Oc
+Add the interface named by
+.Ar interface
+as a port of the
+.Xr lagg 4
+interface,
+and set the priority of
+.Ar interface
+to
+.Ar n .
+.It Cm -laggport Ar interface
+Remove the interface named by
+.Ar interface
+from the
+.Xr lagg 4
+interface.
+.It Cm laggproto Ar proto
+Set the aggregation protocol of
+.Xr lagg 4 .
+The default is
+.Li none .
+The available options are
+.Li failover ,
+.Li lacp ,
+.Li loadbalance ,
+and
+.Li none .
+.It Cm laggportpri Ar interface Ar n
+If the interface id a
+.Xr lagg 4
+pseudo-interface, set the priority of
+.Ar interface
+to
+.Ar n
 .It Cm eee
 Enable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm -eee
@@ -899,6 +933,7 @@ tried to alter an interface's configurat
 .Sh SEE ALSO
 .Xr netstat 1 ,
 .Xr agr 4 ,
+.Xr lagg 4 ,
 .Xr carp 4 ,
 .Xr ifmedia 4 ,
 .Xr netintro 4 ,



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 04:29:52 UTC 2024

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

Log Message:
Added documents about parameters related to lagg(4)

PR misc/58125


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/ifconfig/ifconfig.8

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



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 00:50:49 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): fix missing initialization of the number of array

pointed out by martin@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/ifconfig

2024-04-07 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr  8 00:50:49 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
lagg(4): fix missing initialization of the number of array

pointed out by martin@, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/lagg.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/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.6 src/sbin/ifconfig/lagg.c:1.7
--- src/sbin/ifconfig/lagg.c:1.6	Thu Apr  4 08:01:55 2024
+++ src/sbin/ifconfig/lagg.c	Mon Apr  8 00:50:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.7 2024/04/08 00:50:49 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -413,6 +413,7 @@ setlaggport(prop_dictionary_t env, prop_
 	memset(&_req, 0, sizeof(_req));
 	req = (struct lagg_req *)&_req;
 	rp = >lrq_reqports[0];
+	req->lrq_nports = 1;
 
 	strlcpy(rp->rp_portname, ifname, sizeof(rp->rp_portname));
 	ioc = LAGGIOC_NOCMD;



CVS commit: src/sbin/ifconfig

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 08:01:55 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
ifconfig: remove optional space


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/lagg.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/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.5 src/sbin/ifconfig/lagg.c:1.6
--- src/sbin/ifconfig/lagg.c:1.5	Thu Apr  4 07:55:32 2024
+++ src/sbin/ifconfig/lagg.c	Thu Apr  4 08:01:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.5 2024/04/04 07:55:32 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.6 2024/04/04 08:01:55 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -279,7 +279,7 @@ getlagg(prop_dictionary_t env)
 
 		if (errno != ENOBUFS)
 			break;
-		nports = req->lrq_nports + 3; /* 3: additional space */
+		nports = req->lrq_nports;
 	}
 
 	if (req != NULL) {



CVS commit: src/sbin/ifconfig

2024-04-04 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Apr  4 08:01:55 UTC 2024

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
ifconfig: remove optional space


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/mount

2024-04-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Apr  3 07:00:06 UTC 2024

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

Log Message:
new sentence, new line


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sbin/mount/mount.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/mount/mount.8
diff -u src/sbin/mount/mount.8:1.91 src/sbin/mount/mount.8:1.92
--- src/sbin/mount/mount.8:1.91	Wed Apr  3 03:54:53 2024
+++ src/sbin/mount/mount.8	Wed Apr  3 07:00:06 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount.8,v 1.91 2024/04/03 03:54:53 charlotte Exp $
+.\"	$NetBSD: mount.8,v 1.92 2024/04/03 07:00:06 wiz Exp $
 .\"
 .\" Copyright (c) 1980, 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -137,7 +137,8 @@ or at sign
 .Pq Ql \&@ ,
 then the
 .Li nfs
-type is inferred. Otherwise, a 
+type is inferred.
+Otherwise, a
 .Xr dk 4
 wedge may be referred to by its name with a
 .Ar special



CVS commit: src/sbin/mount

2024-04-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Apr  3 07:00:06 UTC 2024

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

Log Message:
new sentence, new line


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sbin/mount/mount.8

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



CVS commit: src/sbin/mount

2024-04-02 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Wed Apr  3 03:54:53 UTC 2024

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

Log Message:
mount(8): Mention the ability to refer to dk(4) wedges in the manpage


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sbin/mount/mount.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/mount/mount.8
diff -u src/sbin/mount/mount.8:1.90 src/sbin/mount/mount.8:1.91
--- src/sbin/mount/mount.8:1.90	Sun Jul 10 18:52:34 2022
+++ src/sbin/mount/mount.8	Wed Apr  3 03:54:53 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount.8,v 1.90 2022/07/10 18:52:34 snj Exp $
+.\"	$NetBSD: mount.8,v 1.91 2024/04/03 03:54:53 charlotte Exp $
 .\"
 .\" Copyright (c) 1980, 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)mount.8	8.8 (Berkeley) 6/16/94
 .\"
-.Dd July 10, 2022
+.Dd April 2, 2024
 .Dt MOUNT 8
 .Os
 .Sh NAME
@@ -137,7 +137,13 @@ or at sign
 .Pq Ql \&@ ,
 then the
 .Li nfs
-type is inferred.
+type is inferred. Otherwise, a 
+.Xr dk 4
+wedge may be referred to by its name with a
+.Ar special
+argument of the form
+.Dq NAME= .
+.Pp
 In
 .Nx ,
 the file system mounting policy is dictated by the running security models.



CVS commit: src/sbin/mount

2024-04-02 Thread Charlotte Koch
Module Name:src
Committed By:   charlotte
Date:   Wed Apr  3 03:54:53 UTC 2024

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

Log Message:
mount(8): Mention the ability to refer to dk(4) wedges in the manpage


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sbin/mount/mount.8

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



CVS commit: src/sbin/fsirand

2024-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 28 15:39:42 UTC 2024

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

Log Message:
fsirand(8): Fix security claims.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/fsirand/fsirand.8

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



CVS commit: src/sbin/fsirand

2024-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 28 15:39:42 UTC 2024

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

Log Message:
fsirand(8): Fix security claims.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/fsirand/fsirand.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/fsirand/fsirand.8
diff -u src/sbin/fsirand/fsirand.8:1.10 src/sbin/fsirand/fsirand.8:1.11
--- src/sbin/fsirand/fsirand.8:1.10	Sun Sep 11 21:22:18 2016
+++ src/sbin/fsirand/fsirand.8	Thu Mar 28 15:39:42 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fsirand.8,v 1.10 2016/09/11 21:22:18 sevan Exp $
+.\"	$NetBSD: fsirand.8,v 1.11 2024/03/28 15:39:42 riastradh Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -43,8 +43,17 @@
 .Nm
 writes random inode generation numbers for all the inodes on device
 .Ar special .
-These random numbers make the NFS filehandles less predictable, increasing
-security of exported filesystems.
+These random numbers make the NFS filehandles less predictable, which
+was once thought to increase security of exported file systems.
+.Pp
+.Nm
+is no longer relevant because
+.Xr newfs 8
+has randomized inode generation numbers on all new file systems since
+.Nx 2.0 ,
+and in any case, exporting a file system to NFS clients allows them to
+traverse the entire file system, so making filehandles less predictable
+does not prevent clients from finding them anyway.
 .Pp
 .Nm
 should be run on a clean and unmounted filesystem.



CVS commit: src/sbin/newfs_ext2fs

2024-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Feb 22 14:11:52 UTC 2024

Modified Files:
src/sbin/newfs_ext2fs: mke2fs.c

Log Message:
Pull a change of newfs/mkfs.c rev 1.136:

> if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/newfs_ext2fs/mke2fs.c

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



CVS commit: src/sbin/newfs_ext2fs

2024-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Feb 22 14:11:52 UTC 2024

Modified Files:
src/sbin/newfs_ext2fs: mke2fs.c

Log Message:
Pull a change of newfs/mkfs.c rev 1.136:

> if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/newfs_ext2fs/mke2fs.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/newfs_ext2fs/mke2fs.c
diff -u src/sbin/newfs_ext2fs/mke2fs.c:1.26 src/sbin/newfs_ext2fs/mke2fs.c:1.27
--- src/sbin/newfs_ext2fs/mke2fs.c:1.26	Wed May 17 09:54:59 2023
+++ src/sbin/newfs_ext2fs/mke2fs.c	Thu Feb 22 14:11:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mke2fs.c,v 1.26 2023/05/17 09:54:59 tsutsui Exp $	*/
+/*	$NetBSD: mke2fs.c,v 1.27 2024/02/22 14:11:52 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2007 Izumi Tsutsui.  All rights reserved.
@@ -100,7 +100,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mke2fs.c,v 1.26 2023/05/17 09:54:59 tsutsui Exp $");
+__RCSID("$NetBSD: mke2fs.c,v 1.27 2024/02/22 14:11:52 tsutsui Exp $");
 #endif
 #endif /* not lint */
 
@@ -594,7 +594,8 @@ mke2fs(const char *fsys, int fi, int fo)
 	fld_width = verbosity < 4 ? 1 : snprintf(NULL, 0, "%" PRIu64,
 	(uint64_t)cgbase(, ncg - 1));
 	/* Get terminal width */
-	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0)
+	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0 &&
+	winsize.ws_col != 0)
 		max_cols = winsize.ws_col;
 	else
 		max_cols = 80;



CVS commit: src/sbin/newfs

2024-02-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb 22 02:11:29 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sbin/newfs/mkfs.c

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



CVS commit: src/sbin/newfs

2024-02-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb 22 02:11:29 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sbin/newfs/mkfs.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/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.135 src/sbin/newfs/mkfs.c:1.136
--- src/sbin/newfs/mkfs.c:1.135	Wed Jul  5 10:58:58 2023
+++ src/sbin/newfs/mkfs.c	Thu Feb 22 02:11:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -672,7 +672,8 @@ mkfs(const char *fsys, int fi, int fo,
 	fld_width = verbosity < 4 ? 1 : snprintf(NULL, 0, "%" PRIu64, 
 		(uint64_t)FFS_FSBTODB(, cgsblock(, sblock.fs_ncg-1)));
 	/* Get terminal width */
-	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0)
+	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0 &&
+	winsize.ws_col != 0)
 		max_cols = winsize.ws_col;
 	else
 		max_cols = 80;



CVS commit: src/sbin/gpt

2024-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  6 20:25:11 UTC 2024

Modified Files:
src/sbin/gpt: resizedisk.c

Log Message:
check the right variable


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/resizedisk.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/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.20 src/sbin/gpt/resizedisk.c:1.21
--- src/sbin/gpt/resizedisk.c:1.20	Mon Nov 21 19:25:52 2022
+++ src/sbin/gpt/resizedisk.c	Tue Feb  6 15:25:11 2024
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.20 2022/11/22 00:25:52 mlelstv Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.21 2024/02/06 20:25:11 christos Exp $");
 #endif
 
 #include 
@@ -107,7 +107,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
 mbr = mbrmap->map_data;
 
 	gpt->gpt = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
-	if (gpt == NULL) {
+	if (gpt->gpt == NULL) {
 		gpt_warnx(gpt, "No primary GPT header; run create or recover");
 		return -1;
 	}



CVS commit: src/sbin/gpt

2024-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  6 20:25:11 UTC 2024

Modified Files:
src/sbin/gpt: resizedisk.c

Log Message:
check the right variable


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/resizedisk.c

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



CVS commit: src/sbin/mount_cd9660

2024-02-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Feb  3 15:47:44 UTC 2024

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

Log Message:
sync usage with man page


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sbin/mount_cd9660/mount_cd9660.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/mount_cd9660/mount_cd9660.c
diff -u src/sbin/mount_cd9660/mount_cd9660.c:1.34 src/sbin/mount_cd9660/mount_cd9660.c:1.35
--- src/sbin/mount_cd9660/mount_cd9660.c:1.34	Fri Feb  2 20:27:26 2024
+++ src/sbin/mount_cd9660/mount_cd9660.c	Sat Feb  3 15:47:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_cd9660.c,v 1.34 2024/02/02 20:27:26 christos Exp $	*/
+/*	$NetBSD: mount_cd9660.c,v 1.35 2024/02/03 15:47:44 wiz Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)mount_cd9660.c	8.7 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mount_cd9660.c,v 1.34 2024/02/02 20:27:26 christos Exp $");
+__RCSID("$NetBSD: mount_cd9660.c,v 1.35 2024/02/03 15:47:44 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -228,6 +228,6 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-		"usage: %s [-o options] special node\n", getprogname());
+		"usage: %s [-G gid] [-M mask] [-m mask] [-o options] [-U uid] special node\n", getprogname());
 	exit(1);
 }



CVS commit: src/sbin/mount_cd9660

2024-02-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Feb  3 15:47:44 UTC 2024

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

Log Message:
sync usage with man page


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

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



CVS commit: src/sbin/mount_cd9660

2024-02-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Feb  3 09:17:06 UTC 2024

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

Log Message:
Sort options in man page.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sbin/mount_cd9660/mount_cd9660.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/mount_cd9660/mount_cd9660.8
diff -u src/sbin/mount_cd9660/mount_cd9660.8:1.32 src/sbin/mount_cd9660/mount_cd9660.8:1.33
--- src/sbin/mount_cd9660/mount_cd9660.8:1.32	Fri Feb  2 20:27:26 2024
+++ src/sbin/mount_cd9660/mount_cd9660.8	Sat Feb  3 09:17:06 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_cd9660.8,v 1.32 2024/02/02 20:27:26 christos Exp $
+.\" $NetBSD: mount_cd9660.8,v 1.33 2024/02/03 09:17:06 wiz Exp $
 .\"
 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -66,10 +66,10 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl G Ar gid
-.Op Fl m Ar mask
 .Op Fl M Ar mask
-.Op Fl U Ar uid
+.Op Fl m Ar mask
 .Op Fl o Ar options
+.Op Fl U Ar uid
 .Ar special node
 .Sh DESCRIPTION
 The
@@ -85,15 +85,17 @@ and
 are converted to absolute paths before use.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width 10n
 .It Fl G Ar group
 Set the group of the files in the file system to
 .Ar group .
 The default gid on non-Rockridge volumes is zero.
-.It Fl U Ar user
-Set the owner of the files in the file system to
-.Ar user .
-The default uid on non-Rockridge volumes is zero.
+.It Fl M Ar mask
+Specify the maximum file permissions for directories
+in the file system.
+See the
+.Fl m
+description for details.
 .It Fl m Ar mask
 Specify the maximum file permissions for files
 in the file system.
@@ -113,10 +115,6 @@ are used.
 The default
 .Ar mask
 on non-Rockridge volumes is 755.
-.It Fl M Ar mask
-Specify the maximum file permissions for directories
-in the file system.
-See the previous option's description for details.
 .It Fl o
 Options are specified with a
 .Fl o
@@ -166,23 +164,27 @@ For compatibility with Solaris only.
 Makes all lookups case-insensitive even for CD-ROMs with Rock-Ridge
 extensions (for Rock-Ridge, default is case-sensitive lookup).
 .El
+.It Fl U Ar user
+Set the owner of the files in the file system to
+.Ar user .
+The default uid on non-Rockridge volumes is zero.
 .El
 .Pp
 For compatibility with previous releases, following obsolete flags are
 still recognized:
-.Bl -tag -width indent
+.Bl -tag -width indent -compact -offset indent
 .It Fl e
 Same as
 .Fl o
 .Cm extatt .
-.It Fl j
-Same as
-.Fl o
-.Cm nojoliet .
 .It Fl g
 Same as
 .Fl o
 .Cm gens .
+.It Fl j
+Same as
+.Fl o
+.Cm nojoliet .
 .It Fl r
 Same as
 .Fl o



CVS commit: src/sbin/mount_cd9660

2024-02-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Feb  3 09:17:06 UTC 2024

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

Log Message:
Sort options in man page.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sbin/mount_cd9660/mount_cd9660.8

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



CVS commit: src/sbin/blkdiscard

2024-01-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 25 02:42:17 UTC 2024

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

Log Message:
blkdiscard: avoid asserting when passed a bsd disklabel raw device

PR#57856 shows when using blkdiscard on eg, /dev/ld0 it asserts because
'0' is not between 'a' and 'p'.  switch this to using DISKPART() on the
returned st_rdev, so it works on 'ld0c' or 'ld0' (rawpart=2.)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/blkdiscard/blkdiscard.8 \
src/sbin/blkdiscard/blkdiscard.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/blkdiscard/blkdiscard.8
diff -u src/sbin/blkdiscard/blkdiscard.8:1.2 src/sbin/blkdiscard/blkdiscard.8:1.3
--- src/sbin/blkdiscard/blkdiscard.8:1.2	Sat Oct 15 21:53:21 2022
+++ src/sbin/blkdiscard/blkdiscard.8	Thu Jan 25 02:42:17 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: blkdiscard.8,v 1.2 2022/10/15 21:53:21 andvar Exp $
+.\"	$NetBSD: blkdiscard.8,v 1.3 2024/01/25 02:42:17 mrg Exp $
 .\"
 .\" Copyright (c) 2022 Matthew R. Green
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 6, 2022
+.Dd January 13, 2024
 .Dt BLKDISCARD 8
 .Os
 .Sh NAME
@@ -156,7 +156,7 @@ The
 .Nm
 command was written by
 .An Matthew R. Green
-.Aq m...@eterna.com.au .
+.Aq m...@eterna23.net .
 .Sh BUGS
 The secure erase functionality of the
 .Fl s
Index: src/sbin/blkdiscard/blkdiscard.c
diff -u src/sbin/blkdiscard/blkdiscard.c:1.2 src/sbin/blkdiscard/blkdiscard.c:1.3
--- src/sbin/blkdiscard/blkdiscard.c:1.2	Thu Jan 25 02:06:56 2024
+++ src/sbin/blkdiscard/blkdiscard.c	Thu Jan 25 02:42:17 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: blkdiscard.c,v 1.2 2024/01/25 02:06:56 mrg Exp $	*/
+/*	$NetBSD: blkdiscard.c,v 1.3 2024/01/25 02:42:17 mrg Exp $	*/
 
 /*
- * Copyright (c) 2019, 2020, 2022 Matthew R. Green
+ * Copyright (c) 2019, 2020, 2022, 2024 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 static bool secure = false;
@@ -53,7 +52,7 @@ static bool zeroout = false;
 static char *zeros = NULL;
 static unsigned ttywidth = 80;
 
-#define FDISCARD_VERSION	20220206u
+#define FDISCARD_VERSION	20240113u
 
 static void __dead
 usage(const char* msg)
@@ -105,6 +104,7 @@ main(int argc, char *argv[])
 	int64_t val;
 	int i;
 	bool verbose = false;
+	struct stat sb;
 
 	/* Default /sbin/blkdiscard to be "run" */
 	bool norun = strcmp(getprogname(), "blkdiscard") != 0;
@@ -176,6 +176,7 @@ main(int argc, char *argv[])
 
 	if (size == 0) {
 		struct dkwedge_info dkw;
+
 		if (ioctl(fd, DIOCGWEDGEINFO, ) == 0) {
 			size = dkw.dkw_size * DEV_BSIZE;
 			if (verbose)
@@ -184,24 +185,20 @@ main(int argc, char *argv[])
 		}
 	}
 
-	if (size == 0) {
+	if (size == 0 && fstat(fd, ) != -1) {
 		struct disklabel dl;
+
 		if (ioctl(fd, DIOCGDINFO, ) != -1) {
-			char partchar = name[strlen(name)-1];
-			assert(partchar >= 'a' && partchar <= 'p');
-			int part = partchar - 'a';
+			unsigned part = DISKPART(sb.st_rdev);
 
 			size = (uint64_t)dl.d_partitions[part].p_size *
 			dl.d_secsize;
 			if (verbose)
-printf("%s: disklabel size is %lld\n", name,
-(long long)size);
+printf("%s: partition %u disklabel size is"
+   " %lld\n", name, part, (long long)size);
 		}
-	}
 
-	if (size == 0) {
-		struct stat sb;
-		if (fstat(fd, ) != -1) {
+		if (size == 0) {
 			size = sb.st_size;
 			if (verbose)
 printf("%s: stat size is %lld\n", name,



CVS commit: src/sbin/blkdiscard

2024-01-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 25 02:42:17 UTC 2024

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

Log Message:
blkdiscard: avoid asserting when passed a bsd disklabel raw device

PR#57856 shows when using blkdiscard on eg, /dev/ld0 it asserts because
'0' is not between 'a' and 'p'.  switch this to using DISKPART() on the
returned st_rdev, so it works on 'ld0c' or 'ld0' (rawpart=2.)


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

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



CVS commit: src/sbin/blkdiscard

2024-01-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 25 02:06:56 UTC 2024

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

Log Message:
determine the tty width instead off writing 100 chars before a new line.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/blkdiscard/blkdiscard.c

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



CVS commit: src/sbin/blkdiscard

2024-01-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 25 02:06:56 UTC 2024

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

Log Message:
determine the tty width instead off writing 100 chars before a new line.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/blkdiscard/blkdiscard.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/blkdiscard/blkdiscard.c
diff -u src/sbin/blkdiscard/blkdiscard.c:1.1 src/sbin/blkdiscard/blkdiscard.c:1.2
--- src/sbin/blkdiscard/blkdiscard.c:1.1	Mon Feb  7 09:33:26 2022
+++ src/sbin/blkdiscard/blkdiscard.c	Thu Jan 25 02:06:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: blkdiscard.c,v 1.1 2022/02/07 09:33:26 mrg Exp $	*/
+/*	$NetBSD: blkdiscard.c,v 1.2 2024/01/25 02:06:56 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019, 2020, 2022 Matthew R. Green
@@ -51,6 +51,7 @@
 static bool secure = false;
 static bool zeroout = false;
 static char *zeros = NULL;
+static unsigned ttywidth = 80;
 
 #define FDISCARD_VERSION	20220206u
 
@@ -224,7 +225,9 @@ main(int argc, char *argv[])
 		size = end_offset;
 	}
 
-	if (verbose)
+	if (verbose) {
+		struct winsize winsize;
+
 		printf("%sgoing to %s on %s from byte %lld for "
 		   "%lld bytes, %lld at a time\n",
 		   norun ? "not " : "",
@@ -233,7 +236,12 @@ main(int argc, char *argv[])
 		   name, (long long)first_byte, (long long)size,
 		   (long long)max_per_call);
 
-	int loop = 0;
+		if (ioctl(fileno(stdout), TIOCGWINSZ, ) != -1 &&
+		winsize.ws_col > 1)
+			ttywidth = winsize.ws_col - 1;
+	}
+
+	unsigned loop = 0;
 	while (size > 0) {
 		if (size > max_per_call)
 			discard_size = max_per_call;
@@ -248,7 +256,7 @@ main(int argc, char *argv[])
 		if (verbose) {
 			printf(".");
 			fflush(stdout);
-			if (loop++ > 100) {
+			if (++loop >= ttywidth) {
 loop = 0;
 printf("\n");
 			}



CVS commit: src/sbin/iscsid

2023-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Dec 27 18:07:30 UTC 2023

Modified Files:
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Treat port 0 (unset) as ISCSI_DEFAULT_PORT like before.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/iscsid/iscsid_driverif.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/iscsid/iscsid_driverif.c
diff -u src/sbin/iscsid/iscsid_driverif.c:1.9 src/sbin/iscsid/iscsid_driverif.c:1.10
--- src/sbin/iscsid/iscsid_driverif.c:1.9	Sat Nov 25 08:06:02 2023
+++ src/sbin/iscsid/iscsid_driverif.c	Wed Dec 27 18:07:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsid_driverif.c,v 1.9 2023/11/25 08:06:02 mlelstv Exp $	*/
+/*	$NetBSD: iscsid_driverif.c,v 1.10 2023/12/27 18:07:30 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -285,7 +285,8 @@ make_connection(session_t * sess, iscsid
 	memset(, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
-	snprintf(portnum, sizeof(portnum), "%u", addr->port);
+	snprintf(portnum, sizeof(portnum), "%u", addr->port
+	? addr->port : ISCSI_DEFAULT_PORT);
 	ret = getaddrinfo((char *)addr->address, portnum, , );
 	switch (ret) {
 	case 0:
@@ -553,7 +554,8 @@ event_recover_connection(uint32_t sid, u
 	memset(, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
-	snprintf(portnum, sizeof(portnum), "%u", addr->port);
+	snprintf(portnum, sizeof(portnum), "%u", addr->port
+	? addr->port : ISCSI_DEFAULT_PORT);
 	ret = getaddrinfo((char *)addr->address, portnum, , );
 	if (ret) {
 		DEB(1, ("getaddrinfo failed (%s)", gai_strerror(ret)));



CVS commit: src/sbin/iscsid

2023-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Dec 27 18:07:30 UTC 2023

Modified Files:
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Treat port 0 (unset) as ISCSI_DEFAULT_PORT like before.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/iscsid/iscsid_driverif.c

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



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

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

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.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/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.86 src/sbin/gpt/gpt.c:1.87
--- src/sbin/gpt/gpt.c:1.86	Mon Dec 11 12:45:22 2023
+++ src/sbin/gpt/gpt.c	Wed Dec 13 06:51:57 2023
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.86 2023/12/11 12:45:22 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.87 2023/12/13 06:51:57 mrg Exp $");
 #endif
 
 #include 
@@ -604,9 +604,8 @@ gpt_open(const char *dev, int flags, int
  close:
 	if (gpt->fd != -1)
 		close(gpt->fd);
+	gpt_warn(gpt, "No GPT found");
 	free(gpt);
-	if (!(flags & GPT_QUIET))
-		gpt_warn(gpt, "No GPT found");
 	return NULL;
 }
 



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

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

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.c

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



CVS commit: src/sbin/swapctl

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:47:24 UTC 2023

Modified Files:
src/sbin/swapctl: swaplist.c

Log Message:
Avoid overflow of totals.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/swapctl/swaplist.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/swapctl/swaplist.c
diff -u src/sbin/swapctl/swaplist.c:1.18 src/sbin/swapctl/swaplist.c:1.19
--- src/sbin/swapctl/swaplist.c:1.18	Tue May 31 09:34:25 2016
+++ src/sbin/swapctl/swaplist.c	Mon Dec 11 12:47:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: swaplist.c,v 1.18 2016/05/31 09:34:25 pgoyette Exp $	*/
+/*	$NetBSD: swaplist.c,v 1.19 2023/12/11 12:47:24 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1997 Matthew R. Green
@@ -28,7 +28,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: swaplist.c,v 1.18 2016/05/31 09:34:25 pgoyette Exp $");
+__RCSID("$NetBSD: swaplist.c,v 1.19 2023/12/11 12:47:24 mlelstv Exp $");
 #endif
 
 
@@ -61,8 +61,9 @@ list_swap(int pri, int kflag, int pflag,
 	char	szbuf[5], usbuf[5], avbuf[5]; /* size, used, avail */
 	const	char *header, *suff;
 	size_t	l;
-	int	hlen, totalsize, size, totalinuse, inuse, ncounted, pathmax;
+	int	hlen, size, inuse, ncounted, pathmax;
 	int	rnswap, nswap = swapctl(SWAP_NSWAP, 0, 0), i;
+	int64_t	totalsize, totalinuse;
 
 	if (nswap < 1) {
 		puts("no swap devices configured");



CVS commit: src/sbin/swapctl

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:47:24 UTC 2023

Modified Files:
src/sbin/swapctl: swaplist.c

Log Message:
Avoid overflow of totals.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/swapctl/swaplist.c

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



CVS commit: src/sbin/gpt

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:45:22 UTC 2023

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

Log Message:
Be verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sbin/gpt/gpt.c

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



CVS commit: src/sbin/gpt

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:45:22 UTC 2023

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

Log Message:
Be verbose about errors.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sbin/gpt/gpt.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/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.85 src/sbin/gpt/gpt.c:1.86
--- src/sbin/gpt/gpt.c:1.85	Tue Sep 26 15:55:46 2023
+++ src/sbin/gpt/gpt.c	Mon Dec 11 12:45:22 2023
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.85 2023/09/26 15:55:46 kre Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.86 2023/12/11 12:45:22 mlelstv Exp $");
 #endif
 
 #include 
@@ -386,8 +386,10 @@ gpt_gpt(gpt_t gpt, off_t lba, int found)
 	uint32_t crc;
 
 	hdr = gpt_read(gpt, lba, 1);
-	if (hdr == NULL)
+	if (hdr == NULL) {
+		gpt_warn(gpt, "Read failed");
 		return -1;
+	}
 
 	if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)))
 		goto fail_hdr;
@@ -540,6 +542,7 @@ gpt_open(const char *dev, int flags, int
 			gpt->secsz = 512;	/* Fixed size for files. */
 		if (gpt->mediasz == 0) {
 			if (gpt->sb.st_size % gpt->secsz) {
+gpt_warn(gpt, "Media size not a multiple of sector size (%u)\n", gpt->secsz);
 errno = EINVAL;
 goto close;
 			}
@@ -602,6 +605,8 @@ gpt_open(const char *dev, int flags, int
 	if (gpt->fd != -1)
 		close(gpt->fd);
 	free(gpt);
+	if (!(flags & GPT_QUIET))
+		gpt_warn(gpt, "No GPT found");
 	return NULL;
 }
 



CVS commit: src/sbin/ifconfig

2023-12-05 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Dec  6 05:57:39 UTC 2023

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/lagg.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/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.3 src/sbin/ifconfig/lagg.c:1.4
--- src/sbin/ifconfig/lagg.c:1.3	Thu Mar 31 01:53:22 2022
+++ src/sbin/ifconfig/lagg.c	Wed Dec  6 05:57:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.4 2023/12/06 05:57:39 yamaguchi Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -132,27 +132,35 @@ struct piface	 laggportpri_if = PIFACE_I
 
 static const struct kwinst	 lagglacpkw[] = {
 	  {.k_word = "dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "maxports", .k_nextparser = _parser}
 	, {.k_word = "-maxports", .k_key = "lacpmaxports",
-	   .k_type = KW_T_INT, .k_int = 0}
+	   .k_type = KW_T_INT, .k_int = 0, .k_exec = setlagglacpmaxports}
 	, {.k_word = "multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 };
 struct pkw	 lagglacp = PKW_INITIALIZER(, "lagg-lacp-option",
-		setlagglacp, NULL, lagglacpkw, __arraycount(lagglacpkw),
+		NULL, NULL, lagglacpkw, __arraycount(lagglacpkw),
 		_root.pb_parser);
 
 static const struct kwinst	 laggfailkw[] = {



CVS commit: src/sbin/ifconfig

2023-12-05 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Wed Dec  6 05:57:39 UTC 2023

Modified Files:
src/sbin/ifconfig: lagg.c

Log Message:
Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/lagg.c

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



CVS commit: src/sbin/gpt

2023-12-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Dec  5 17:23:20 UTC 2023

Modified Files:
src/sbin/gpt: map.c

Log Message:
Fix an incorrect comment.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/map.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/gpt/map.c
diff -u src/sbin/gpt/map.c:1.15 src/sbin/gpt/map.c:1.16
--- src/sbin/gpt/map.c:1.15	Sun May 24 14:42:44 2020
+++ src/sbin/gpt/map.c	Tue Dec  5 17:23:19 2023
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: map.c,v 1.15 2020/05/24 14:42:44 jmcneill Exp $");
+__RCSID("$NetBSD: map.c,v 1.16 2023/12/05 17:23:19 tsutsui Exp $");
 #endif
 
 #include 
@@ -257,7 +257,7 @@ map_resize(gpt_t gpt, map_t m, off_t siz
 		gpt_warnx(gpt, "negative size or alignment");
 		return -1;
 	}
-	/* Size == 0 means delete, if the next map is unused */
+	/* Size == 0 means to use whole region of the following unused map */
 	if (size == 0) { 
 		if (n == NULL) {
 			// XXX: we could just turn the map to UNUSED!



CVS commit: src/sbin/gpt

2023-12-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Dec  5 17:23:20 UTC 2023

Modified Files:
src/sbin/gpt: map.c

Log Message:
Fix an incorrect comment.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/map.c

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



CVS commit: src/sbin

2023-11-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 25 08:06:02 UTC 2023

Modified Files:
src/sbin/iscsictl: iscsic_parse.c
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Parse IPv6 targets and handle IPv6 addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/iscsictl/iscsic_parse.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/iscsid/iscsid_driverif.c

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



CVS commit: src/sbin

2023-11-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 25 08:06:02 UTC 2023

Modified Files:
src/sbin/iscsictl: iscsic_parse.c
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Parse IPv6 targets and handle IPv6 addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/iscsictl/iscsic_parse.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/iscsid/iscsid_driverif.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/iscsictl/iscsic_parse.c
diff -u src/sbin/iscsictl/iscsic_parse.c:1.4 src/sbin/iscsictl/iscsic_parse.c:1.5
--- src/sbin/iscsictl/iscsic_parse.c:1.4	Fri Dec  3 13:27:38 2021
+++ src/sbin/iscsictl/iscsic_parse.c	Sat Nov 25 08:06:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsic_parse.c,v 1.4 2021/12/03 13:27:38 andvar Exp $	*/
+/*	$NetBSD: iscsic_parse.c,v 1.5 2023/11/25 08:06:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -48,50 +48,62 @@
 STATIC void
 get_address(iscsi_portal_address_t * portal, char *str, char *arg)
 {
-	char *sp, *sp2;
+	char *sp;
 	int val;
 
 	if (!str || !*str)
 		arg_error(arg, "Address is missing");
 
-	/* is there a port? don't check inside square brackets (IPv6 addr) */
-	for (sp = str + 1, val = 0; *sp && (*sp != ':' || val); sp++) {
-		if (*sp == '[')
-			val = 1;
-		else if (*sp == ']')
-			val = 0;
-	}
-
-	/* */
-	if (*sp) {
-		for (sp2 = sp + 1; *sp2 && *sp2 != ':'; sp2++);
-		/* if there's a second colon, assume it's an unbracketed IPv6 address */
-		if (!*sp2) {
-			/* truncate source, that's the address */
-			*sp++ = '\0';
-			if (sscanf(sp, "%d", ) != 1)
-arg_error(arg, "Bad address format: Expected port number");
-			if (val < 0 || val > 0x)
-arg_error(arg, "Bad address format: Port number out of range");
-			portal->port = (uint16_t) val;
-		}
-		/* is there a group tag? */
-		for (; isdigit((unsigned char)*sp); sp++);
-		if (*sp && *sp != ',')
-			arg_error(arg, "Bad address format: Extra character(s) '%c'", *sp);
-	} else
-		for (sp = str + 1; *sp && *sp != ','; sp++);
-
-	if (*sp) {
+	/* Parse and strip trailing group tag */
+	sp = strrchr(str, ',');
+	if (sp != NULL) {
 		if (sscanf(sp + 1, "%d", ) != 1)
 			arg_error(arg, "Bad address format: Expected group tag");
 		if (val < 0 || val > 0x)
 			arg_error(arg, "Bad address format: Group tag out of range");
 		portal->group_tag = (uint16_t) val;
-		/* truncate source, that's the address */
 		*sp = '\0';
 	}
-	/* only check length, don't verify correct format (too many possibilities) */
+
+	/* Skip over bracketed IPv6 address */
+	sp = strchr(str, ']');
+	if (sp != NULL)
+		sp++;
+	else
+		sp = str;
+
+	/* Parse and strip trailing port number */
+	sp = strchr(sp, ':');
+	if (sp != NULL) {
+		if (strchr(sp + 1, ':') != NULL) {
+			/*
+			 *  If there's a second colon, assume
+			 *  it's an unbracketed IPv6 address
+			 */
+			portal->port = 0;
+		} else {
+			if (sscanf(sp + 1, "%d", ) != 1)
+arg_error(arg, "Bad address format: Expected port number");
+			if (val < 0 || val > 0x)
+arg_error(arg, "Bad address format: Port number ut  of range");
+			portal->port = (uint16_t) val;
+			*sp = '\0';
+		}
+	}
+
+	/* Remove brackets */
+	if (*str == '[') {
+		sp = strchr(str, ']');
+		if (sp != NULL && !*(sp+1)) {
+			str = str + 1;
+			*sp = '\0';
+		}
+	}
+
+	/*
+	 * only check length, don't verify correct format
+	 * (too many possibilities)
+	 */
 	if (strlen(str) >= sizeof(portal->address))
 		arg_error(arg, "Bad address format: Address string too long");
 

Index: src/sbin/iscsid/iscsid_driverif.c
diff -u src/sbin/iscsid/iscsid_driverif.c:1.8 src/sbin/iscsid/iscsid_driverif.c:1.9
--- src/sbin/iscsid/iscsid_driverif.c:1.8	Sun May 29 13:35:45 2016
+++ src/sbin/iscsid/iscsid_driverif.c	Sat Nov 25 08:06:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsid_driverif.c,v 1.8 2016/05/29 13:35:45 mlelstv Exp $	*/
+/*	$NetBSD: iscsid_driverif.c,v 1.9 2023/11/25 08:06:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -98,23 +98,29 @@ set_node_name(iscsid_set_node_name_req_t
 static int
 bind_socket(int sock, uint8_t * addr)
 {
-	struct sockaddr_in serverAddress;
-	struct hostent *host;
+	struct addrinfo hints, *ai, *ai0;
+	int ret = FALSE;
 
 	DEB(8, ("Binding to <%s>", addr));
-	(void) memset(, 0x0, sizeof(serverAddress));
-	host = gethostbyname((char *)addr);
-	if (host == NULL)
-		return FALSE;
-	if (host->h_length > (int)sizeof(serverAddress.sin_addr))
-		return FALSE;
-	serverAddress.sin_family = host->h_addrtype;
-	serverAddress.sin_port = 0;
-	serverAddress.sin_len = host->h_length;
-	memcpy(_addr, host->h_addr_list[0], host->h_length);
+	
+	memset(, 0, sizeof(hints));
+	hints.ai_family = AF_UNSPEC;
+	hints.ai_socktype = SOCK_STREAM;
+	hints.ai_flags = AI_PASSIVE;
+	if (getaddrinfo((char *)addr, NULL, , ))
+		return ret;
+
+	for (ai = ai0; ai; ai = ai->ai_next) {
+		if (bind(sock, 

CVS commit: src/sbin/gpt

2023-11-06 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Nov  7 00:53:39 UTC 2023

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

Log Message:
gpt.8: fix grammar in a sentence


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.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/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.79 src/sbin/gpt/gpt.8:1.80
--- src/sbin/gpt/gpt.8:1.79	Tue Oct 31 12:09:48 2023
+++ src/sbin/gpt/gpt.8	Tue Nov  7 00:53:39 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.79 2023/10/31 12:09:48 martin Exp $
+.\" $NetBSD: gpt.8,v 1.80 2023/11/07 00:53:39 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -659,7 +659,7 @@ option, all information for all GPT part
 .Fl i Ar index )
 will be printed.
 None of the options have any effect on non-GPT partitions.
-The order of precedence for the options are:
+The order of precedence for the options is:
 .Fl a ,
 .Fl i ,
 .Fl l ,



CVS commit: src/sbin/gpt

2023-11-06 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Nov  7 00:53:39 UTC 2023

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

Log Message:
gpt.8: fix grammar in a sentence


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

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



CVS commit: src/sbin/gpt

2023-10-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 31 12:09:48 UTC 2023

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

Log Message:
Apply patch from Thierry Laronde: add missing suffixes for size values
and clarify that they are case independant.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/gpt/gpt.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/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.78 src/sbin/gpt/gpt.8:1.79
--- src/sbin/gpt/gpt.8:1.78	Sat Jul 15 21:18:06 2023
+++ src/sbin/gpt/gpt.8	Tue Oct 31 12:09:48 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.78 2023/07/15 21:18:06 gutteridge Exp $
+.\" $NetBSD: gpt.8,v 1.79 2023/10/31 12:09:48 martin Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -160,7 +160,7 @@ or
 .Sq S
 then size is in sectors, otherwise size is in bytes which must be
 a multiple of the device's sector size.
-Accepted suffix units are
+Accepted suffix units (case insensitive) are
 .Sq b
 to denote bytes,
 .Sq k
@@ -168,7 +168,13 @@ to denote kilobytes,
 .Sq m
 to denote megabytes and
 .Sq g
-to denote gigabytes.
+to denote gigabytes,
+.Sq t
+to denote terabytes,
+.Sq p
+to denote petabytes, and
+.Sq e
+to denote exabytes.
 The minimum size is 1 sector.
 .Pp
 The



CVS commit: src/sbin/gpt

2023-10-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 31 12:09:48 UTC 2023

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

Log Message:
Apply patch from Thierry Laronde: add missing suffixes for size values
and clarify that they are case independant.


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

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



Re: CVS commit: src/sbin/gpt

2023-09-27 Thread Robert Elz
Date:Wed, 27 Sep 2023 09:44:10 +
From:"Taylor R Campbell" 
Message-ID:  <20230927094410.b9257f...@cvs.netbsd.org>

  | gpt(8): Make gpt type array and enum match again.

Thanks, and apologies for not checking that better - I did test
that it recognised the new one properly...

kre




CVS commit: src/sbin/gpt

2023-09-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 27 09:44:10 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c gpt_uuid.h

Log Message:
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal   2023-09-26 15:48:30.0 
+
+++ /tmp/check.sc6ylB/stdout2023-09-26 23:30:42.388157924 
+
@@ -3,6 +3,6 @@
   1  1 Pri GPT header
   2 32 Pri GPT table
  34   1024  1  GPT part - EFI System
-   1058   9150  2  GPT part - NetBSD FFSv1/FFSv2
+   1058   9150  2  GPT part - NetBSD Cryptographic Disk
   10208 32 Sec GPT table
   10240  1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/gpt_uuid.h

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



CVS commit: src/sbin/gpt

2023-09-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 27 09:44:10 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c gpt_uuid.h

Log Message:
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal   2023-09-26 15:48:30.0 
+
+++ /tmp/check.sc6ylB/stdout2023-09-26 23:30:42.388157924 
+
@@ -3,6 +3,6 @@
   1  1 Pri GPT header
   2 32 Pri GPT table
  34   1024  1  GPT part - EFI System
-   1058   9150  2  GPT part - NetBSD FFSv1/FFSv2
+   1058   9150  2  GPT part - NetBSD Cryptographic Disk
   10208 32 Sec GPT table
   10240  1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/gpt_uuid.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/gpt/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.20 src/sbin/gpt/gpt_uuid.c:1.21
--- src/sbin/gpt/gpt_uuid.c:1.20	Tue Sep 26 15:48:30 2023
+++ src/sbin/gpt/gpt_uuid.c	Wed Sep 27 09:44:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $	*/
+/*	$NetBSD: gpt_uuid.c,v 1.21 2023/09/27 09:44:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.21 2023/09/27 09:44:10 riastradh Exp $");
 #endif
 
 #include 
@@ -65,6 +65,7 @@ static const struct {
 	const char *n;
 	const char *d;
 } gpt_nv[] = {
+	/* Must match the gpt_type_t enum in gpt_uuid.h */
 	{ GPT_ENT_TYPE_APPLE_HFS, "apple", "Apple HFS" },
 	{ GPT_ENT_TYPE_APPLE_UFS, "apple-ufs", "Apple UFS" },
 	{ GPT_ENT_TYPE_BIOS, "bios", "BIOS Boot" },

Index: src/sbin/gpt/gpt_uuid.h
diff -u src/sbin/gpt/gpt_uuid.h:1.9 src/sbin/gpt/gpt_uuid.h:1.10
--- src/sbin/gpt/gpt_uuid.h:1.9	Sun Jun 30 11:38:16 2019
+++ src/sbin/gpt/gpt_uuid.h	Wed Sep 27 09:44:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.h,v 1.9 2019/06/30 11:38:16 sevan Exp $	*/
+/*	$NetBSD: gpt_uuid.h,v 1.10 2023/09/27 09:44:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  * support anyway
  */
 
-// Must match the array in gpt_uuid.c
+/* Must match the gpt_nv array in gpt_uuid.c */
 typedef enum {
 	GPT_TYPE_INVALID = -1,
 	GPT_TYPE_APPLE_HFS = 0,
@@ -64,6 +64,7 @@ typedef enum {
 	GPT_TYPE_LINUX_LVM,
 	GPT_TYPE_MS_BASIC_DATA,
 	GPT_TYPE_MS_RESERVED,
+	GPT_TYPE_MS_RECOVERY,
 	GPT_TYPE_NETBSD_CCD,
 	GPT_TYPE_NETBSD_CGD,
 	GPT_TYPE_NETBSD_FFS,



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:55:46 UTC 2023

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

Log Message:
When extracting the attributes (to printable form), avoid simply ignoring
any attribute bits which are unknown, print them as a hex value.  This
avoids "Attributes: " for most windows filesystem types, which all seem
to have but 63 set (which is supposed to mean "don't assign a drive letter"
which is akin to "noauto" in fstab - except it is set even on partitions
which do get mounted, so must mean something subtly different).

These upper 16 attribute bits are supposed to be file system type speficic
(in practice, they seem to be common to all filesystem types from one vendor)
but we don't have the info (yet anyway) to treat them like that.

ChromeOS seems to treat some of the bits as bit fields containing numeric
values - add #if 0'd (but compile tested) code to deal with those (maybe,
compile tested - but not execution tested) should someone ever get an
environment where these things occur, and could add the missing definitions
to actually test this.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.c

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



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:55:46 UTC 2023

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

Log Message:
When extracting the attributes (to printable form), avoid simply ignoring
any attribute bits which are unknown, print them as a hex value.  This
avoids "Attributes: " for most windows filesystem types, which all seem
to have but 63 set (which is supposed to mean "don't assign a drive letter"
which is akin to "noauto" in fstab - except it is set even on partitions
which do get mounted, so must mean something subtly different).

These upper 16 attribute bits are supposed to be file system type speficic
(in practice, they seem to be common to all filesystem types from one vendor)
but we don't have the info (yet anyway) to treat them like that.

ChromeOS seems to treat some of the bits as bit fields containing numeric
values - add #if 0'd (but compile tested) code to deal with those (maybe,
compile tested - but not execution tested) should someone ever get an
environment where these things occur, and could add the missing definitions
to actually test this.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sbin/gpt/gpt.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/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.84 src/sbin/gpt/gpt.c:1.85
--- src/sbin/gpt/gpt.c:1.84	Tue Nov 22 00:25:52 2022
+++ src/sbin/gpt/gpt.c	Tue Sep 26 15:55:46 2023
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.84 2022/11/22 00:25:52 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.85 2023/09/26 15:55:46 kre Exp $");
 #endif
 
 #include 
@@ -1239,13 +1239,62 @@ const char *
 gpt_attr_list(char *buf, size_t len, uint64_t attributes)
 {
 	size_t i;
+	/*
+	 * a uint64_t (attributes) has at most 16 hex digits
+	 * in its representation, add 2 for "0x", and 2 more
+	 * for surrounding [ ], plus one for a trailing \0,
+	 * and we need 21 bytes, round that up to 24
+	 */
+	char xbuf[24];
+
 	strlcpy(buf, "", len);	
 
-	for (i = 0; i < __arraycount(gpt_attr); i++)
+	for (i = 0; i < __arraycount(gpt_attr); i++) {
+		/*
+		 * if the attribute is specified in one of bits
+		 * 48..63, it should depend upon the defining
+		 * partition type for that attribute.   Currently
+		 * we have no idea what that is, so...
+		 *
+		 * Also note that for some partition types, these
+		 * fields are not a single bit boolean, but several
+		 * bits to form a numeric value.  That we could handle.
+		 */
+
 		if (attributes & gpt_attr[i].mask) {
 			strlcat(buf, buf[0] ? ", " : "", len); 
 			strlcat(buf, gpt_attr[i].name, len);
+#if 0
+	/*
+	 * there are none currently defined, so this is untestable
+	 * (it does build however).
+	 */
+			if (gpt_attr[i].mask & (gpt_attr[i].mask - 1)) {
+/* This only happens in bits 46..63 */
+
+/*
+ * xbuf is big enough for "=65535\0"
+ * which is the biggest possible value
+ */
+snprintf(xbuf, sizeof xbuf, "=%ju",
+(uintmax_t) (
+  (attributes & gpt_attr[i].mask) >>
+  (ffs((int)(gpt_attr[i].mask >> 48)) + 47)
+));
+
+strlcat(buf, xbuf, len);
+			}
+#endif
+			attributes &=~ gpt_attr[i].mask;
 		}
+	}
+
+	if (attributes != 0) {
+		snprintf(xbuf, sizeof xbuf, "[%#jx]", (uintmax_t)attributes);
+		strlcat(buf, buf[0] ? ", " : "", len);
+		strlcat(buf, xbuf, len);
+	}
+
 	return buf;
 }
 



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:48:31 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
Recognise Windows Recovery partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.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/gpt/gpt_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.19 src/sbin/gpt/gpt_uuid.c:1.20
--- src/sbin/gpt/gpt_uuid.c:1.19	Mon Mar 30 10:41:53 2020
+++ src/sbin/gpt/gpt_uuid.c	Tue Sep 26 15:48:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $	*/
+/*	$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt_uuid.c,v 1.19 2020/03/30 10:41:53 martin Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.20 2023/09/26 15:48:30 kre Exp $");
 #endif
 
 #include 
@@ -80,6 +80,7 @@ static const struct {
 	{ GPT_ENT_TYPE_LINUX_LVM, "linux-lvm", "Linux LVM" },
 	{ GPT_ENT_TYPE_MS_BASIC_DATA, "windows", "Windows basic data" },
 	{ GPT_ENT_TYPE_MS_RESERVED, "windows-reserved", "Windows reserved" },
+	{ GPT_ENT_TYPE_MS_RECOVERY, "windows-recovery", "Windows recovery" },
 	{ GPT_ENT_TYPE_NETBSD_CCD, "ccd", "NetBSD ccd component" },
 	{ GPT_ENT_TYPE_NETBSD_CGD, "cgd", "NetBSD Cryptographic Disk" },
 	{ GPT_ENT_TYPE_NETBSD_FFS, "ffs", "NetBSD FFSv1/FFSv2" },



CVS commit: src/sbin/gpt

2023-09-26 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep 26 15:48:31 UTC 2023

Modified Files:
src/sbin/gpt: gpt_uuid.c

Log Message:
Recognise Windows Recovery partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/gpt_uuid.c

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



CVS commit: src/sbin/fsck_msdos

2023-09-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Sep 24 20:41:52 UTC 2023

Modified Files:
src/sbin/fsck_msdos: ext.h

Log Message:
ext.h: fix spelling and grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/fsck_msdos/ext.h

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



CVS commit: src/sbin/fsck_msdos

2023-09-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Sep 24 20:41:52 UTC 2023

Modified Files:
src/sbin/fsck_msdos: ext.h

Log Message:
ext.h: fix spelling and grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/fsck_msdos/ext.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/fsck_msdos/ext.h
diff -u src/sbin/fsck_msdos/ext.h:1.13 src/sbin/fsck_msdos/ext.h:1.14
--- src/sbin/fsck_msdos/ext.h:1.13	Sat Apr 11 07:14:50 2009
+++ src/sbin/fsck_msdos/ext.h	Sun Sep 24 20:41:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext.h,v 1.13 2009/04/11 07:14:50 lukem Exp $	*/
+/*	$NetBSD: ext.h,v 1.14 2023/09/24 20:41:52 gutteridge Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -69,7 +69,7 @@ int checkfilesys(const char *);
 #define FSFIXFAT	64		/* Fix file system FAT */
 
 /*
- * read a boot block in a machine independend fashion and translate
+ * Read a boot block in a machine independent fashion and translate
  * it into our struct bootblock.
  */
 int readboot(int, struct bootblock *);



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/resize_lfs

2023-08-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug  7 23:27:07 UTC 2023

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

Log Message:
fix potentially uninitialised data being used.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/resize_lfs/resize_lfs.c

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



CVS commit: src/sbin/resize_lfs

2023-08-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug  7 23:27:07 UTC 2023

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

Log Message:
fix potentially uninitialised data being used.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/resize_lfs/resize_lfs.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/resize_lfs/resize_lfs.c
diff -u src/sbin/resize_lfs/resize_lfs.c:1.15 src/sbin/resize_lfs/resize_lfs.c:1.16
--- src/sbin/resize_lfs/resize_lfs.c:1.15	Thu Aug 22 20:26:07 2019
+++ src/sbin/resize_lfs/resize_lfs.c	Mon Aug  7 23:27:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize_lfs.c,v 1.15 2019/08/22 20:26:07 brad Exp $	*/
+/*	$NetBSD: resize_lfs.c,v 1.16 2023/08/07 23:27:07 mrg Exp $	*/
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -124,7 +124,7 @@ main(int argc, char **argv)
 		err(1, "open filesystem root");
 
 	/* Read the superblock, finding alternates if necessary */
-	fs = (struct lfs *)malloc(sizeof(*fs));
+	fs = (struct lfs *)calloc(sizeof(*fs), 1);
 	for (sboff = LFS_LABELPAD;;) {
 		pread(devfd, buf, sboff, LFS_SBPAD);
 		__CTASSERT(sizeof(struct dlfs) == sizeof(struct dlfs64));



CVS commit: src/sbin/dump

2023-08-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug  7 23:26:40 UTC 2023

Modified Files:
src/sbin/dump: traverse.c

Log Message:
fix always true conditional by removing the address-of operator.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sbin/dump/traverse.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/dump/traverse.c
diff -u src/sbin/dump/traverse.c:1.55 src/sbin/dump/traverse.c:1.56
--- src/sbin/dump/traverse.c:1.55	Wed Jan 26 20:22:14 2022
+++ src/sbin/dump/traverse.c	Mon Aug  7 23:26:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: traverse.c,v 1.55 2022/01/26 20:22:14 christos Exp $	*/
+/*	$NetBSD: traverse.c,v 1.56 2023/08/07 23:26:40 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1988, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)traverse.c	8.7 (Berkeley) 6/15/95";
 #else
-__RCSID("$NetBSD: traverse.c,v 1.55 2022/01/26 20:22:14 christos Exp $");
+__RCSID("$NetBSD: traverse.c,v 1.56 2023/08/07 23:26:40 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -780,7 +780,7 @@ appendextdata(union dinode *dp)
 	tbperdb = ufsib->ufs_bsize >> tp_bshift;
 	assert(count + blks < TP_NINDIR);
 	for (i = 0; i < blks; i++)
-		if (>dp2.di_extb[i / tbperdb] != 0)
+		if (dp->dp2.di_extb[i / tbperdb] != 0)
 spcl.c_addr[count + i] = 1;
 			else
 spcl.c_addr[count + i] = 0;



CVS commit: src/sbin/dump

2023-08-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug  7 23:26:40 UTC 2023

Modified Files:
src/sbin/dump: traverse.c

Log Message:
fix always true conditional by removing the address-of operator.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sbin/dump/traverse.c

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



CVS commit: src/sbin/bioctl

2023-08-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  4 03:45:07 UTC 2023

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

Log Message:
bioctl(8): bio_show_volumes(): Do not return pointer to stack.

Found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/bioctl/bioctl.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/bioctl/bioctl.c
diff -u src/sbin/bioctl/bioctl.c:1.19 src/sbin/bioctl/bioctl.c:1.20
--- src/sbin/bioctl/bioctl.c:1.19	Tue May 10 14:16:25 2022
+++ src/sbin/bioctl/bioctl.c	Fri Aug  4 03:45:07 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bioctl.c,v 1.19 2022/05/10 14:16:25 msaitoh Exp $ */
+/* $NetBSD: bioctl.c,v 1.20 2023/08/04 03:45:07 rin Exp $ */
 /* $OpenBSD: bioctl.c,v 1.52 2007/03/20 15:26:06 jmc Exp $ */
 
 /*
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: bioctl.c,v 1.19 2022/05/10 14:16:25 msaitoh Exp $");
+__RCSID("$NetBSD: bioctl.c,v 1.20 2023/08/04 03:45:07 rin Exp $");
 #endif
 
 #include 
@@ -78,7 +78,7 @@ struct locator {
 __dead static void 	usage(void);
 static void	bio_alarm(int, int, char **);
 static void	bio_show_common(int, int, char **);
-static int	bio_show_volumes(struct biotmp *);
+static int	bio_show_volumes(struct biotmp *, struct bioc_vol *);
 static void	bio_show_disks(struct biotmp *);
 static void	bio_setblink(int, int, char **);
 static void 	bio_blink(int, char *, int, int);
@@ -232,34 +232,33 @@ str2locator(const char *string, struct l
  * Shows info about available RAID volumes.
  */
 static int
-bio_show_volumes(struct biotmp *bt)
+bio_show_volumes(struct biotmp *bt, struct bioc_vol *bv)
 {
-	struct bioc_vol 	bv;
 	const char 		*status, *rtypestr, *stripestr;
 	char 			size[64], percent[16], seconds[20];
 	char 			rtype[16], stripe[16], tmp[48];
 
 	rtypestr = stripestr = NULL;
 
-	memset(, 0, sizeof(bv));
-	bv.bv_cookie = bl.bl_cookie;
-	bv.bv_volid = bt->volid;
-	bv.bv_percent = -1;
-	bv.bv_seconds = 0;
+	memset(bv, 0, sizeof(*bv));
+	bv->bv_cookie = bl.bl_cookie;
+	bv->bv_volid = bt->volid;
+	bv->bv_percent = -1;
+	bv->bv_seconds = 0;
 
-	if (ioctl(bt->fd, BIOCVOL, ) == -1)
+	if (ioctl(bt->fd, BIOCVOL, bv) == -1)
 		err(EXIT_FAILURE, "BIOCVOL");
 
 	percent[0] = '\0';
 	seconds[0] = '\0';
-	if (bv.bv_percent != -1)
+	if (bv->bv_percent != -1)
 		snprintf(percent, sizeof(percent),
-		" %3.2f%% done", bv.bv_percent / 10.0);
-	if (bv.bv_seconds)
+		" %3.2f%% done", bv->bv_percent / 10.0);
+	if (bv->bv_seconds)
 		snprintf(seconds, sizeof(seconds),
-		" %u seconds", bv.bv_seconds);
+		" %u seconds", bv->bv_seconds);
 
-	switch (bv.bv_status) {
+	switch (bv->bv_status) {
 	case BIOC_SVONLINE:
 		status = BIOC_SVONLINE_S;
 		break;
@@ -290,13 +289,13 @@ bio_show_volumes(struct biotmp *bt)
 		break;
 	}
 
-	snprintf(bt->volname, sizeof(bt->volname), "%u", bv.bv_volid);
-	if (bv.bv_vendor[0])
-		snprintf(tmp, sizeof(tmp), "%s %s", bv.bv_dev, bv.bv_vendor);
+	snprintf(bt->volname, sizeof(bt->volname), "%u", bv->bv_volid);
+	if (bv->bv_vendor[0])
+		snprintf(tmp, sizeof(tmp), "%s %s", bv->bv_dev, bv->bv_vendor);
 	else
-		snprintf(tmp, sizeof(tmp), "%s", bv.bv_dev);
+		snprintf(tmp, sizeof(tmp), "%s", bv->bv_dev);
 
-	switch (bv.bv_level) {
+	switch (bv->bv_level) {
 	case BIOC_SVOL_HOTSPARE:
 		rtypestr = "Hot spare";
 		stripestr = "N/A";
@@ -312,8 +311,8 @@ bio_show_volumes(struct biotmp *bt)
 		rtypestr = "RAID 1+0";
 		break;
 	default:
-		snprintf(rtype, sizeof(rtype), "RAID %u", bv.bv_level);
-		if (bv.bv_level == 1 || bv.bv_stripe_size == 0)
+		snprintf(rtype, sizeof(rtype), "RAID %u", bv->bv_level);
+		if (bv->bv_level == 1 || bv->bv_stripe_size == 0)
 			stripestr = "N/A";
 		break;
 	}
@@ -323,18 +322,18 @@ bio_show_volumes(struct biotmp *bt)
 	if (stripestr)
 		strlcpy(stripe, stripestr, sizeof(stripe));
 	else
-		snprintf(stripe, sizeof(stripe), "%uK", bv.bv_stripe_size);
+		snprintf(stripe, sizeof(stripe), "%uK", bv->bv_stripe_size);
 
-	humanize_number(size, 5, (int64_t)bv.bv_size, "", HN_AUTOSCALE,
+	humanize_number(size, 5, (int64_t)bv->bv_size, "", HN_AUTOSCALE,
 	HN_B | HN_NOSPACE | HN_DECIMAL);
 
 	printf("%6s %-12s %4s %20s %8s %6s %s%s\n",
 	bt->volname, status, size, tmp,
 	rtype, stripe, percent, seconds);
 
-	bt->bv = 
+	bt->bv = bv;
 
-	return bv.bv_nodisk;
+	return bv->bv_nodisk;
 }
 
 /*
@@ -431,6 +430,7 @@ bio_show_common(int fd, int argc, char *
 {
 	struct biotmp 		*biot;
 	struct bioc_inq 	bi;
+	struct bioc_vol 	bv;
 	int 			i, d, ndisks;
 	bool 			show_all, show_disks;
 	bool 			show_vols, show_caps;
@@ -491,7 +491,7 @@ bio_show_common(int fd, int argc, char *
 	for (i = 0; i < bi.bi_novol; i++) {
 		biot->format = true;
 		biot->volid = i;
-		ndisks = bio_show_volumes(biot);
+		ndisks = bio_show_volumes(biot, );
 		if (show_vols)
 			continue;
 



CVS commit: src/sbin/bioctl

2023-08-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  4 03:45:07 UTC 2023

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

Log Message:
bioctl(8): bio_show_volumes(): Do not return pointer to stack.

Found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/bioctl/bioctl.c

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



CVS commit: src/sbin/fsck_udf

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:06:11 UTC 2023

Modified Files:
src/sbin/fsck_udf: main.c

Log Message:
avoid double-free.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/fsck_udf/main.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/fsck_udf/main.c
diff -u src/sbin/fsck_udf/main.c:1.13 src/sbin/fsck_udf/main.c:1.14
--- src/sbin/fsck_udf/main.c:1.13	Mon Apr 25 15:37:14 2022
+++ src/sbin/fsck_udf/main.c	Thu Aug  3 08:06:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.13 2022/04/25 15:37:14 reinoud Exp $	*/
+/*	$NetBSD: main.c,v 1.14 2023/08/03 08:06:11 mrg Exp $	*/
 
 /*
  * Copyright (c) 2022 Reinoud Zandijk
@@ -37,7 +37,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.13 2022/04/25 15:37:14 reinoud Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 2023/08/03 08:06:11 mrg Exp $");
 #endif /* not lint */
 
 #include 
@@ -2800,6 +2800,7 @@ udf_check_VDS_areas(void) {
 		context.vds_buf  = vds1_buf;
 		context.vds_size = vds1_size;
 		free(vds2_buf);
+		vds2_buf = NULL;
 	}
 	if (!error2) {
 		/* retrieve data from VDS 2 */
@@ -2807,6 +2808,7 @@ udf_check_VDS_areas(void) {
 		context.vds_buf  = vds2_buf;
 		context.vds_size = vds2_size;
 		free(vds1_buf);
+		vds1_buf = NULL;
 	}
 	/* check if all is correct and complete */
 	error = udf_process_vds();



CVS commit: src/sbin/fsck_udf

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:06:11 UTC 2023

Modified Files:
src/sbin/fsck_udf: main.c

Log Message:
avoid double-free.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/fsck_udf/main.c

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



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:18:07 UTC 2023

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

Log Message:
gpt.8: fix some grammar

(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/gpt/gpt.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/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.77 src/sbin/gpt/gpt.8:1.78
--- src/sbin/gpt/gpt.8:1.77	Sat Jul 15 21:11:58 2023
+++ src/sbin/gpt/gpt.8	Sat Jul 15 21:18:06 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.77 2023/07/15 21:11:58 gutteridge Exp $
+.\" $NetBSD: gpt.8,v 1.78 2023/07/15 21:18:06 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -174,7 +174,7 @@ The minimum size is 1 sector.
 The
 .Fl t Ar type
 option allows the user to specify the partition type.
-The type is given as an UUID, but
+The type is given as a UUID, but
 .Nm
 accepts
 .Bl -tag -width "windows-reserved" -compact -offset indent
@@ -381,7 +381,7 @@ This can cause multiple partitions to be
 The
 .Fl t Ar type
 option selects all partitions that have the given type.
-The type is given as an UUID or by the aliases that the
+The type is given as a UUID or by the aliases that the
 .Ic add
 command accepts.
 This can cause multiple partitions to be labeled.
@@ -639,7 +639,7 @@ option the GPT partition label will be d
 type.
 With the
 .Fl u
-option the GPT partition type is displayed as an UUID instead of in a
+option the GPT partition type is displayed as a UUID instead of in a
 user friendly form.
 With the
 .Fl i
@@ -826,7 +826,7 @@ However, it is believed that the current
 and stable enough that this tool can be used without bullet-proof footware if
 one thinks one does not make mistakes.
 .Pp
-It is expected that the basic usage model does not change, but it is
+It is expected that the basic usage model will not change, but it is
 possible that future versions will not be compatible in the strictest sense
 of the word.
 Also, options primarily intended for diagnostic or debug purposes may be



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:18:07 UTC 2023

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

Log Message:
gpt.8: fix some grammar

(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)


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

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



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:11:58 UTC 2023

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

Log Message:
gpt.8: drop cross-reference to cvs(1)

It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/gpt/gpt.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/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.76 src/sbin/gpt/gpt.8:1.77
--- src/sbin/gpt/gpt.8:1.76	Thu Apr  7 13:57:44 2022
+++ src/sbin/gpt/gpt.8	Sat Jul 15 21:11:58 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.76 2022/04/07 13:57:44 kre Exp $
+.\" $NetBSD: gpt.8,v 1.77 2023/07/15 21:11:58 gutteridge Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd April 7, 2022
+.Dd July 15, 2023
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -59,11 +59,6 @@ tables
 but see
 .Sx BUGS
 below for how and where functionality is missing.
-The basic usage model of the
-.Nm
-tool follows that of the
-.Xr cvs 1
-tool.
 The general options are described in the following paragraph.
 The remaining paragraphs describe the individual commands with their options.
 Here we conclude by mentioning that a



CVS commit: src/sbin/gpt

2023-07-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jul 15 21:11:58 UTC 2023

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

Log Message:
gpt.8: drop cross-reference to cvs(1)

It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.


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

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



Re: CVS commit: src/sbin/newfs

2023-07-05 Thread Greg Troxel
Taylor R Campbell  writes:

> Well, what happened is:
>
> 1. I was drafting posix_memalign and aligned_alloc for libbsdmalloc in
>response to the thread about static program size yesterday, and
>carefully reading the specs -- POSIX 2018, C11 -- to make sure I
>got all the details right.
>
> 2. I saw a silly restriction in C11, that aligned_alloc(A, S) requires
>A to divide S.
>
> 3. For the sake of encouraging portable code, I figured we should
>enforce that restriction, so I went ahead and did that in both the
>libbsdmalloc front end I was writing and in jemalloc.  (This caused
>a bunch of tests to start failing.)
>
> 4. I audited all the uses of aligned_alloc in tree to make sury they
>meet the restriction (which fixed the tests).
>
> 5. Someone pointed out that the silly restriction that was imposed in
>C11 had actually been lifted in C17:
>
> (C11) The value of alignment shall be a valid alignment
> supported by the implementation and the value of size shall be
> an integral multiple of alignment.
>
> (C17) If the value of alignment is not a valid alignment
> supported by the implementation the function shall fail by
> returning a null pointer.
>
> 6. So I reverted the jemalloc enforcement of the C11 restriction, and
>reverted the fixes made to conform to it, and removed the
>restriction in the new libbsdmalloc code, and we're more or less
>back to where we started.
>
> Except I am now reminded that I updated t_posix_memalign.c to verify
> this silly restriction of aligned_alloc, so I'd better go fix that
> before a bunch of tests start failing again!

Thanks for taking the time to explain so thoroughly.  So we are back to
status quo ante-fixum, which is by definition always ok :-)


Re: CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
> Date: Wed, 05 Jul 2023 07:03:09 -0400
> From: Greg Troxel 
> References: <20230705105858.33080f...@cvs.netbsd.org>
> 
> "Taylor R Campbell"  writes:
> 
> > Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."
> >
> > C17 lifted this restriction.
> 
> I know we have only two toolchains maintained in tree, but did we really
> decide to require C17?

Well, what happened is:

1. I was drafting posix_memalign and aligned_alloc for libbsdmalloc in
   response to the thread about static program size yesterday, and
   carefully reading the specs -- POSIX 2018, C11 -- to make sure I
   got all the details right.

2. I saw a silly restriction in C11, that aligned_alloc(A, S) requires
   A to divide S.

3. For the sake of encouraging portable code, I figured we should
   enforce that restriction, so I went ahead and did that in both the
   libbsdmalloc front end I was writing and in jemalloc.  (This caused
   a bunch of tests to start failing.)

4. I audited all the uses of aligned_alloc in tree to make sury they
   meet the restriction (which fixed the tests).

5. Someone pointed out that the silly restriction that was imposed in
   C11 had actually been lifted in C17:

(C11) The value of alignment shall be a valid alignment
supported by the implementation and the value of size shall be
an integral multiple of alignment.

(C17) If the value of alignment is not a valid alignment
supported by the implementation the function shall fail by
returning a null pointer.

6. So I reverted the jemalloc enforcement of the C11 restriction, and
   reverted the fixes made to conform to it, and removed the
   restriction in the new libbsdmalloc code, and we're more or less
   back to where we started.

Except I am now reminded that I updated t_posix_memalign.c to verify
this silly restriction of aligned_alloc, so I'd better go fix that
before a bunch of tests start failing again!


CVS commit: src/sbin/fsck_ffs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:59:08 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.108 -r1.109 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.70 -r1.71 src/sbin/fsck_ffs/utilities.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.77 src/sbin/fsck_ffs/inode.c:1.78
--- src/sbin/fsck_ffs/inode.c:1.77	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/inode.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -462,10 +462,8 @@ setinodebuf(ino_t inum)
 		partialcnt = fullcnt;
 		partialsize = inobufsize;
 	}
-	__CTASSERT(powerof2(DEV_BSIZE));
 	if (inodebuf == NULL &&
-	(inodebuf = aligned_alloc(DEV_BSIZE,
-		roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL)
+	(inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
 		errexit("Cannot allocate space for inode buffer");
 }
 

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.108 src/sbin/fsck_ffs/setup.c:1.109
--- src/sbin/fsck_ffs/setup.c:1.108	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/setup.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -127,7 +127,6 @@ setup(const char *dev, const char *origd
 	lfdir = 0;
 	initbarea();
 	initbarea();
-	__CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0);
 	sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
@@ -460,9 +459,8 @@ setup(const char *dev, const char *origd
 	 * read in the summary info.
 	 */
 	asked = 0;
-	__CTASSERT(powerof2(DEV_BSIZE));
 	sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
-	roundup2(sblock->fs_cssize, DEV_BSIZE));
+	sblock->fs_cssize);
 	if (sblock->fs_csp == NULL) {
 		pwarn("cannot alloc %u bytes for summary info\n",
 		sblock->fs_cssize);
@@ -497,9 +495,7 @@ setup(const char *dev, const char *origd
 	 * allocate and initialize the necessary maps
 	 */
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
-	__CTASSERT(powerof2(DEV_BSIZE));
-	blockmap = aligned_alloc(DEV_BSIZE,
-	roundup2((unsigned)bmapsize, DEV_BSIZE));
+	blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
 	if (blockmap == NULL) {
 		pwarn("cannot alloc %u bytes for blockmap\n",
 		(unsigned)bmapsize);
@@ -534,9 +530,7 @@ setup(const char *dev, const char *origd
 		(unsigned)(numdirs * sizeof(struct inoinfo *)));
 		goto badsblabel;
 	}
-	__CTASSERT(powerof2(DEV_BSIZE));
-	cgrp = aligned_alloc(DEV_BSIZE,
-	roundup2(sblock->fs_cgsize, DEV_BSIZE));
+	cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
 	if (cgrp == NULL) {
 		pwarn("cannot alloc %u bytes for cylinder group\n",
 		sblock->fs_cgsize);

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.70 src/sbin/fsck_ffs/utilities.c:1.71
--- src/sbin/fsck_ffs/utilities.c:1.70	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/utilities.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -135,15 +135,12 @@ bufinit(void)
 	char *bufp;
 
 	pbp = pdirbp = (struct bufarea *)0;
-	__CTASSERT(powerof2(DEV_BSIZE));
-	bufp = aligned_alloc(DEV_BSIZE,
-	roundup2((unsigned int)sblock->fs_bsize, DEV_BSIZE));
+	bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
 	if (bufp == 0)
 		

CVS commit: src/sbin/fsck_ffs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:59:08 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.108 -r1.109 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.70 -r1.71 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:58 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.119 -r1.120 src/sbin/newfs/newfs.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/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.134 src/sbin/newfs/mkfs.c:1.135
--- src/sbin/newfs/mkfs.c:1.134	Tue Jul  4 20:40:34 2023
+++ src/sbin/newfs/mkfs.c	Wed Jul  5 10:58:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -201,11 +201,9 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
-	__CTASSERT((sizeof(*fsun) % DEV_BSIZE) == 0);
 	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
 	memset(fsun, 0, sizeof(*fsun));
-	__CTASSERT((sizeof(*cgun) % DEV_BSIZE) == 0);
 	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
 	memset(cgun, 0, sizeof(*cgun));

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.119 src/sbin/newfs/newfs.c:1.120
--- src/sbin/newfs/newfs.c:1.119	Tue Jul  4 20:40:34 2023
+++ src/sbin/newfs/newfs.c	Wed Jul  5 10:58:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $	*/
+/*	$NetBSD: newfs.c,v 1.120 2023/07/05 10:58:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.120 2023/07/05 10:58:58 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -624,9 +624,7 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		__CTASSERT(powerof2(DEV_BSIZE));
-		if ((buf = aligned_alloc(DEV_BSIZE,
-			roundup2(bufsize, DEV_BSIZE))) == NULL)
+		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
 		memset(buf, 0, bufsize);



CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:58 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.119 -r1.120 src/sbin/newfs/newfs.c

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



CVS commit: src/sbin/nvmectl

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:47 UTC 2023

Modified Files:
src/sbin/nvmectl: firmware.c wdc.c

Log Message:
Revert "nvmectl(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.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/nvmectl/firmware.c
diff -u src/sbin/nvmectl/firmware.c:1.5 src/sbin/nvmectl/firmware.c:1.6
--- src/sbin/nvmectl/firmware.c:1.5	Tue Jul  4 20:40:43 2023
+++ src/sbin/nvmectl/firmware.c	Wed Jul  5 10:58:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $	*/
+/*	$NetBSD: firmware.c,v 1.6 2023/07/05 10:58:46 riastradh Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -33,7 +33,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $");
+__RCSID("$NetBSD: firmware.c,v 1.6 2023/07/05 10:58:46 riastradh Exp $");
 #if 0
 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/firmware.c 329824 2018-02-22 13:32:31Z wma $");
 #endif
@@ -123,7 +123,6 @@ update_firmware(int fd, uint8_t *payload
 	off = 0;
 	resid = payload_size;
 
-	__CTASSERT((NVME_MAX_XFER_SIZE % PAGE_SIZE) == 0);
 	if ((chunk = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE)) == NULL)
 		errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE);
 
Index: src/sbin/nvmectl/wdc.c
diff -u src/sbin/nvmectl/wdc.c:1.5 src/sbin/nvmectl/wdc.c:1.6
--- src/sbin/nvmectl/wdc.c:1.5	Tue Jul  4 20:40:43 2023
+++ src/sbin/nvmectl/wdc.c	Wed Jul  5 10:58:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $	*/
+/*	$NetBSD: wdc.c,v 1.6 2023/07/05 10:58:46 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $");
+__RCSID("$NetBSD: wdc.c,v 1.6 2023/07/05 10:58:46 riastradh Exp $");
 #if 0
 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/wdc.c 329824 2018-02-22 13:32:31Z wma $");
 #endif
@@ -125,7 +125,7 @@ wdc_do_dump(int fd, char *tmpl, const ch
 	fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (fd2 < 0)
 		err(1, "open %s", tmpl);
-	buf = aligned_alloc(page_size, roundup(NVME_MAX_XFER_SIZE, page_size));
+	buf = aligned_alloc(page_size, NVME_MAX_XFER_SIZE);
 	if (buf == NULL)
 		errx(1, "Can't get buffer to read dump");
 	offset = 0;



CVS commit: src/sbin/nvmectl

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:47 UTC 2023

Modified Files:
src/sbin/nvmectl: firmware.c wdc.c

Log Message:
Revert "nvmectl(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.c

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



CVS commit: src/sbin/fsck_ffs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:53 UTC 2023

Modified Files:
src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c
pass4.c pass5.c pass6.c quota2.c setup.c utilities.c

Log Message:
fsck_ffs(8): Fix whitespace issues.

- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.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/fsck_ffs/dir.c
diff -u src/sbin/fsck_ffs/dir.c:1.61 src/sbin/fsck_ffs/dir.c:1.62
--- src/sbin/fsck_ffs/dir.c:1.61	Sun May  5 14:59:06 2019
+++ src/sbin/fsck_ffs/dir.c	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $	*/
+/*	$NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -230,7 +230,7 @@ dirscan(struct inodesc *idesc)
 			dirty(bp);
 			sbdirty();
 		}
-		if (n & STOP) 
+		if (n & STOP)
 			return (n);
 	}
 	return (idesc->id_filesize > 0 ? KEEPON : STOP);
@@ -265,7 +265,7 @@ fsck_readdir(struct inodesc *idesc)
 		dp->d_name[0] = '\0';
 		if (fix)
 			dirty(bp);
-		else 
+		else
 			markclean = 0;
 		idesc->id_loc += dirblksiz;
 		idesc->id_filesize -= dirblksiz;
@@ -294,7 +294,7 @@ dpok:
 		dp->d_reclen = iswap16(iswap16(dp->d_reclen) + size);
 		if (fix)
 			dirty(bp);
-		else 
+		else
 			markclean = 0;
 	}
 	return (dp);
@@ -308,7 +308,7 @@ dpok:
  *	0: bad
  */
 static int
-dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp) 
+dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp)
 {
 	uint8_t namlen, type;
 	uint16_t reclen;
@@ -497,7 +497,7 @@ adjust(struct inodesc *idesc, int lcnt)
 		if (preen || reply("ADJUST") == 1) {
 			DIP_SET(dp, nlink, iswap16(nlink - lcnt));
 			inodirty();
-		} else 
+		} else
 			markclean = 0;
 	}
 }
@@ -715,7 +715,7 @@ makeentry(ino_t parent, ino_t ino, const
 	union dinode *dp;
 	struct inodesc idesc;
 	char pathbuf[MAXPATHLEN + 1];
-	
+
 	if (parent < UFS_ROOTINO || parent >= maxino ||
 	ino < UFS_ROOTINO || ino >= maxino)
 		return (0);

Index: src/sbin/fsck_ffs/extern.h
diff -u src/sbin/fsck_ffs/extern.h:1.28 src/sbin/fsck_ffs/extern.h:1.29
--- src/sbin/fsck_ffs/extern.h:1.28	Thu Nov 17 06:40:38 2022
+++ src/sbin/fsck_ffs/extern.h	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.28 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: extern.h,v 1.29 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1994 James A. Jegers
@@ -88,7 +88,6 @@ void		remove_uquot(struct uquot_hash *,s
 void		update_uquot(ino_t, uid_t, gid_t, int64_t, int64_t);
 int		is_quota_inode(ino_t);
 
-
 int		check_wapbl(void);
 void		replay_wapbl(void);
 void		cleanup_wapbl(void);

Index: src/sbin/fsck_ffs/fsck.h
diff -u src/sbin/fsck_ffs/fsck.h:1.57 src/sbin/fsck_ffs/fsck.h:1.58
--- src/sbin/fsck_ffs/fsck.h:1.57	Sat Jan 14 12:12:50 2023
+++ src/sbin/fsck_ffs/fsck.h	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsck.h,v 1.57 2023/01/14 12:12:50 christos Exp $	*/
+/*	$NetBSD: fsck.h,v 1.58 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -101,7 +101,6 @@ extern struct inostatlist {
 	struct inostat *il_stat;/* inostat info for this cylinder group */
 } *inostathead;
 
-
 /*
  * buffer cache structure.
  */
@@ -205,14 +204,14 @@ struct inodesc {
 
 /*
  * Linked list of duplicate blocks.
- * 
+ *
  * The list is composed of two parts. The first part of the
  * list (from duplist through the node pointed to by muldup)
- * contains a single copy of each duplicate block that has been 
+ * contains a single copy of each duplicate block that has been
  * found. The second part of the list (from muldup to the end)
  * contains duplicate blocks that have been found more than once.
  * To check if a block has been found as a duplicate it is only
- * necessary to 

CVS commit: src/sbin/fsck_ffs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:53 UTC 2023

Modified Files:
src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c
pass4.c pass5.c pass6.c quota2.c setup.c utilities.c

Log Message:
fsck_ffs(8): Fix whitespace issues.

- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/nvmectl

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:43 UTC 2023

Modified Files:
src/sbin/nvmectl: firmware.c wdc.c

Log Message:
nvmectl(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.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/nvmectl/firmware.c
diff -u src/sbin/nvmectl/firmware.c:1.4 src/sbin/nvmectl/firmware.c:1.5
--- src/sbin/nvmectl/firmware.c:1.4	Wed Apr 18 10:11:44 2018
+++ src/sbin/nvmectl/firmware.c	Tue Jul  4 20:40:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: firmware.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $	*/
+/*	$NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -33,7 +33,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: firmware.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $");
+__RCSID("$NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $");
 #if 0
 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/firmware.c 329824 2018-02-22 13:32:31Z wma $");
 #endif
@@ -123,6 +123,7 @@ update_firmware(int fd, uint8_t *payload
 	off = 0;
 	resid = payload_size;
 
+	__CTASSERT((NVME_MAX_XFER_SIZE % PAGE_SIZE) == 0);
 	if ((chunk = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE)) == NULL)
 		errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE);
 
Index: src/sbin/nvmectl/wdc.c
diff -u src/sbin/nvmectl/wdc.c:1.4 src/sbin/nvmectl/wdc.c:1.5
--- src/sbin/nvmectl/wdc.c:1.4	Wed Apr 18 10:11:44 2018
+++ src/sbin/nvmectl/wdc.c	Tue Jul  4 20:40:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $	*/
+/*	$NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: wdc.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $");
+__RCSID("$NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $");
 #if 0
 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/wdc.c 329824 2018-02-22 13:32:31Z wma $");
 #endif
@@ -125,7 +125,7 @@ wdc_do_dump(int fd, char *tmpl, const ch
 	fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (fd2 < 0)
 		err(1, "open %s", tmpl);
-	buf = aligned_alloc(page_size, NVME_MAX_XFER_SIZE);
+	buf = aligned_alloc(page_size, roundup(NVME_MAX_XFER_SIZE, page_size));
 	if (buf == NULL)
 		errx(1, "Can't get buffer to read dump");
 	offset = 0;



CVS commit: src/sbin/nvmectl

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:43 UTC 2023

Modified Files:
src/sbin/nvmectl: firmware.c wdc.c

Log Message:
nvmectl(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.c

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



CVS commit: src/sbin/newfs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:34 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
newfs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.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/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.133 src/sbin/newfs/mkfs.c:1.134
--- src/sbin/newfs/mkfs.c:1.133	Sat Jan  7 19:41:29 2023
+++ src/sbin/newfs/mkfs.c	Tue Jul  4 20:40:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -201,9 +201,11 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
+	__CTASSERT((sizeof(*fsun) % DEV_BSIZE) == 0);
 	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
 	memset(fsun, 0, sizeof(*fsun));
+	__CTASSERT((sizeof(*cgun) % DEV_BSIZE) == 0);
 	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
 	memset(cgun, 0, sizeof(*cgun));

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.118 src/sbin/newfs/newfs.c:1.119
--- src/sbin/newfs/newfs.c:1.118	Thu Nov 17 06:40:39 2022
+++ src/sbin/newfs/newfs.c	Tue Jul  4 20:40:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $	*/
+/*	$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -624,7 +624,9 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
+		__CTASSERT(powerof2(DEV_BSIZE));
+		if ((buf = aligned_alloc(DEV_BSIZE,
+			roundup2(bufsize, DEV_BSIZE))) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
 		memset(buf, 0, bufsize);



CVS commit: src/sbin/newfs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:34 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
newfs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.c

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



CVS commit: src/sbin/fsck_ffs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:22 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.75 src/sbin/fsck_ffs/inode.c:1.76
--- src/sbin/fsck_ffs/inode.c:1.75	Sat Jan 14 17:01:10 2023
+++ src/sbin/fsck_ffs/inode.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $	*/
+/*	$NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $");
+__RCSID("$NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -462,8 +462,10 @@ setinodebuf(ino_t inum)
 		partialcnt = fullcnt;
 		partialsize = inobufsize;
 	}
+	__CTASSERT(powerof2(DEV_BSIZE));
 	if (inodebuf == NULL &&
-	(inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
+	(inodebuf = aligned_alloc(DEV_BSIZE,
+		roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL)
 		errexit("Cannot allocate space for inode buffer");
 }
 

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.106 src/sbin/fsck_ffs/setup.c:1.107
--- src/sbin/fsck_ffs/setup.c:1.106	Sun Jan  8 05:25:24 2023
+++ src/sbin/fsck_ffs/setup.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $	*/
+/*	$NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $");
+__RCSID("$NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -127,6 +127,7 @@ setup(const char *dev, const char *origd
 	lfdir = 0;
 	initbarea();
 	initbarea();
+	__CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0);
 	sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
@@ -459,8 +460,9 @@ setup(const char *dev, const char *origd
 	 * read in the summary info.
 	 */
 	asked = 0;
+	__CTASSERT(powerof2(DEV_BSIZE));
 	sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
-	sblock->fs_cssize);
+	roundup2(sblock->fs_cssize, DEV_BSIZE));
 	if (sblock->fs_csp == NULL) {
 		pwarn("cannot alloc %u bytes for summary info\n",
 		sblock->fs_cssize);	
@@ -495,7 +497,9 @@ setup(const char *dev, const char *origd
 	 * allocate and initialize the necessary maps
 	 */
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
-	blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
+	__CTASSERT(powerof2(DEV_BSIZE));
+	blockmap = aligned_alloc(DEV_BSIZE,
+	roundup2((unsigned)bmapsize, DEV_BSIZE));
 	if (blockmap == NULL) {
 		pwarn("cannot alloc %u bytes for blockmap\n",
 		(unsigned)bmapsize);
@@ -530,7 +534,9 @@ setup(const char *dev, const char *origd
 		(unsigned)(numdirs * sizeof(struct inoinfo *)));
 		goto badsblabel;
 	}
-	cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
+	__CTASSERT(powerof2(DEV_BSIZE));
+	cgrp = aligned_alloc(DEV_BSIZE,
+	roundup2(sblock->fs_cgsize, DEV_BSIZE));
 	if (cgrp == NULL) {
 		pwarn("cannot alloc %u bytes for cylinder group\n",
 		sblock->fs_cgsize);

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.68 src/sbin/fsck_ffs/utilities.c:1.69
--- src/sbin/fsck_ffs/utilities.c:1.68	Sat Jan 14 12:12:50 2023
+++ src/sbin/fsck_ffs/utilities.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $	*/
+/*	$NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -135,12 +135,15 @@ bufinit(void)
 	char *bufp;
 
 	pbp = pdirbp = (struct bufarea *)0;
-	bufp = aligned_alloc(DEV_BSIZE, 

CVS commit: src/sbin/fsck_ffs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:22 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/mount

2023-05-25 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu May 25 17:37:05 UTC 2023

Modified Files:
src/sbin/mount: pathadj.c

Log Message:
pathadj() is required to succeed.   If it cannot, simply issuing a
warning and continuing is not good enough.  Change the warning to
an error (and hence immediate exit) instead, that's all we can do.

Problem pointed out by tlaro...@polynum.com

XXX - pullup -10 (others?)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount/pathadj.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/mount/pathadj.c
diff -u src/sbin/mount/pathadj.c:1.3 src/sbin/mount/pathadj.c:1.4
--- src/sbin/mount/pathadj.c:1.3	Sun Jul 26 08:20:22 2020
+++ src/sbin/mount/pathadj.c	Thu May 25 17:37:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathadj.c,v 1.3 2020/07/26 08:20:22 mlelstv Exp $	*/
+/*	$NetBSD: pathadj.c,v 1.4 2023/05/25 17:37:05 kre Exp $	*/
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation.  All Rights Reserved.
@@ -37,10 +37,8 @@ void
 pathadj(const char *input, char *adjusted)
 {
 
-	if (realpath(input, adjusted) == NULL) {
-		warn("Warning: realpath %s", input);
-		return;
-	}
+	if (realpath(input, adjusted) == NULL)
+		err(EXIT_FAILURE, "realpath '%s' failed", input);
 
 	if (input[0] != '/') {
 		warnx("\"%s\" is a relative path.", input);



CVS commit: src/sbin/mount

2023-05-25 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu May 25 17:37:05 UTC 2023

Modified Files:
src/sbin/mount: pathadj.c

Log Message:
pathadj() is required to succeed.   If it cannot, simply issuing a
warning and continuing is not good enough.  Change the warning to
an error (and hence immediate exit) instead, that's all we can do.

Problem pointed out by tlaro...@polynum.com

XXX - pullup -10 (others?)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount/pathadj.c

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



CVS commit: src/sbin/chown

2023-05-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat May 20 09:41:34 UTC 2023

Modified Files:
src/sbin/chown: chgrp.1

Log Message:
ALso fix chgrp Synopsis to include -d option


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/chown/chgrp.1

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



CVS commit: src/sbin/chown

2023-05-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat May 20 09:41:34 UTC 2023

Modified Files:
src/sbin/chown: chgrp.1

Log Message:
ALso fix chgrp Synopsis to include -d option


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/chown/chgrp.1

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

Modified files:

Index: src/sbin/chown/chgrp.1
diff -u src/sbin/chown/chgrp.1:1.9 src/sbin/chown/chgrp.1:1.10
--- src/sbin/chown/chgrp.1:1.9	Thu May  4 17:07:56 2023
+++ src/sbin/chown/chgrp.1	Sat May 20 09:41:34 2023
@@ -29,9 +29,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)chgrp.1	8.3 (Berkeley) 3/31/94
-.\"	$NetBSD: chgrp.1,v 1.9 2023/05/04 17:07:56 pgoyette Exp $
+.\"	$NetBSD: chgrp.1,v 1.10 2023/05/20 09:41:34 pgoyette Exp $
 .\"
-.Dd May 1, 2023
+.Dd May 19, 2023
 .Dt CHGRP 1
 .Os
 .Sh NAME
@@ -43,7 +43,7 @@
 .Fl R
 .Op Fl H | Fl L | Fl P
 .Oc
-.Op Fl fhv
+.Op Fl dfhv
 .Ar group
 .Ar
 .Nm
@@ -51,7 +51,7 @@
 .Fl R
 .Op Fl H | Fl L | Fl P
 .Oc
-.Op Fl fhv
+.Op Fl dfhv
 .Fl Fl reference=rfile
 .Ar
 .Sh DESCRIPTION



  1   2   3   4   5   6   7   >