CVS commit: src/sbin/sysctl

2023-04-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Apr  2 18:15:24 UTC 2023

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

Log Message:
commonize case block


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sbin/sysctl/sysctl.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/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.164 src/sbin/sysctl/sysctl.c:1.165
--- src/sbin/sysctl/sysctl.c:1.164	Sun Apr  2 18:11:26 2023
+++ src/sbin/sysctl/sysctl.c	Sun Apr  2 18:15:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $ */
+/*	$NetBSD: sysctl.c,v 1.165 2023/04/02 18:15:24 ryo Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.165 2023/04/02 18:15:24 ryo Exp $");
 #endif
 #endif /* not lint */
 
@@ -940,13 +940,6 @@ parse(char *l, regex_t *re, size_t *last
 	}
 
 	switch (type) {
-	case CTLTYPE_NODE:
-		/*
-		 * XXX old behavior is to print.  should we error instead?
-		 */
-		print_tree(&name[0], namelen, node, CTLTYPE_NODE, 0, re,
-		lastcompiled);
-		break;
 	case CTLTYPE_INT:
 	case CTLTYPE_BOOL:
 	case CTLTYPE_QUAD:
@@ -955,6 +948,7 @@ parse(char *l, regex_t *re, size_t *last
 	case CTLTYPE_STRING:
 		write_string(&name[0], namelen, node, value, optional);
 		break;
+	case CTLTYPE_NODE:
 	case CTLTYPE_STRUCT:
 		/*
 		 * XXX old behavior is to print.  should we error instead?



CVS commit: src/sbin/sysctl

2023-04-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Apr  2 18:15:24 UTC 2023

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

Log Message:
commonize case block


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sbin/sysctl/sysctl.c

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



CVS commit: src/sbin/sysctl

2023-04-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Apr  2 18:11:26 UTC 2023

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

Log Message:
don't pass add=1 to print_tree() when displaying by specifying nodes.

For example, "sysctl -w kern.mbuf=" had been displayed extra node names in the 
MIB.
 # sysctl -w kern.mbuf=
 kern.mbuf.mbuf.msize = 512
 kern.mbuf.mbuf.mclbytes = 2048
 :


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sbin/sysctl/sysctl.c

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



CVS commit: src/sbin/sysctl

2023-04-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Apr  2 18:11:26 UTC 2023

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

Log Message:
don't pass add=1 to print_tree() when displaying by specifying nodes.

For example, "sysctl -w kern.mbuf=" had been displayed extra node names in the 
MIB.
 # sysctl -w kern.mbuf=
 kern.mbuf.mbuf.msize = 512
 kern.mbuf.mbuf.mclbytes = 2048
 :


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sbin/sysctl/sysctl.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/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.163 src/sbin/sysctl/sysctl.c:1.164
--- src/sbin/sysctl/sysctl.c:1.163	Tue Dec 28 16:06:57 2021
+++ src/sbin/sysctl/sysctl.c	Sun Apr  2 18:11:26 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $ */
+/*	$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $");
 #endif
 #endif /* not lint */
 
@@ -944,7 +944,7 @@ parse(char *l, regex_t *re, size_t *last
 		/*
 		 * XXX old behavior is to print.  should we error instead?
 		 */
-		print_tree(&name[0], namelen, node, CTLTYPE_NODE, 1, re,
+		print_tree(&name[0], namelen, node, CTLTYPE_NODE, 0, re,
 		lastcompiled);
 		break;
 	case CTLTYPE_INT:



CVS commit: src/sbin/sysctl

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 16:06:57 UTC 2021

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

Log Message:
kern.hashstat takes too long and it is meaningless here.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sbin/sysctl/sysctl.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/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.162 src/sbin/sysctl/sysctl.c:1.163
--- src/sbin/sysctl/sysctl.c:1.162	Sun Aug 18 00:10:22 2019
+++ src/sbin/sysctl/sysctl.c	Tue Dec 28 11:06:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $ */
+/*	$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -191,6 +191,7 @@ static const struct handlespec {
 	{ "/kern/boottime",			kern_boottime, NULL, NULL },
 	{ "/kern/consdev",			kern_consdev, NULL, NULL },
 	{ "/kern/cp_time(/[0-9]+)?",		kern_cp_time, NULL, NULL },
+	{ "/kern/hashstat",			printother, NULL, "vmstat -H" },
 	{ "/kern/sysvipc_info",			printother, NULL, "ipcs" },
 	{ "/kern/cp_id(/[0-9]+)?",		kern_cp_id, NULL, NULL },
 



CVS commit: src/sbin/sysctl

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 16:06:57 UTC 2021

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

Log Message:
kern.hashstat takes too long and it is meaningless here.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sbin/sysctl/sysctl.c

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



CVS commit: src/sbin/sysctl

2019-08-17 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Aug 18 04:10:22 UTC 2019

Modified Files:
src/sbin/sysctl: Makefile prog_ops.h sysctl.c sysctl_hostops.c
sysctl_rumpops.c

Log Message:
sysctl: Add indirection of symbols to remove clash with sanitizers

Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlbyname and sysctlgetmibinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/sysctl/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sbin/sysctl/prog_ops.h
cvs rdiff -u -r1.161 -r1.162 src/sbin/sysctl/sysctl.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/sysctl/sysctl_hostops.c \
src/sbin/sysctl/sysctl_rumpops.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/sysctl/Makefile
diff -u src/sbin/sysctl/Makefile:1.21 src/sbin/sysctl/Makefile:1.22
--- src/sbin/sysctl/Makefile:1.21	Thu Nov 29 02:05:38 2012
+++ src/sbin/sysctl/Makefile	Sun Aug 18 04:10:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.21 2012/11/29 02:05:38 christos Exp $
+#	$NetBSD: Makefile,v 1.22 2019/08/18 04:10:22 kamil Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include 
@@ -13,4 +13,8 @@ SRCS=	sysctl.c
 CPPFLAGS+= -DRUMP_ACTION
 RUMPSRCS+= sysctlbyname.c sysctlgetmibinfo.c
 
+SANITIZER_RENAME_CLASSES+=	rump
+SANITIZER_RENAME_FILES.rump+=	${PROG}_rumpops.c ${RUMPSRCS}
+SANITIZER_RENAME_SYMBOL.rump+=	sysctlbyname sysctlgetmibinfo
+
 .include 

Index: src/sbin/sysctl/prog_ops.h
diff -u src/sbin/sysctl/prog_ops.h:1.2 src/sbin/sysctl/prog_ops.h:1.3
--- src/sbin/sysctl/prog_ops.h:1.2	Mon Dec 13 21:48:01 2010
+++ src/sbin/sysctl/prog_ops.h	Sun Aug 18 04:10:22 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.2 2010/12/13 21:48:01 pooka Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.3 2019/08/18 04:10:22 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -32,19 +32,33 @@
 #include 
 
 #ifndef CRUNCHOPS
+struct sysctlnode;
+
 struct prog_ops {
 	int (*op_init)(void);
 
 	int (*op_sysctl)(const int *, u_int, void *, size_t *,
 			 const void *, size_t);
+
+	/* Indirection needed for sanitizers. */
+
+	int (*op_sysctlbyname)(const char *, void *, size_t *,
+			 const void *, size_t);
+
+	int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, char *,
+			 size_t *, struct sysctlnode **, int);
 };
 extern const struct prog_ops prog_ops;
 
 #define prog_init prog_ops.op_init
 #define prog_sysctl prog_ops.op_sysctl
+#define prog_sysctlbyname prog_ops.op_sysctlbyname
+#define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo
 #else
 #define prog_init ((int (*)(void))NULL)
 #define prog_sysctl sysctl
+#define prog_sysctlbyname sysctlbyname
+#define prog_sysctlgetmibinfo sysctlgetmibinfo
 #endif
 
 #endif /* _PROG_OPS_H_ */

Index: src/sbin/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.161 src/sbin/sysctl/sysctl.c:1.162
--- src/sbin/sysctl/sysctl.c:1.161	Tue Oct 30 19:41:21 2018
+++ src/sbin/sysctl/sysctl.c	Sun Aug 18 04:10:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $ */
+/*	$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $");
 #endif
 #endif /* not lint */
 
@@ -896,7 +896,7 @@ parse(char *l, regex_t *re, size_t *last
 	namelen = CTL_MAXNAME;
 	sz = sizeof(gsname);
 
-	if (sysctlgetmibinfo(key, &name[0], &namelen, gsname, &sz, &node,
+	if (prog_sysctlgetmibinfo(key, &name[0], &namelen, gsname, &sz, &node,
 			 SYSCTL_VERSION) == -1) {
 		if (optional)
 			return;
@@ -1441,7 +1441,7 @@ parse_create(char *l)
 		namelen = sizeof(name) / sizeof(name[0]);
 		sz = sizeof(gsname);
 		*t = '\0';
-		rc = sysctlgetmibinfo(nname, &name[0], &namelen,
+		rc = prog_sysctlgetmibinfo(nname, &name[0], &namelen,
   gsname, &sz, NULL, SYSCTL_VERSION);
 		*t = sep[0];
 		if (rc == -1) {
@@ -1489,7 +1489,7 @@ parse_destroy(char *l)
 	memset(name, 0, sizeof(name));
 	namelen = sizeof(name) / sizeof(name[0]);
 	sz = sizeof(gsname);
-	rc = sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
+	rc = prog_sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
 			  SYSCTL_VERSION);
 	if (rc == -1) {
 		sysctlparseerror(namelen, l);
@@ -1538,7 +1538,7 @@ parse_describe(char *l)
 	memset(name, 0, sizeof(name));
 	namelen = sizeof(name) / sizeof(name[0]);
 	sz = sizeof(gsname);
-	rc = sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
+	rc = prog_sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
 			  SYSCTL_VERSION);
 	if (rc == -1) {
 		sysctlparseerror(namelen, l);
@@ -2266,7 +2266,7 @@ kern_cp_time(HANDLER_ARGS)
 
 	if (namelen == 2 && Aflag) {
 		sz = sizeof(n)

CVS commit: src/sbin/sysctl

2019-08-17 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Aug 18 04:10:22 UTC 2019

Modified Files:
src/sbin/sysctl: Makefile prog_ops.h sysctl.c sysctl_hostops.c
sysctl_rumpops.c

Log Message:
sysctl: Add indirection of symbols to remove clash with sanitizers

Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlbyname and sysctlgetmibinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/sysctl/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sbin/sysctl/prog_ops.h
cvs rdiff -u -r1.161 -r1.162 src/sbin/sysctl/sysctl.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/sysctl/sysctl_hostops.c \
src/sbin/sysctl/sysctl_rumpops.c

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



Re: CVS commit: src/sbin/sysctl

2012-12-06 Thread Christos Zoulas
On Dec 6, 11:48am, plu...@rya-online.net (Iain Hibbert) wrote:
-- Subject: Re: CVS commit: src/sbin/sysctl

| thats not a very helpful message, regarding the bug that was fixed..

And I am unhappy enough with the API I introduced to consider removing
it...

christos


Re: CVS commit: src/sbin/sysctl

2012-12-06 Thread Iain Hibbert
On Wed, 5 Dec 2012, Christos Zoulas wrote:

> Module Name:  src
> Committed By: christos
> Date: Wed Dec  5 13:53:39 UTC 2012
>
> Modified Files:
>   src/sbin/sysctl: sysctl.c
>
> Log Message:
> fix bug found by clang.

thats not a very helpful message, regarding the bug that was fixed..

iain