svn commit: r311716 - in projects/bsnmp-ipv6-mib: bin/chmod contrib/llvm/projects/libunwind/src contrib/ngatm/snmp_atm lib/libc/include lib/libc/stdlib lib/libprocstat lib/libstand lib/libutil sbin...

Ngie Cooper ngie at FreeBSD.org
Mon Jan 9 01:00:24 UTC 2017


Author: ngie
Date: Mon Jan  9 01:00:20 2017
New Revision: 311716
URL: https://svnweb.freebsd.org/changeset/base/311716

Log:
  MFhead at r311715

Added:
  projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit_impl.c
     - copied unchanged from r311715, head/lib/libc/stdlib/cxa_thread_atexit_impl.c
  projects/bsnmp-ipv6-mib/sys/net80211/ieee80211_vht.c
     - copied unchanged from r311715, head/sys/net80211/ieee80211_vht.c
  projects/bsnmp-ipv6-mib/sys/net80211/ieee80211_vht.h
     - copied unchanged from r311715, head/sys/net80211/ieee80211_vht.h
Modified:
  projects/bsnmp-ipv6-mib/bin/chmod/chmod.1
  projects/bsnmp-ipv6-mib/bin/chmod/chmod.c
  projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S
  projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S
  projects/bsnmp-ipv6-mib/contrib/ngatm/snmp_atm/snmp_atm.c
  projects/bsnmp-ipv6-mib/lib/libc/include/libc_private.h
  projects/bsnmp-ipv6-mib/lib/libc/stdlib/Makefile.inc
  projects/bsnmp-ipv6-mib/lib/libc/stdlib/Symbol.map
  projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit.c
  projects/bsnmp-ipv6-mib/lib/libprocstat/cd9660.c
  projects/bsnmp-ipv6-mib/lib/libprocstat/libprocstat.c
  projects/bsnmp-ipv6-mib/lib/libstand/bootp.c
  projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getallproc.c
  projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getfile.c
  projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getproc.c
  projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getvmmap.c
  projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.8
  projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.c
  projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.h
  projects/bsnmp-ipv6-mib/sbin/camcontrol/modeedit.c
  projects/bsnmp-ipv6-mib/sbin/md5/md5.1
  projects/bsnmp-ipv6-mib/share/misc/pci_vendors
  projects/bsnmp-ipv6-mib/share/misc/scsi_modes
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl.c
  projects/bsnmp-ipv6-mib/sys/cam/scsi/scsi_all.c
  projects/bsnmp-ipv6-mib/sys/cam/scsi/scsi_all.h
  projects/bsnmp-ipv6-mib/sys/cam/scsi/scsi_ch.c
  projects/bsnmp-ipv6-mib/sys/conf/files
  projects/bsnmp-ipv6-mib/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
  projects/bsnmp-ipv6-mib/sys/contrib/dev/acpica/components/tables/tbxface.c
  projects/bsnmp-ipv6-mib/sys/contrib/dev/acpica/include/acpixf.h
  projects/bsnmp-ipv6-mib/sys/crypto/skein/amd64/skein_block_asm.s
  projects/bsnmp-ipv6-mib/sys/dev/cxgbe/tom/t4_connect.c
  projects/bsnmp-ipv6-mib/sys/dev/cxgbe/tom/t4_listen.c
  projects/bsnmp-ipv6-mib/sys/dev/cxgbe/tom/t4_tom.c
  projects/bsnmp-ipv6-mib/sys/dev/cxgbe/tom/t4_tom.h
  projects/bsnmp-ipv6-mib/sys/dev/etherswitch/etherswitch.c
  projects/bsnmp-ipv6-mib/sys/dev/gpio/gpioc.c
  projects/bsnmp-ipv6-mib/sys/dev/gpio/ofw_gpiobus.c
  projects/bsnmp-ipv6-mib/sys/dev/kbd/kbd.c
  projects/bsnmp-ipv6-mib/sys/dev/mmc/mmcreg.h
  projects/bsnmp-ipv6-mib/sys/dev/rtwn/if_rtwnvar.h
  projects/bsnmp-ipv6-mib/sys/dev/rtwn/usb/rtwn_usb_attach.c
  projects/bsnmp-ipv6-mib/sys/dev/rtwn/usb/rtwn_usb_ep.c
  projects/bsnmp-ipv6-mib/sys/dev/rtwn/usb/rtwn_usb_rx.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci.h
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci_if.m
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/ef10_tx.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/efx.h
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/efx_tx.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/hunt_nic.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/medford_nic.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/common/siena_nic.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/sfxge.h
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/sfxge_port.c
  projects/bsnmp-ipv6-mib/sys/dev/sfxge/sfxge_tx.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_lookup.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_node.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_node.h
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_rrip.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_vfsops.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/cd9660_vnops.c
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/iso.h
  projects/bsnmp-ipv6-mib/sys/fs/cd9660/iso_rrip.h
  projects/bsnmp-ipv6-mib/sys/geom/vinum/geom_vinum_state.c
  projects/bsnmp-ipv6-mib/sys/modules/wlan/Makefile
  projects/bsnmp-ipv6-mib/sys/net80211/ieee80211_scan.c
  projects/bsnmp-ipv6-mib/sys/net80211/ieee80211_var.h
  projects/bsnmp-ipv6-mib/sys/netinet6/nd6.c
  projects/bsnmp-ipv6-mib/sys/netipsec/ipsec.c
  projects/bsnmp-ipv6-mib/sys/powerpc/include/vmparam.h
  projects/bsnmp-ipv6-mib/sys/sys/unistd.h
  projects/bsnmp-ipv6-mib/usr.bin/top/machine.c
  projects/bsnmp-ipv6-mib/usr.bin/users/users.cc
  projects/bsnmp-ipv6-mib/usr.sbin/bhyve/ps2mouse.c   (contents, props changed)
  projects/bsnmp-ipv6-mib/usr.sbin/bhyve/virtio.h
  projects/bsnmp-ipv6-mib/usr.sbin/chown/chgrp.1
  projects/bsnmp-ipv6-mib/usr.sbin/chown/chown.8
  projects/bsnmp-ipv6-mib/usr.sbin/chown/chown.c
  projects/bsnmp-ipv6-mib/usr.sbin/route6d/route6d.c
  projects/bsnmp-ipv6-mib/usr.sbin/rwhod/rwhod.c
Directory Properties:
  projects/bsnmp-ipv6-mib/   (props changed)
  projects/bsnmp-ipv6-mib/contrib/llvm/   (props changed)
  projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/   (props changed)
  projects/bsnmp-ipv6-mib/sys/contrib/dev/acpica/   (props changed)

Modified: projects/bsnmp-ipv6-mib/bin/chmod/chmod.1
==============================================================================
--- projects/bsnmp-ipv6-mib/bin/chmod/chmod.1	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/bin/chmod/chmod.1	Mon Jan  9 01:00:20 2017	(r311716)
@@ -32,7 +32,7 @@
 .\"	@(#)chmod.1	8.4 (Berkeley) 3/31/94
 .\" $FreeBSD$
 .\"
-.Dd April 20, 2015
+.Dd January 7, 2017
 .Dt CHMOD 1
 .Os
 .Sh NAME
@@ -106,6 +106,16 @@ option is specified.
 In addition, these options override each other and the
 command's actions are determined by the last one specified.
 .Pp
+If
+.Nm
+receives a
+.Dv SIGINFO
+signal (see the
+.Cm status
+argument for
+.Xr stty 1 ) ,
+then the current filename as well as the old and new modes are displayed.
+.Pp
 Only the owner of a file or the super-user is permitted to change
 the mode of a file.
 .Sh EXIT STATUS

Modified: projects/bsnmp-ipv6-mib/bin/chmod/chmod.c
==============================================================================
--- projects/bsnmp-ipv6-mib/bin/chmod/chmod.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/bin/chmod/chmod.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -49,14 +49,24 @@ __FBSDID("$FreeBSD$");
 #include <fcntl.h>
 #include <fts.h>
 #include <limits.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+static volatile sig_atomic_t siginfo;
+
 static void usage(void);
 static int may_have_nfs4acl(const FTSENT *ent, int hflag);
 
+static void
+siginfo_handler(int sig __unused)
+{
+
+	siginfo = 1;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -125,6 +135,8 @@ done:	argv += optind;
 	if (argc < 2)
 		usage();
 
+	(void)signal(SIGINFO, siginfo_handler);
+
 	if (Rflag) {
 		if (hflag)
 			errx(1, "the -R and -h options may not be "
@@ -192,10 +204,10 @@ done:	argv += optind;
 		    && !fflag) {
 			warn("%s", p->fts_path);
 			rval = 1;
-		} else if (vflag) {
+		} else if (vflag || siginfo) {
 			(void)printf("%s", p->fts_path);
 
-			if (vflag > 1) {
+			if (vflag > 1 || siginfo) {
 				char m1[12], m2[12];
 
 				strmode(p->fts_statp->st_mode, m1);
@@ -207,6 +219,7 @@ done:	argv += optind;
 				    newmode, m2);
 			}
 			(void)printf("\n");
+			siginfo = 0;
 		}
 	}
 	if (errno)

Modified: projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S	Mon Jan  9 01:00:20 2017	(r311716)
@@ -527,3 +527,5 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   ret                       // jump to ra
 
 #endif
+
+  .section .note.GNU-stack,"", at progbits

Modified: projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S	Mon Jan  9 01:00:20 2017	(r311716)
@@ -469,3 +469,5 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
 /* RISCVTODO */
 
 #endif
+
+    .section .note.GNU-stack,"", at progbits

Modified: projects/bsnmp-ipv6-mib/contrib/ngatm/snmp_atm/snmp_atm.c
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/ngatm/snmp_atm/snmp_atm.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/contrib/ngatm/snmp_atm/snmp_atm.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -170,7 +170,7 @@ atmif_check_carrier(struct atmif_priv *a
 		aif->pub.carrier = ATMIF_CARRIER_UNKNOWN;
 		return;
 	}
-	if (!ifmr.ifm_status & IFM_AVALID) {
+	if (!(ifmr.ifm_status & IFM_AVALID)) {
 		aif->pub.carrier = ATMIF_CARRIER_UNKNOWN;
 		return;
 	}

Modified: projects/bsnmp-ipv6-mib/lib/libc/include/libc_private.h
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libc/include/libc_private.h	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libc/include/libc_private.h	Mon Jan  9 01:00:20 2017	(r311716)
@@ -272,6 +272,8 @@ void _malloc_thread_cleanup(void);
  * thread is exiting, so its thread-local dtors should be called.
  */
 void __cxa_thread_call_dtors(void);
+int __cxa_thread_atexit_hidden(void (*dtor_func)(void *), void *obj,
+    void *dso_symbol) __hidden;
 
 /*
  * These functions are used by the threading libraries in order to protect

Modified: projects/bsnmp-ipv6-mib/lib/libc/stdlib/Makefile.inc
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libc/stdlib/Makefile.inc	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libc/stdlib/Makefile.inc	Mon Jan  9 01:00:20 2017	(r311716)
@@ -5,7 +5,9 @@
 .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib ${LIBC_SRCTOP}/stdlib
 
 MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
-	bsearch.c cxa_thread_atexit.c div.c exit.c getenv.c getopt.c getopt_long.c \
+	bsearch.c \
+	cxa_thread_atexit.c cxa_thread_atexit_impl.c \
+	div.c exit.c getenv.c getopt.c getopt_long.c \
 	getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
 	hsearch_r.c imaxabs.c imaxdiv.c \
 	insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \

Modified: projects/bsnmp-ipv6-mib/lib/libc/stdlib/Symbol.map
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libc/stdlib/Symbol.map	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libc/stdlib/Symbol.map	Mon Jan  9 01:00:20 2017	(r311716)
@@ -118,6 +118,7 @@ FBSD_1.4 {
 
 FBSD_1.5 {
 	__cxa_thread_atexit;
+	__cxa_thread_atexit_impl;
 };
 
 FBSDprivate_1.0 {

Modified: projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -1,7 +1,10 @@
 /*-
- * Copyright (c) 2016 Mahdi Mokhtari <mokhi64 at gmail.com>
+ * Copyright (c) 2017 The FreeBSD Foundation
  * All rights reserved.
  *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -27,114 +30,11 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/queue.h>
-#include "namespace.h"
-#include <errno.h>
-#include <link.h>
-#include <pthread.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "un-namespace.h"
 #include "libc_private.h"
 
-/*
- * C++11 introduces the thread_local scope (like __thread with some
- * additions).  As a key-feature it should support non-trivial
- * destructors, registered with __cxa_thread_atexit() to be executed
- * at the thread termination.
- *
- * The implemention keeps a _Thread_local list of destructors per each
- * thread, and calls __cxa_thread_call_dtors() on each thread's exit
- * to do cleanup.  For a thread calling exit(3), in particular, for
- * the initial thread returning from main(), we call
- * __cxa_thread_call_dtors() inside exit().
- *
- * It could be possible that a dynamically loaded library, use
- * thread_local variable but is dlclose()'d before thread exit.  The
- * destructor of this variable will then try to access the address,
- * for calling it but it's unloaded, so it'll crash.  We're using
- * __elf_phdr_match_addr() to detect and prevent such cases and so
- * prevent the crash.
- */
-
-#define CXA_DTORS_ITERATIONS 4
-
-struct cxa_thread_dtor {
-	void *obj;
-	void (*func)(void *);
-	void *dso;
-	LIST_ENTRY(cxa_thread_dtor) entry;
-};
-static _Thread_local LIST_HEAD(dtor_list, cxa_thread_dtor) dtors =
-    LIST_HEAD_INITIALIZER(dtors);
-
 int
 __cxa_thread_atexit(void (*dtor_func)(void *), void *obj, void *dso_symbol)
 {
-	struct cxa_thread_dtor *new_dtor;
-
-	new_dtor = malloc(sizeof(*new_dtor));
-	if (new_dtor == NULL) {
-		errno = ENOMEM; /* forcibly override malloc(3) error */
-		return (-1);
-	}
-
-	new_dtor->obj = obj;
-	new_dtor->func = dtor_func;
-	new_dtor->dso = dso_symbol;
-	LIST_INSERT_HEAD(&dtors, new_dtor, entry);
-	return (0);
-}
-
-static void
-walk_cb_call(struct cxa_thread_dtor *dtor)
-{
-	struct dl_phdr_info phdr_info;
-
-	if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
-	    __elf_phdr_match_addr(&phdr_info, dtor->func))
-		dtor->func(dtor->obj);
-	else
-		fprintf(stderr, "__cxa_thread_call_dtors: dtr %p from "
-		    "unloaded dso, skipping\n", (void *)(dtor->func));
-}
-
-static void
-walk_cb_nocall(struct cxa_thread_dtor *dtor __unused)
-{
-}
-
-static void
-cxa_thread_walk(void (*cb)(struct cxa_thread_dtor *))
-{
-	struct cxa_thread_dtor *dtor, *tdtor;
-
-	LIST_FOREACH_SAFE(dtor, &dtors, entry, tdtor) {
-		LIST_REMOVE(dtor, entry);
-		cb(dtor);
-		free(dtor);
-	}
-}
-
-/*
- * This is the callback function we use to call destructors, once for
- * each thread.  It is called in exit(3) in libc/stdlib/exit.c and
- * before exit_thread() in libthr/thread/thr_exit.c.
- */
-void
-__cxa_thread_call_dtors(void)
-{
-	int i;
-
-	for (i = 0; i < CXA_DTORS_ITERATIONS && !LIST_EMPTY(&dtors); i++)
-		cxa_thread_walk(walk_cb_call);
 
-	if (!LIST_EMPTY(&dtors)) {
-		fprintf(stderr, "Thread %p is exiting with more "
-		    "thread-specific dtors created after %d iterations "
-		    "of destructor calls\n",
-		    _pthread_self(), i);
-		cxa_thread_walk(walk_cb_nocall);
-	}
+	return (__cxa_thread_atexit_hidden(dtor_func, obj, dso_symbol));
 }

Copied: projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit_impl.c (from r311715, head/lib/libc/stdlib/cxa_thread_atexit_impl.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/bsnmp-ipv6-mib/lib/libc/stdlib/cxa_thread_atexit_impl.c	Mon Jan  9 01:00:20 2017	(r311716, copy of r311715, head/lib/libc/stdlib/cxa_thread_atexit_impl.c)
@@ -0,0 +1,153 @@
+/*-
+ * Copyright (c) 2016 Mahdi Mokhtari <mokhi64 at gmail.com>
+ * Copyright (c) 2016, 2017 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/queue.h>
+#include "namespace.h"
+#include <errno.h>
+#include <link.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+/*
+ * C++11 introduces the thread_local scope (like __thread with some
+ * additions).  As a key-feature it should support non-trivial
+ * destructors, registered with __cxa_thread_atexit() to be executed
+ * at the thread termination.
+ *
+ * The implemention keeps a _Thread_local list of destructors per each
+ * thread, and calls __cxa_thread_call_dtors() on each thread's exit
+ * to do cleanup.  For a thread calling exit(3), in particular, for
+ * the initial thread returning from main(), we call
+ * __cxa_thread_call_dtors() inside exit().
+ *
+ * It could be possible that a dynamically loaded library, use
+ * thread_local variable but is dlclose()'d before thread exit.  The
+ * destructor of this variable will then try to access the address,
+ * for calling it but it's unloaded, so it'll crash.  We're using
+ * __elf_phdr_match_addr() to detect and prevent such cases and so
+ * prevent the crash.
+ */
+
+#define CXA_DTORS_ITERATIONS 4
+
+struct cxa_thread_dtor {
+	void *obj;
+	void (*func)(void *);
+	void *dso;
+	LIST_ENTRY(cxa_thread_dtor) entry;
+};
+static _Thread_local LIST_HEAD(dtor_list, cxa_thread_dtor) dtors =
+    LIST_HEAD_INITIALIZER(dtors);
+
+int
+__cxa_thread_atexit_impl(void (*dtor_func)(void *), void *obj,
+    void *dso_symbol)
+{
+
+	return (__cxa_thread_atexit_hidden(dtor_func, obj, dso_symbol));
+}
+
+int
+__cxa_thread_atexit_hidden(void (*dtor_func)(void *), void *obj,
+    void *dso_symbol)
+{
+	struct cxa_thread_dtor *new_dtor;
+
+	new_dtor = malloc(sizeof(*new_dtor));
+	if (new_dtor == NULL) {
+		errno = ENOMEM; /* forcibly override malloc(3) error */
+		return (-1);
+	}
+
+	new_dtor->obj = obj;
+	new_dtor->func = dtor_func;
+	new_dtor->dso = dso_symbol;
+	LIST_INSERT_HEAD(&dtors, new_dtor, entry);
+	return (0);
+}
+
+static void
+walk_cb_call(struct cxa_thread_dtor *dtor)
+{
+	struct dl_phdr_info phdr_info;
+
+	if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
+	    __elf_phdr_match_addr(&phdr_info, dtor->func))
+		dtor->func(dtor->obj);
+	else
+		fprintf(stderr, "__cxa_thread_call_dtors: dtr %p from "
+		    "unloaded dso, skipping\n", (void *)(dtor->func));
+}
+
+static void
+walk_cb_nocall(struct cxa_thread_dtor *dtor __unused)
+{
+}
+
+static void
+cxa_thread_walk(void (*cb)(struct cxa_thread_dtor *))
+{
+	struct cxa_thread_dtor *dtor, *tdtor;
+
+	LIST_FOREACH_SAFE(dtor, &dtors, entry, tdtor) {
+		LIST_REMOVE(dtor, entry);
+		cb(dtor);
+		free(dtor);
+	}
+}
+
+/*
+ * This is the callback function we use to call destructors, once for
+ * each thread.  It is called in exit(3) in libc/stdlib/exit.c and
+ * before exit_thread() in libthr/thread/thr_exit.c.
+ */
+void
+__cxa_thread_call_dtors(void)
+{
+	int i;
+
+	for (i = 0; i < CXA_DTORS_ITERATIONS && !LIST_EMPTY(&dtors); i++)
+		cxa_thread_walk(walk_cb_call);
+
+	if (!LIST_EMPTY(&dtors)) {
+		fprintf(stderr, "Thread %p is exiting with more "
+		    "thread-specific dtors created after %d iterations "
+		    "of destructor calls\n",
+		    _pthread_self(), i);
+		cxa_thread_walk(walk_cb_nocall);
+	}
+}

Modified: projects/bsnmp-ipv6-mib/lib/libprocstat/cd9660.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libprocstat/cd9660.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libprocstat/cd9660.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -53,10 +53,10 @@ __FBSDID("$FreeBSD$");
 
 #include <err.h>
 
-#include <isofs/cd9660/cd9660_node.h>
 #define _KERNEL
 #include <isofs/cd9660/iso.h>
 #undef _KERNEL
+#include <isofs/cd9660/cd9660_node.h>
 
 #include <kvm.h>
 #include <stdio.h>

Modified: projects/bsnmp-ipv6-mib/lib/libprocstat/libprocstat.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libprocstat/libprocstat.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libprocstat/libprocstat.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -282,7 +282,7 @@ procstat_getprocs(struct procstat *procs
 		name[1] = KERN_PROC;
 		name[2] = what;
 		name[3] = arg;
-		error = sysctl(name, 4, NULL, &len, NULL, 0);
+		error = sysctl(name, nitems(name), NULL, &len, NULL, 0);
 		if (error < 0 && errno != EPERM) {
 			warn("sysctl(kern.proc)");
 			goto fail;
@@ -299,7 +299,7 @@ procstat_getprocs(struct procstat *procs
 				goto fail;
 			}
 			olen = len;
-			error = sysctl(name, 4, p, &len, NULL, 0);
+			error = sysctl(name, nitems(name), p, &len, NULL, 0);
 		} while (error < 0 && errno == ENOMEM && olen == len);
 		if (error < 0 && errno != EPERM) {
 			warn("sysctl(kern.proc)");
@@ -1760,7 +1760,7 @@ getargv(struct procstat *procstat, struc
 		name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
 		name[3] = kp->ki_pid;
 		len = nchr;
-		error = sysctl(name, 4, av->buf, &len, NULL, 0);
+		error = sysctl(name, nitems(name), av->buf, &len, NULL, 0);
 		if (error != 0 && errno != ESRCH && errno != EPERM)
 			warn("sysctl(kern.proc.%s)", env ? "env" : "args");
 		if (error != 0 || len == 0)
@@ -1983,7 +1983,7 @@ procstat_getgroups_sysctl(pid_t pid, uns
 		warn("malloc(%zu)", len);
 		return (NULL);
 	}
-	if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
+	if (sysctl(mib, nitems(mib), groups, &len, NULL, 0) == -1) {
 		warn("sysctl: kern.proc.groups: %d", pid);
 		free(groups);
 		return (NULL);
@@ -2059,7 +2059,7 @@ procstat_getumask_sysctl(pid_t pid, unsi
 	mib[2] = KERN_PROC_UMASK;
 	mib[3] = pid;
 	len = sizeof(*maskp);
-	error = sysctl(mib, 4, maskp, &len, NULL, 0);
+	error = sysctl(mib, nitems(mib), maskp, &len, NULL, 0);
 	if (error != 0 && errno != ESRCH && errno != EPERM)
 		warn("sysctl: kern.proc.umask: %d", pid);
 	return (error);
@@ -2139,7 +2139,7 @@ procstat_getrlimit_sysctl(pid_t pid, int
 	name[3] = pid;
 	name[4] = which;
 	len = sizeof(struct rlimit);
-	error = sysctl(name, 5, rlimit, &len, NULL, 0);
+	error = sysctl(name, nitems(name), rlimit, &len, NULL, 0);
 	if (error < 0 && errno != ESRCH) {
 		warn("sysctl: kern.proc.rlimit: %d", pid);
 		return (-1);
@@ -2201,7 +2201,7 @@ procstat_getpathname_sysctl(pid_t pid, c
 	name[2] = KERN_PROC_PATHNAME;
 	name[3] = pid;
 	len = maxlen;
-	error = sysctl(name, 4, pathname, &len, NULL, 0);
+	error = sysctl(name, nitems(name), pathname, &len, NULL, 0);
 	if (error != 0 && errno != ESRCH)
 		warn("sysctl: kern.proc.pathname: %d", pid);
 	if (len == 0)
@@ -2281,7 +2281,7 @@ procstat_getosrel_sysctl(pid_t pid, int 
 	name[2] = KERN_PROC_OSREL;
 	name[3] = pid;
 	len = sizeof(*osrelp);
-	error = sysctl(name, 4, osrelp, &len, NULL, 0);
+	error = sysctl(name, nitems(name), osrelp, &len, NULL, 0);
 	if (error != 0 && errno != ESRCH)
 		warn("sysctl: kern.proc.osrel: %d", pid);
 	return (error);
@@ -2341,7 +2341,7 @@ is_elf32_sysctl(pid_t pid)
 	name[2] = KERN_PROC_SV_NAME;
 	name[3] = pid;
 	len = sizeof(sv_name);
-	error = sysctl(name, 4, sv_name, &len, NULL, 0);
+	error = sysctl(name, nitems(name), sv_name, &len, NULL, 0);
 	if (error != 0 || len == 0)
 		return (0);
 	for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
@@ -2372,7 +2372,7 @@ procstat_getauxv32_sysctl(pid_t pid, uns
 		warn("malloc(%zu)", len);
 		goto out;
 	}
-	if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), auxv32, &len, NULL, 0) == -1) {
 		if (errno != ESRCH && errno != EPERM)
 			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
 		goto out;
@@ -2421,7 +2421,7 @@ procstat_getauxv_sysctl(pid_t pid, unsig
 		warn("malloc(%zu)", len);
 		return (NULL);
 	}
-	if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), auxv, &len, NULL, 0) == -1) {
 		if (errno != ESRCH && errno != EPERM)
 			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
 		free(auxv);
@@ -2482,7 +2482,7 @@ procstat_getkstack_sysctl(pid_t pid, int
 	name[3] = pid;
 
 	len = 0;
-	error = sysctl(name, 4, NULL, &len, NULL, 0);
+	error = sysctl(name, nitems(name), NULL, &len, NULL, 0);
 	if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
 		warn("sysctl: kern.proc.kstack: %d", pid);
 		return (NULL);
@@ -2499,7 +2499,7 @@ procstat_getkstack_sysctl(pid_t pid, int
 		warn("malloc(%zu)", len);
 		return (NULL);
 	}
-	if (sysctl(name, 4, kkstp, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), kkstp, &len, NULL, 0) == -1) {
 		warn("sysctl: kern.proc.pid: %d", pid);
 		free(kkstp);
 		return (NULL);

Modified: projects/bsnmp-ipv6-mib/lib/libstand/bootp.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libstand/bootp.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libstand/bootp.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -62,8 +62,6 @@ __FBSDID("$FreeBSD$");
 
 struct in_addr servip;
 
-static n_long	nmask, smask;
-
 static time_t	bot;
 
 static	char vm_rfc1048[4] = VM_RFC1048;
@@ -223,30 +221,19 @@ bootp(sock, flag)
 	bcopy(rbuf.rbootp.bp_file, bootfile, sizeof(bootfile));
 	bootfile[sizeof(bootfile) - 1] = '\0';
 
-	if (IN_CLASSA(ntohl(myip.s_addr)))
-		nmask = htonl(IN_CLASSA_NET);
-	else if (IN_CLASSB(ntohl(myip.s_addr)))
-		nmask = htonl(IN_CLASSB_NET);
-	else
-		nmask = htonl(IN_CLASSC_NET);
-#ifdef BOOTP_DEBUG
-	if (debug)
-		printf("'native netmask' is %s\n", intoa(nmask));
-#endif
-
-	/* Check subnet mask against net mask; toss if bogus */
-	if ((nmask & smask) != nmask) {
+	if (!netmask) {
+		if (IN_CLASSA(ntohl(myip.s_addr)))
+			netmask = htonl(IN_CLASSA_NET);
+		else if (IN_CLASSB(ntohl(myip.s_addr)))
+			netmask = htonl(IN_CLASSB_NET);
+		else
+			netmask = htonl(IN_CLASSC_NET);
 #ifdef BOOTP_DEBUG
 		if (debug)
-			printf("subnet mask (%s) bad\n", intoa(smask));
+			printf("'native netmask' is %s\n", intoa(netmask));
 #endif
-		smask = 0;
 	}
 
-	/* Get subnet (or natural net) mask */
-	netmask = nmask;
-	if (smask)
-		netmask = smask;
 #ifdef BOOTP_DEBUG
 	if (debug)
 		printf("mask: %s\n", intoa(netmask));
@@ -385,7 +372,7 @@ vend_rfc1048(cp, len)
 			break;
 
 		if (tag == TAG_SUBNET_MASK) {
-			bcopy(cp, &smask, sizeof(smask));
+			bcopy(cp, &netmask, sizeof(netmask));
 		}
 		if (tag == TAG_GATEWAY) {
 			bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr));
@@ -445,7 +432,7 @@ vend_cmu(cp)
 	vp = (struct cmu_vend *)cp;
 
 	if (vp->v_smask.s_addr != 0) {
-		smask = vp->v_smask.s_addr;
+		netmask = vp->v_smask.s_addr;
 	}
 	if (vp->v_dgate.s_addr != 0) {
 		gateip = vp->v_dgate;

Modified: projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getallproc.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getallproc.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getallproc.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -31,8 +31,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/user.h>
 #include <sys/sysctl.h>
+#include <sys/user.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -75,14 +75,14 @@ kinfo_getallproc(int *cntp)
 	mib[2] = KERN_PROC_PROC;
 
 	len = 0;
-	if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0)
+	if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) < 0)
 		return (NULL);
 
 	kipp = malloc(len);
 	if (kipp == NULL)
 		return (NULL);
 
-	if (sysctl(mib, 3, kipp, &len, NULL, 0) < 0)
+	if (sysctl(mib, nitems(mib), kipp, &len, NULL, 0) < 0)
 		goto bad;
 	if (len % sizeof(*kipp) != 0)
 		goto bad;

Modified: projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getfile.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getfile.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getfile.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -2,8 +2,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/user.h>
 #include <sys/sysctl.h>
+#include <sys/user.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -26,14 +26,14 @@ kinfo_getfile(pid_t pid, int *cntp)
 	mib[2] = KERN_PROC_FILEDESC;
 	mib[3] = pid;
 
-	error = sysctl(mib, 4, NULL, &len, NULL, 0);
+	error = sysctl(mib, nitems(mib), NULL, &len, NULL, 0);
 	if (error)
 		return (NULL);
 	len = len * 4 / 3;
 	buf = malloc(len);
 	if (buf == NULL)
 		return (NULL);
-	error = sysctl(mib, 4, buf, &len, NULL, 0);
+	error = sysctl(mib, nitems(mib), buf, &len, NULL, 0);
 	if (error) {
 		free(buf);
 		return (NULL);

Modified: projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getproc.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getproc.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getproc.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -30,8 +30,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/user.h>
 #include <sys/sysctl.h>
+#include <sys/user.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -49,14 +49,14 @@ kinfo_getproc(pid_t pid)
 	mib[1] = KERN_PROC;
 	mib[2] = KERN_PROC_PID;
 	mib[3] = pid;
-	if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+	if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) < 0)
 		return (NULL);
 
 	kipp = malloc(len);
 	if (kipp == NULL)
 		return (NULL);
 
-	if (sysctl(mib, 4, kipp, &len, NULL, 0) < 0)
+	if (sysctl(mib, nitems(mib), kipp, &len, NULL, 0) < 0)
 		goto bad;
 	if (len != sizeof(*kipp))
 		goto bad;

Modified: projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getvmmap.c
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getvmmap.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/lib/libutil/kinfo_getvmmap.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -2,8 +2,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/user.h>
 #include <sys/sysctl.h>
+#include <sys/user.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -26,14 +26,14 @@ kinfo_getvmmap(pid_t pid, int *cntp)
 	mib[2] = KERN_PROC_VMMAP;
 	mib[3] = pid;
 
-	error = sysctl(mib, 4, NULL, &len, NULL, 0);
+	error = sysctl(mib, nitems(mib), NULL, &len, NULL, 0);
 	if (error)
 		return (NULL);
 	len = len * 4 / 3;
 	buf = malloc(len);
 	if (buf == NULL)
 		return (NULL);
-	error = sysctl(mib, 4, buf, &len, NULL, 0);
+	error = sysctl(mib, nitems(mib), buf, &len, NULL, 0);
 	if (error) {
 		free(buf);
 		return (NULL);

Modified: projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.8
==============================================================================
--- projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.8	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.8	Mon Jan  9 01:00:20 2017	(r311716)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 30, 2016
+.Dd January 6, 2017
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -121,7 +121,7 @@
 .Ic modepage
 .Op device id
 .Op generic args
-.Aq Fl m Ar page | Fl l
+.Aq Fl m Ar page[,subpage] | Fl l
 .Op Fl P Ar pgctl
 .Op Fl b | Fl e
 .Op Fl d
@@ -702,9 +702,10 @@ The editor will be invoked if
 detects that standard input is terminal.
 .It Fl l
 Lists all available mode pages.
-.It Fl m Ar mode_page
-This specifies the number of the mode page the user would like to view
-and/or edit.
+If specified more then once, also lists subpages.
+.It Fl m Ar page[,subpage]
+This specifies the number of the mode page and optionally subpage the user
+would like to view and/or edit.
 This argument is mandatory unless
 .Fl l
 is specified.

Modified: projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.c
==============================================================================
--- projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -125,12 +125,9 @@ typedef enum {
 	CAM_ARG_GET_STDINQ	= 0x00002000,
 	CAM_ARG_GET_XFERRATE	= 0x00004000,
 	CAM_ARG_INQ_MASK	= 0x00007000,
-	CAM_ARG_MODE_EDIT	= 0x00008000,
-	CAM_ARG_PAGE_CNTL	= 0x00010000,
 	CAM_ARG_TIMEOUT		= 0x00020000,
 	CAM_ARG_CMD_IN		= 0x00040000,
 	CAM_ARG_CMD_OUT		= 0x00080000,
-	CAM_ARG_DBD		= 0x00100000,
 	CAM_ARG_ERR_RECOVER	= 0x00200000,
 	CAM_ARG_RETRIES		= 0x00400000,
 	CAM_ARG_START_UNIT	= 0x00800000,
@@ -3987,8 +3984,8 @@ reassignblocks(struct cam_device *device
 
 #ifndef MINIMALISTIC
 void
-mode_sense(struct cam_device *device, int mode_page, int page_control,
-	   int dbd, int retry_count, int timeout, u_int8_t *data, int datalen)
+mode_sense(struct cam_device *device, int dbd, int pc, int page, int subpage,
+	   int retry_count, int timeout, u_int8_t *data, int datalen)
 {
 	union ccb *ccb;
 	int retval;
@@ -4000,15 +3997,17 @@ mode_sense(struct cam_device *device, in
 
 	CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio);
 
-	scsi_mode_sense(&ccb->csio,
+	scsi_mode_sense_subpage(&ccb->csio,
 			/* retries */ retry_count,
 			/* cbfcnp */ NULL,
 			/* tag_action */ MSG_SIMPLE_Q_TAG,
 			/* dbd */ dbd,
-			/* page_code */ page_control << 6,
-			/* page */ mode_page,
+			/* pc */ pc << 6,
+			/* page */ page,
+			/* subpage */ subpage,
 			/* param_buf */ data,
 			/* param_len */ datalen,
+			/* minimum_cmd_size */ 0,
 			/* sense_len */ SSD_FULL_SIZE,
 			/* timeout */ timeout ? timeout : 5000);
 
@@ -4089,8 +4088,9 @@ void
 modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
 	 int retry_count, int timeout)
 {
-	int c, mode_page = -1, page_control = 0;
-	int binary = 0, list = 0;
+	char *str_subpage;
+	int c, page = -1, subpage = -1, pc = 0;
+	int binary = 0, dbd = 0, edit = 0, list = 0;
 
 	while ((c = getopt(argc, argv, combinedopt)) != -1) {
 		switch(c) {
@@ -4098,40 +4098,44 @@ modepage(struct cam_device *device, int 
 			binary = 1;
 			break;
 		case 'd':
-			arglist |= CAM_ARG_DBD;
+			dbd = 1;
 			break;
 		case 'e':
-			arglist |= CAM_ARG_MODE_EDIT;
+			edit = 1;
 			break;
 		case 'l':
-			list = 1;
+			list++;
 			break;
 		case 'm':
-			mode_page = strtol(optarg, NULL, 0);
-			if (mode_page < 0)
-				errx(1, "invalid mode page %d", mode_page);
+			str_subpage = optarg;
+			strsep(&str_subpage, ",");
+			page = strtol(optarg, NULL, 0);
+			if (str_subpage)
+			    subpage = strtol(str_subpage, NULL, 0);
+			else
+			    subpage = 0;
+			if (page < 0)
+				errx(1, "invalid mode page %d", page);
+			if (subpage < 0)
+				errx(1, "invalid mode subpage %d", subpage);
 			break;
 		case 'P':
-			page_control = strtol(optarg, NULL, 0);
-			if ((page_control < 0) || (page_control > 3))
-				errx(1, "invalid page control field %d",
-				     page_control);
-			arglist |= CAM_ARG_PAGE_CNTL;
+			pc = strtol(optarg, NULL, 0);
+			if ((pc < 0) || (pc > 3))
+				errx(1, "invalid page control field %d", pc);
 			break;
 		default:
 			break;
 		}
 	}
 
-	if (mode_page == -1 && list == 0)
+	if (page == -1 && list == 0)
 		errx(1, "you must specify a mode page!");
 
-	if (list) {
-		mode_list(device, page_control, arglist & CAM_ARG_DBD,
-		    retry_count, timeout);
+	if (list != 0) {
+		mode_list(device, dbd, pc, list > 1, retry_count, timeout);
 	} else {
-		mode_edit(device, mode_page, page_control,
-		    arglist & CAM_ARG_DBD, arglist & CAM_ARG_MODE_EDIT, binary,
+		mode_edit(device, dbd, pc, page, subpage, edit, binary,
 		    retry_count, timeout);
 	}
 }

Modified: projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.h
==============================================================================
--- projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.h	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/sbin/camcontrol/camcontrol.h	Mon Jan  9 01:00:20 2017	(r311716)
@@ -84,14 +84,14 @@ int epc(struct cam_device *device, int a
 int timestamp(struct cam_device *device, int argc, char **argv,
 	      char *combinedopt, int retry_count, int timeout,
 	      int verbosemode);
-void mode_sense(struct cam_device *device, int mode_page, int page_control,
-		int dbd, int retry_count, int timeout, u_int8_t *data,
+void mode_sense(struct cam_device *device, int dbd, int pc, int page,
+		int subpage, int retry_count, int timeout, uint8_t *data,
 		int datalen);
 void mode_select(struct cam_device *device, int save_pages, int retry_count,
 		 int timeout, u_int8_t *data, int datalen);
-void mode_edit(struct cam_device *device, int page, int page_control, int dbd,
+void mode_edit(struct cam_device *device, int dbd, int pc, int page, int subpage,
 	       int edit, int binary, int retry_count, int timeout);
-void mode_list(struct cam_device *device, int page_control, int dbd,
+void mode_list(struct cam_device *device, int dbd, int pc, int subpages,
 	       int retry_count, int timeout);
 int scsidoinquiry(struct cam_device *device, int argc, char **argv,
 		  char *combinedopt, int retry_count, int timeout);

Modified: projects/bsnmp-ipv6-mib/sbin/camcontrol/modeedit.c
==============================================================================
--- projects/bsnmp-ipv6-mib/sbin/camcontrol/modeedit.c	Mon Jan  9 00:54:18 2017	(r311715)
+++ projects/bsnmp-ipv6-mib/sbin/camcontrol/modeedit.c	Mon Jan  9 01:00:20 2017	(r311716)
@@ -66,9 +66,6 @@ __FBSDID("$FreeBSD$");
 #define	MODE_PAGE_HEADER(mh)						\
 	(struct scsi_mode_page_header *)find_mode_page_6(mh)
 
-#define	MODE_PAGE_DATA(mph)						\
-	(u_int8_t *)(mph) + sizeof(struct scsi_mode_page_header)
-
 
 struct editentry {
 	STAILQ_ENTRY(editentry) link;
@@ -86,7 +83,8 @@ static int editlist_changed = 0;	/* Whet
 
 struct pagename {
 	SLIST_ENTRY(pagename) link;
-	int pagenum;
+	int page;
+	int subpage;
 	char *name;
 };
 static SLIST_HEAD(, pagename) namelist;	/* Page number to name mappings. */
@@ -106,21 +104,22 @@ static int		 editentry_save(void *hook, 
 static struct editentry	*editentry_lookup(char *name);
 static int		 editentry_set(char *name, char *newvalue,
 				       int editonly);
-static void		 editlist_populate(struct cam_device *device,
-					   int modepage, int page_control,
-					   int dbd, int retries, int timeout);
-static void		 editlist_save(struct cam_device *device, int modepage,
-				       int page_control, int dbd, int retries,
-				       int timeout);
-static void		 nameentry_create(int pagenum, char *name);
-static struct pagename	*nameentry_lookup(int pagenum);
-static int		 load_format(const char *pagedb_path, int page);
+static void		 editlist_populate(struct cam_device *device, int dbd,
+					   int pc, int page, int subpage,
+					   int retries, int timeout);
+static void		 editlist_save(struct cam_device *device, int dbd,
+				       int pc, int page, int subpage,
+				       int retries, int timeout);
+static void		 nameentry_create(int page, int subpage, char *name);
+static struct pagename	*nameentry_lookup(int page, int subpage);
+static int		 load_format(const char *pagedb_path, int lpage,
+			    int lsubpage);
 static int		 modepage_write(FILE *file, int editonly);
 static int		 modepage_read(FILE *file);
 static void		 modepage_edit(void);
-static void		 modepage_dump(struct cam_device *device, int page,
-				       int page_control, int dbd, int retries,
-				       int timeout);
+static void		 modepage_dump(struct cam_device *device, int dbd,
+			    int pc, int page, int subpage, int retries,
+			    int timeout);
 static void		 cleanup_editfile(void);
 
 
@@ -325,10 +324,10 @@ editentry_set(char *name, char *newvalue
 }
 
 static void
-nameentry_create(int pagenum, char *name) {
+nameentry_create(int page, int subpage, char *name) {
 	struct pagename *newentry;
 
-	if (pagenum < 0 || name == NULL || name[0] == '\0')
+	if (page < 0 || subpage < 0 || name == NULL || name[0] == '\0')
 		return;
 
 	/* Allocate memory for the new entry and a copy of the entry name. */
@@ -339,16 +338,17 @@ nameentry_create(int pagenum, char *name
 	/* Trim any trailing whitespace for the page name. */
 	RTRIM(newentry->name);
 
-	newentry->pagenum = pagenum;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list