CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:21:13 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/compat/linux/common/linux_misc.c

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

Modified files:

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.243 src/sys/compat/linux/common/linux_misc.c:1.244
--- src/sys/compat/linux/common/linux_misc.c:1.243	Fri Aug 23 08:01:42 2019
+++ src/sys/compat/linux/common/linux_misc.c	Sat Aug 24 14:21:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.243 2019/08/23 08:01:42 maxv Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.244 2019/08/24 14:21:13 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.243 2019/08/23 08:01:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.244 2019/08/24 14:21:13 maxv Exp $");
 
 #include 
 #include 
@@ -240,7 +240,7 @@ linux_sys_wait4(struct lwp *l, const str
 # ifdef DIAGNOSTIC
 	if (linux_options & LINUX_WAIT4_WNOTHREAD)
 		printf("WARNING: %s: linux process %d.%d called "
-		   "waitpid with __WNOTHREAD set!",
+		   "waitpid with __WNOTHREAD set!\n",
 		   __FILE__, l->l_proc->p_pid, l->l_lid);
 
 # endif



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:21:13 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/compat/linux/common/linux_misc.c

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



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:18:43 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Fix memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/compat/linux/common/linux_socket.c

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

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.147 src/sys/compat/linux/common/linux_socket.c:1.148
--- src/sys/compat/linux/common/linux_socket.c:1.147	Sat Aug 24 14:08:35 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 14:18:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -546,6 +546,8 @@ linux_sys_sendmsg(struct lwp *l, const s
 
 case LINUX_SCM_CREDENTIALS:
 	/* no native equivalent, just drop it */
+	if (control != mtod(ctl_mbuf, void *))
+		free(control, M_MBUF);
 	m_free(ctl_mbuf);
 	ctl_mbuf = NULL;
 	msg.msg_control = NULL;



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:18:43 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Fix memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/compat/linux/common/linux_socket.c

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



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:08:35 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/compat/linux/common/linux_socket.c

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

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.146 src/sys/compat/linux/common/linux_socket.c:1.147
--- src/sys/compat/linux/common/linux_socket.c:1.146	Sat Aug 24 12:33:25 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 14:08:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -568,14 +568,15 @@ linux_sys_sendmsg(struct lwp *l, const s
 			/* Check the buffer is big enough */
 			if (__predict_false(cidx + cspace > clen)) {
 u_int8_t *nc;
+size_t nclen;
 
-clen = cidx + cspace;
-if (clen >= PAGE_SIZE) {
+nclen = cidx + cspace;
+if (nclen >= PAGE_SIZE) {
 	error = EINVAL;
 	goto done;
 }
 nc = realloc(clen <= MLEN ? NULL : control,
-		clen, M_TEMP, M_WAITOK);
+		nclen, M_TEMP, M_WAITOK);
 if (!nc) {
 	error = ENOMEM;
 	goto done;
@@ -584,6 +585,7 @@ linux_sys_sendmsg(struct lwp *l, const s
 	/* Old buffer was in mbuf... */
 	memcpy(nc, control, cidx);
 control = nc;
+clen = nclen;
 			}
 
 			/* Copy header */



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:08:35 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/compat/linux/common/linux_socket.c

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



CVS commit: src

2019-08-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Aug 24 13:20:52 UTC 2019

Modified Files:
src/lib/libnpf: Makefile
src/lib/npf: mod.mk
src/libexec/identd: Makefile
src/usr.sbin/npf/npfctl: Makefile
src/usr.sbin/npf/npfd: Makefile

Log Message:
libnpf fix: link the library itself to libnv; libnpf users should not be
expected to assume this dependency.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libnpf/Makefile
cvs rdiff -u -r1.7 -r1.8 src/lib/npf/mod.mk
cvs rdiff -u -r1.17 -r1.18 src/libexec/identd/Makefile
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/npf/npfctl/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npfd/Makefile

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



CVS commit: src

2019-08-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Aug 24 13:20:52 UTC 2019

Modified Files:
src/lib/libnpf: Makefile
src/lib/npf: mod.mk
src/libexec/identd: Makefile
src/usr.sbin/npf/npfctl: Makefile
src/usr.sbin/npf/npfd: Makefile

Log Message:
libnpf fix: link the library itself to libnv; libnpf users should not be
expected to assume this dependency.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libnpf/Makefile
cvs rdiff -u -r1.7 -r1.8 src/lib/npf/mod.mk
cvs rdiff -u -r1.17 -r1.18 src/libexec/identd/Makefile
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/npf/npfctl/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npfd/Makefile

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

Modified files:

Index: src/lib/libnpf/Makefile
diff -u src/lib/libnpf/Makefile:1.10 src/lib/libnpf/Makefile:1.11
--- src/lib/libnpf/Makefile:1.10	Sun Jan 27 04:39:33 2019
+++ src/lib/libnpf/Makefile	Sat Aug 24 13:20:52 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2019/01/27 04:39:33 dholland Exp $
+# $NetBSD: Makefile,v 1.11 2019/08/24 13:20:52 rmind Exp $
 
 USE_SHLIBDIR=   yes
 
@@ -12,8 +12,12 @@ SRCS=		npf.c
 INCS=		npf.h
 INCSDIR=	/usr/include
 
+LIBNV!=		cd ${NETBSDSRCDIR}/external/bsd/libnv/lib && ${PRINTOBJDIR}
 CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/external/bsd/libnv/dist
 
+DPADD+=		${LIBNV}/libnv.a
+LDADD+=		-L${LIBNV} -lnv
+
 WARNS=		5
 
 .include 

Index: src/lib/npf/mod.mk
diff -u src/lib/npf/mod.mk:1.7 src/lib/npf/mod.mk:1.8
--- src/lib/npf/mod.mk:1.7	Sat Sep 29 14:41:36 2018
+++ src/lib/npf/mod.mk	Sat Aug 24 13:20:52 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mod.mk,v 1.7 2018/09/29 14:41:36 rmind Exp $
+#	$NetBSD: mod.mk,v 1.8 2019/08/24 13:20:52 rmind Exp $
 
 .include 
 
@@ -25,8 +25,6 @@ SHLIBINSTALLDIR=${LIBROOTDIR}/npf
 
 LIB=		${MOD}
 SRCS=		npf${MOD}.c
-
-CPPFLAGS+=	-I ${NETBSDSRCDIR}/sys/external/bsd/libnv/dist
 LIBDPLIBS+=	npf ${NETBSDSRCDIR}/lib/libnpf
 
 .include 

Index: src/libexec/identd/Makefile
diff -u src/libexec/identd/Makefile:1.17 src/libexec/identd/Makefile:1.18
--- src/libexec/identd/Makefile:1.17	Sat Sep 29 14:41:37 2018
+++ src/libexec/identd/Makefile	Sat Aug 24 13:20:52 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2018/09/29 14:41:37 rmind Exp $
+# $NetBSD: Makefile,v 1.18 2019/08/24 13:20:52 rmind Exp $
 
 .include 
 
@@ -22,10 +22,6 @@ CPPFLAGS+=-DWITH_PF
 .if (${MKNPF} != "no")
 SRCS+=	npf.c
 CPPFLAGS+=-DWITH_NPF
-
-PROGDPLIBS+= nv ${NETBSDSRCDIR}/external/bsd/libnv/lib
-CPPFLAGS+= -I ${NETBSDSRCDIR}/sys/external/bsd/libnv/dist
-
 LDADD+=-lnpf
 DPADD+=${LIBNPF}
 .endif

Index: src/usr.sbin/npf/npfctl/Makefile
diff -u src/usr.sbin/npf/npfctl/Makefile:1.13 src/usr.sbin/npf/npfctl/Makefile:1.14
--- src/usr.sbin/npf/npfctl/Makefile:1.13	Sat Sep 29 14:41:36 2018
+++ src/usr.sbin/npf/npfctl/Makefile	Sat Aug 24 13:20:52 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2018/09/29 14:41:36 rmind Exp $
+# $NetBSD: Makefile,v 1.14 2019/08/24 13:20:52 rmind Exp $
 
 .include 
 
@@ -13,9 +13,6 @@ CPPFLAGS+=	-I${.CURDIR}
 SRCS+=		npf_scan.l npf_parse.y
 YHEADER=	1
 
-PROGDPLIBS+=	nv ${NETBSDSRCDIR}/external/bsd/libnv/lib
-CPPFLAGS+=	-I ${NETBSDSRCDIR}/sys/external/bsd/libnv/dist
-
 LDADD+=		-lnpf -lpcap -lutil -ly
 DPADD+=		${LIBNPF} ${LIBUTIL} ${LIBPCAP} ${LIBUTIL} ${LIBY}
 

Index: src/usr.sbin/npf/npfd/Makefile
diff -u src/usr.sbin/npf/npfd/Makefile:1.6 src/usr.sbin/npf/npfd/Makefile:1.7
--- src/usr.sbin/npf/npfd/Makefile:1.6	Sat Sep 29 14:41:36 2018
+++ src/usr.sbin/npf/npfd/Makefile	Sat Aug 24 13:20:52 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2018/09/29 14:41:36 rmind Exp $
+# $NetBSD: Makefile,v 1.7 2019/08/24 13:20:52 rmind Exp $
 #
 # Public Domain
 #
@@ -9,9 +9,6 @@ MAN=		npfd.8
 SRCS=		npfd.c npfd_log.c
 CPPFLAGS+=	-I${.CURDIR}
 
-PROGDPLIBS+=	nv ${NETBSDSRCDIR}/external/bsd/libnv/lib
-CPPFLAGS+=	-I ${NETBSDSRCDIR}/sys/external/bsd/libnv/dist
-
 LDADD+=		-lnpf -lpcap -lutil
 DPADD+=		${LIBNPF} ${LIBPCAP} ${LIBUTIL}
 



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:34 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dnode.c

Log Message:
Add missing dmu_zfetch_fini() when dnode_create() lost the race.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:34 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dnode.c

Log Message:
Add missing dmu_zfetch_fini() when dnode_create() lost the race.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.7 src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.8
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c:1.7	Sun May 26 10:21:00 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c	Sat Aug 24 12:59:34 2019
@@ -447,6 +447,9 @@ dnode_create(objset_t *os, dnode_phys_t 
 	if (dnh->dnh_dnode != NULL) {
 		/* Lost the allocation race. */
 		mutex_exit(>os_lock);
+#ifdef __NetBSD__
+		dmu_zfetch_fini(>dn_zfetch);
+#endif
 		kmem_cache_free(dnode_cache, dn);
 		return (dnh->dnh_dnode);
 	}



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:06 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Implement kqueue support.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.51 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.52
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.51	Sat Aug 24 12:58:24 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sat Aug 24 12:59:05 2019
@@ -,6 +,16 @@ zfs_rename(vnode_t *sdvp, vnode_t **svpp
 			if (*tvpp != NULL)
 cache_purge(*tvpp);
 			cache_purge_negative(tdvp);
+#ifdef __NetBSD__
+			if (*svpp == *tvpp) {
+VN_KNOTE(sdvp, NOTE_WRITE);
+VN_KNOTE(*svpp, (szp->z_links == 0 ?
+NOTE_DELETE : NOTE_LINK));
+			} else {
+genfs_rename_knote(sdvp, *svpp, tdvp, *tvpp,
+((tzp != NULL) && (tzp->z_links == 0)));
+			}
+#endif
 		}
 	}
 
@@ -5094,6 +5104,10 @@ zfs_netbsd_write(void *v)
 {
 	struct vop_write_args *ap = v;
 	vnode_t *vp = ap->a_vp;
+	znode_t *zp = VTOZ(vp);
+	struct uio *uio = ap->a_uio;
+	off_t osize = zp->z_size;
+	int error, resid;
 
 	switch (vp->v_type) {
 	case VBLK:
@@ -5105,7 +5119,13 @@ zfs_netbsd_write(void *v)
 		return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_write), ap));
 	}
 
-	return (zfs_write(vp, ap->a_uio, ioflags(ap->a_ioflag), ap->a_cred, NULL));
+	resid = uio->uio_resid;
+	error = zfs_write(vp, uio, ioflags(ap->a_ioflag), ap->a_cred, NULL);
+	if (resid > uio->uio_resid)
+		VN_KNOTE(vp, NOTE_WRITE |
+		(zp->z_size > osize ? NOTE_EXTEND : 0));
+
+	return error;
 }
 
 static int
@@ -5296,6 +5316,8 @@ zfs_netbsd_create(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5334,6 +5356,8 @@ zfs_netbsd_mknod(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5363,6 +5387,10 @@ zfs_netbsd_remove(void *v)
 	error = zfs_remove(dvp, vp, nm, cnp->cn_cred);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(vp, NOTE_DELETE);
+		VN_KNOTE(dvp, NOTE_WRITE);
+	}
 	vput(vp);
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	return (error);
@@ -5398,6 +5426,8 @@ zfs_netbsd_mkdir(void *v)
 
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	if (error == 0)
+		VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
 	VOP_UNLOCK(*vpp, 0);
 
 	return (error);
@@ -5427,6 +5457,10 @@ zfs_netbsd_rmdir(void *v)
 	error = zfs_rmdir(dvp, vp, nm, cnp->cn_cred);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
+		VN_KNOTE(vp, NOTE_DELETE);
+	}
 	vput(vp);
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	return error;
@@ -5571,7 +5605,11 @@ zfs_netbsd_setattr(void *v)
 			return error;
 	}
 
-	return (zfs_setattr(vp, (vattr_t *), flags, cred, NULL));
+	error = zfs_setattr(vp, (vattr_t *), flags, cred, NULL);
+	if (error == 0)
+		VN_KNOTE(vp, NOTE_ATTRIB);
+
+	return error;
 }
 
 static int
@@ -5675,7 +5713,8 @@ zfs_netbsd_symlink(void *v)
 	error = zfs_symlink(dvp, vpp, nm, vap, target, cnp->cn_cred, 0);
 
 	PNBUF_PUT(nm);
-
+	if (error == 0)
+		VN_KNOTE(ap->a_dvp, NOTE_WRITE);
 	KASSERT((error == 0) == (*vpp != NULL));
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	VOP_UNLOCK(*vpp, 0);
@@ -5716,6 +5755,10 @@ zfs_netbsd_link(void *v)
 	NULL, 0);
 
 	PNBUF_PUT(nm);
+	if (error == 0) {
+		VN_KNOTE(vp, NOTE_LINK);
+		VN_KNOTE(dvp, NOTE_WRITE);
+	}
 	VOP_UNLOCK(vp, 0);
 	return error;
 }
@@ -6235,6 +6278,7 @@ const struct vnodeopv_entry_desc zfs_vno
 	{ _write_desc,		zfs_netbsd_write },
 	{ _ioctl_desc,		zfs_netbsd_ioctl },
 	{ _poll_desc,		genfs_poll },
+	{ _kqfilter_desc,		genfs_kqfilter },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		zfs_netbsd_remove },
 	{ _link_desc,		zfs_netbsd_link },
@@ -6278,6 +6322,7 @@ const struct vnodeopv_entry_desc zfs_spe
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		spec_ioctl },
 	{ _poll_desc,		spec_poll },
+	{ _kqfilter_desc,		spec_kqfilter },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		spec_remove },
 	{ _link_desc,		spec_link },
@@ -6321,6 +6366,7 @@ const struct vnodeopv_entry_desc zfs_fif
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		vn_fifo_bypass },
 	{ _poll_desc,		vn_fifo_bypass },
+	{ _kqfilter_desc,		vn_fifo_bypass },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		vn_fifo_bypass },
 	{ _link_desc,		vn_fifo_bypass },



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:59:06 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Implement kqueue support.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:58:25 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Implement poll support.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Aug 24 12:58:25 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c

Log Message:
Implement poll support.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.51
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50	Mon Jun 17 08:08:21 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Sat Aug 24 12:58:24 2019
@@ -6234,6 +6234,7 @@ const struct vnodeopv_entry_desc zfs_vno
 	{ _read_desc,		zfs_netbsd_read },
 	{ _write_desc,		zfs_netbsd_write },
 	{ _ioctl_desc,		zfs_netbsd_ioctl },
+	{ _poll_desc,		genfs_poll },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		zfs_netbsd_remove },
 	{ _link_desc,		zfs_netbsd_link },
@@ -6276,6 +6277,7 @@ const struct vnodeopv_entry_desc zfs_spe
 	{ _read_desc,		/**/zfs_netbsd_read },
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		spec_ioctl },
+	{ _poll_desc,		spec_poll },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		spec_remove },
 	{ _link_desc,		spec_link },
@@ -6318,6 +6320,7 @@ const struct vnodeopv_entry_desc zfs_fif
 	{ _read_desc,		/**/zfs_netbsd_read },
 	{ _write_desc,		/**/zfs_netbsd_write },
 	{ _ioctl_desc,		vn_fifo_bypass },
+	{ _poll_desc,		vn_fifo_bypass },
 	{ _fsync_desc,		zfs_netbsd_fsync },
 	{ _remove_desc,		vn_fifo_bypass },
 	{ _link_desc,		vn_fifo_bypass },



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 12:33:25 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h

Log Message:
Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/linux/common/linux_socket.h

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

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.145 src/sys/compat/linux/common/linux_socket.c:1.146
--- src/sys/compat/linux/common/linux_socket.c:1.145	Thu Apr 18 17:45:12 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 12:33:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -605,7 +605,7 @@ linux_sys_sendmsg(struct lwp *l, const s
 
 			resid -= LINUX_CMSG_ALIGN(l_cmsg.cmsg_len);
 			cidx += cspace;
-		} while ((l_cc = LINUX_CMSG_NXTHDR(, l_cc)) && resid > 0);
+		} while ((l_cc = LINUX_CMSG_NXTHDR(, l_cc, _cmsg)) && resid > 0);
 
 		/* If we allocated a buffer, attach to mbuf */
 		if (cidx > MLEN) {

Index: src/sys/compat/linux/common/linux_socket.h
diff -u src/sys/compat/linux/common/linux_socket.h:1.23 src/sys/compat/linux/common/linux_socket.h:1.24
--- src/sys/compat/linux/common/linux_socket.h:1.23	Fri Feb  3 16:57:39 2017
+++ src/sys/compat/linux/common/linux_socket.h	Sat Aug 24 12:33:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.h,v 1.23 2017/02/03 16:57:39 christos Exp $	*/
+/*	$NetBSD: linux_socket.h,v 1.24 2019/08/24 12:33:25 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -186,13 +186,13 @@ struct linux_cmsghdr {
 /* Linux either uses this, or  &((cmsg)->__cmsg_data) */
 #define LINUX_CMSG_DATA(cmsg)	\
 	((u_char *)((struct linux_cmsghdr *)(cmsg) + 1))
-#define	LINUX_CMSG_NXTHDR(mhdr, cmsg)	\
-	char *)(cmsg) + LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \
-			sizeof(*(cmsg))) > \
+#define LINUX_CMSG_NXTHDR(mhdr, ucmsg, kcmsg)	\
+	char *)(ucmsg) + LINUX_CMSG_ALIGN((kcmsg)->cmsg_len) + \
+			sizeof(*(ucmsg))) > \
 	(((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
 	(struct linux_cmsghdr *)NULL : \
-	(struct linux_cmsghdr *)((char *)(cmsg) + \
-	LINUX_CMSG_ALIGN((cmsg)->cmsg_len)))
+	(struct linux_cmsghdr *)((char *)(ucmsg) + \
+	LINUX_CMSG_ALIGN((kcmsg)->cmsg_len)))
 /* This the number of bytes removed from each item (excl. final padding) */
 #define LINUX_CMSG_ALIGN_DELTA	\
 	(CMSG_ALIGN(sizeof(struct cmsghdr)) - sizeof(struct linux_cmsghdr))



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 12:33:25 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h

Log Message:
Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/linux/common/linux_socket.h

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



CVS commit: src/sys/arch/arm/arm32

2019-08-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 24 11:51:26 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
bus_dmamap_load_raw: support coherent mappings
bus_dmamap_sync: support syncing "raw" buffer types


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/arm/arm32/bus_dma.c

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



CVS commit: src/sys/arch/arm/arm32

2019-08-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 24 11:51:26 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
bus_dmamap_load_raw: support coherent mappings
bus_dmamap_sync: support syncing "raw" buffer types


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/arm/arm32/bus_dma.c

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

Modified files:

Index: src/sys/arch/arm/arm32/bus_dma.c
diff -u src/sys/arch/arm/arm32/bus_dma.c:1.115 src/sys/arch/arm/arm32/bus_dma.c:1.116
--- src/sys/arch/arm/arm32/bus_dma.c:1.115	Fri Jun 14 09:09:12 2019
+++ src/sys/arch/arm/arm32/bus_dma.c	Sat Aug 24 11:51:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.115 2019/06/14 09:09:12 skrll Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.116 2019/08/24 11:51:26 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.115 2019/06/14 09:09:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.116 2019/08/24 11:51:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -750,8 +750,10 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 		sgsize = MIN(ds->ds_len, size);
 		if (sgsize == 0)
 			continue;
+		const bool coherent =
+		(ds->_ds_flags & _BUS_DMAMAP_COHERENT) != 0;
 		error = _bus_dmamap_load_paddr(t, map, ds->ds_addr,
-		sgsize, false);
+		sgsize, coherent);
 		if (error != 0)
 			break;
 		size -= sgsize;
@@ -766,6 +768,9 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 	/* XXX TBD bounce */
 
 	map->dm_mapsize = size0;
+	map->_dm_origbuf = NULL;
+	map->_dm_buftype = _BUS_DMA_BUFTYPE_RAW;
+	map->_dm_vmspace = NULL;
 	return 0;
 }
 
@@ -1165,6 +1170,7 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 
 	switch (buftype) {
 	case _BUS_DMA_BUFTYPE_LINEAR:
+	case _BUS_DMA_BUFTYPE_RAW:
 		_bus_dmamap_sync_linear(t, map, offset, len, ops);
 		break;
 
@@ -1176,10 +1182,6 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 		_bus_dmamap_sync_uio(t, map, offset, len, ops);
 		break;
 
-	case _BUS_DMA_BUFTYPE_RAW:
-		panic("_bus_dmamap_sync: _BUS_DMA_BUFTYPE_RAW");
-		break;
-
 	case _BUS_DMA_BUFTYPE_INVALID:
 		panic("_bus_dmamap_sync: _BUS_DMA_BUFTYPE_INVALID");
 		break;



CVS commit: src/sys/dev/pci

2019-08-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 24 11:40:38 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.1372 -r1.1373 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1371 -r1.1372 src/sys/dev/pci/pcidevs_data.h

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



CVS commit: src/sys/dev/pci

2019-08-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 24 11:40:22 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1384 -r1.1385 src/sys/dev/pci/pcidevs

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



CVS commit: src/sys/dev/pci

2019-08-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 24 11:40:22 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1384 -r1.1385 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1384 src/sys/dev/pci/pcidevs:1.1385
--- src/sys/dev/pci/pcidevs:1.1384	Wed Aug 21 06:03:57 2019
+++ src/sys/dev/pci/pcidevs	Sat Aug 24 11:40:22 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1384 2019/08/21 06:03:57 mrg Exp $
+$NetBSD: pcidevs,v 1.1385 2019/08/24 11:40:22 jmcneill Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5869,6 +5869,10 @@ product MATROX G550_AGP		0x2527	MGA G550
 product MEDIAQ MQ200		0x0200	MQ200
 
 /* Mellanox Technologies */
+product MELLANOX MT27700	0x1013	ConnectX-4
+product MELLANOX MT27710	0x1015	ConnectX-4 Lx
+product MELLANOX MT27800	0x1017	ConnectX-5
+product MELLANOX MT28800	0x1019	ConnectX-5 Ex
 product MELLANOX MT23108	0x5a44	InfiniHost (Tavor)
 product MELLANOX MT23108_PCI	0x5a46	InfiniHost PCI Bridge (Tavor)
 product MELLANOX MT25204_OLD	0x5e8c	InfiniHost III Lx (old Sinai)



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:17 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.h

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



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:17 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.h

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

Modified files:

Index: src/sys/dev/sdmmc/sdmmcdevs.h
diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.5 src/sys/dev/sdmmc/sdmmcdevs.h:1.6
--- src/sys/dev/sdmmc/sdmmcdevs.h:1.5	Sun Aug 18 14:32:34 2019
+++ src/sys/dev/sdmmc/sdmmcdevs.h	Sat Aug 24 11:24:17 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: sdmmcdevs.h,v 1.5 2019/08/18 14:32:34 mlelstv Exp $	*/
+/*	$NetBSD: sdmmcdevs.h,v 1.6 2019/08/24 11:24:17 mlelstv Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *		NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp 
+ *		NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp 
  */
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
@@ -31,8 +31,8 @@
 #define	SDMMC_VENDOR_TOSHIBA	0x0098	/* Toshiba */
 #define	SDMMC_VENDOR_SOCKETCOM	0x0104	/* Socket Communications, Inc. */
 #define	SDMMC_VENDOR_REALTEK	0x024c	/* Realtek */
-#define	SDMMC_VENDOR_BROADCOM	0x0270	/* Broadcom */
 #define	SDMMC_VENDOR_ATHEROS	0x0271	/* Atheros */
+#define	SDMMC_VENDOR_BROADCOM	0x02d0	/* Broadcom */
 #define	SDMMC_VENDOR_SYCHIP	0x02db	/* SyChip Inc. */
 #define	SDMMC_VENDOR_SPECTEC	0x02fe	/* Spectec Computer Co., Ltd */
 #define	SDMMC_VENDOR_MEDIATEK	0x037a	/* MediaTek Inc. */



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:00 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs

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

Modified files:

Index: src/sys/dev/sdmmc/sdmmcdevs
diff -u src/sys/dev/sdmmc/sdmmcdevs:1.5 src/sys/dev/sdmmc/sdmmcdevs:1.6
--- src/sys/dev/sdmmc/sdmmcdevs:1.5	Sun Aug 18 14:32:04 2019
+++ src/sys/dev/sdmmc/sdmmcdevs	Sat Aug 24 11:24:00 2019
@@ -1,4 +1,4 @@
-	$NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp $
+	$NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp $
 /*	$OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $	*/
 
 /*
@@ -24,8 +24,8 @@ vendor CGUYS			0x0092	C-guys, Inc.
 vendor TOSHIBA			0x0098	Toshiba
 vendor SOCKETCOM		0x0104	Socket Communications, Inc.
 vendor REALTEK			0x024c	Realtek
-vendor BROADCOM			0x0270	Broadcom
 vendor ATHEROS			0x0271	Atheros
+vendor BROADCOM			0x02d0	Broadcom
 vendor SYCHIP			0x02db	SyChip Inc.
 vendor SPECTEC			0x02fe	Spectec Computer Co., Ltd
 vendor MEDIATEK			0x037a	MediaTek Inc.



CVS commit: src/sys/dev/sdmmc

2019-08-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 24 11:24:00 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmcdevs

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs

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



Re: CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
At Sat, 24 Aug 2019 16:28:39 +1000,
matthew green wrote:
> > Log Message:
> > Use device unit number for index.
> > The index number was too confusing such as
> >  0: [ ] audio1 @ wss0
> >  1: [*] audio0 @ yds0
> > in my PC for example.  Here is new format:
> >  [*] audio0 @ yds0
> >  [ ] audio1 @ wss0
> > In this style, devices are always listed in order of unit number
> > and 0 always means audio0, 1 always means audio1.
> 
> this change gives me pause.
> 
> it seems to be a kind-of "cf_unit" abuse to me.  eg, if
> i configure or usb-plug a lot, such that i only end up
> with just "audio10" and "audio23" attached, the index
> doesn't match the cf_unit.

The index may not have been good name in my change.
I intended to type "audiocfg test 23" for audio23 regardless of
current total number of available devices.
I wanted to use device name like "audiocfg test audio23" at final.

> perhaps you can sort the audio devices based upon cf_unit,
> such that your original output would have the lines swapped
> except for the prefix number, and then your sanity will be
> saved for the normal use-case.
> 
> at the very least, please restore the previous output
> format as i've used it in at least one script and perhaps
> others hvae as well.  please consider that, as a general
> rule, tool output is likely to be scraped and changing it
> may break things, so formatting changes should be avoided
> if possible.

It's my wrong.  I reverted these changes.
Thank you for pointing out.
---
Tetsuya Isaki 


CVS commit: src/sys/dev/usb

2019-08-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Aug 24 07:43:00 UTC 2019

Modified Files:
src/sys/dev/usb: usbdi.c

Log Message:
don't try to deref a maybe-NULL pointer.  instead of logging
potentially garbage (if not NULL), log the request length.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/usb/usbdi.c

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



CVS commit: src/sys/dev/usb

2019-08-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Aug 24 07:43:00 UTC 2019

Modified Files:
src/sys/dev/usb: usbdi.c

Log Message:
don't try to deref a maybe-NULL pointer.  instead of logging
potentially garbage (if not NULL), log the request length.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/usb/usbdi.c

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

Modified files:

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.184 src/sys/dev/usb/usbdi.c:1.185
--- src/sys/dev/usb/usbdi.c:1.184	Thu Aug 22 07:38:06 2019
+++ src/sys/dev/usb/usbdi.c	Sat Aug 24 07:43:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.184 2019/08/22 07:38:06 mrg Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.185 2019/08/24 07:43:00 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.184 2019/08/22 07:38:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.185 2019/08/24 07:43:00 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1102,14 +1102,14 @@ usbd_do_request_flags(struct usbd_device
 {
 	struct usbd_xfer *xfer;
 	usbd_status err;
+	size_t len = UGETW(req->wLength);
 
 	USBHIST_FUNC();
 	USBHIST_CALLARGS(usbdebug, "dev=%#jx req=%jx flgas=%jx len=%jx",
-	(uintptr_t)dev, (uintptr_t)req, flags, *actlen);
+	(uintptr_t)dev, (uintptr_t)req, flags, len);
 
 	ASSERT_SLEEPABLE();
 
-	size_t len = UGETW(req->wLength);
 	int error = usbd_create_xfer(dev->ud_pipe0, len, 0, 0, );
 	if (error)
 		return error;



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 07:39:42 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c audiodev.h main.c

Log Message:
Revert about index number changes.  It breaks its usage and output format.
Pointed out by mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/audiocfg/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/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.14 src/usr.bin/audiocfg/audiodev.c:1.15
--- src/usr.bin/audiocfg/audiodev.c:1.14	Sat Aug 24 06:32:25 2019
+++ src/usr.bin/audiocfg/audiodev.c	Sat Aug 24 07:39:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.14 2019/08/24 06:32:25 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.15 2019/08/24 07:39:42 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -49,7 +49,6 @@ static int audiodev_test_chmask(struct a
 
 static TAILQ_HEAD(audiodevhead, audiodev) audiodevlist =
 TAILQ_HEAD_INITIALIZER(audiodevlist);
-static unsigned int maxunit;
 
 static int
 audiodev_getinfo(struct audiodev *adev)
@@ -138,9 +137,6 @@ audiodev_add(const char *pdev, const cha
 
 	TAILQ_INSERT_TAIL(, adev, next);
 
-	if (unit > maxunit)
-		maxunit = unit;
-
 	return 0;
 }
 
@@ -182,22 +178,29 @@ audiodev_refresh(void)
 }
 
 unsigned int
-audiodev_maxunit(void)
+audiodev_count(void)
 {
-	return maxunit;
+	struct audiodev *adev;
+	unsigned int n;
+
+	n = 0;
+	TAILQ_FOREACH(adev, , next)
+		++n;
+
+	return n;
 }
 
-/*
- * Get audiodev corresponding to audio device.
- */
 struct audiodev *
 audiodev_get(unsigned int i)
 {
 	struct audiodev *adev;
+	unsigned int n;
 
+	n = 0;
 	TAILQ_FOREACH(adev, , next) {
-		if (i == adev->unit)
+		if (n == i)
 			return adev;
+		++n;
 	}
 
 	return NULL;

Index: src/usr.bin/audiocfg/audiodev.h
diff -u src/usr.bin/audiocfg/audiodev.h:1.8 src/usr.bin/audiocfg/audiodev.h:1.9
--- src/usr.bin/audiocfg/audiodev.h:1.8	Sat Aug 24 05:45:25 2019
+++ src/usr.bin/audiocfg/audiodev.h	Sat Aug 24 07:39:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.h,v 1.8 2019/08/24 05:45:25 isaki Exp $ */
+/* $NetBSD: audiodev.h,v 1.9 2019/08/24 07:39:42 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -60,7 +60,7 @@ struct audiodev {
 };
 
 int			audiodev_refresh(void);
-unsigned int		audiodev_maxunit(void);
+unsigned int		audiodev_count(void);
 struct audiodev *	audiodev_get(unsigned int);
 int			audiodev_set_default(struct audiodev *);
 int			audiodev_set_param(struct audiodev *, int,

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.15 src/usr.bin/audiocfg/main.c:1.16
--- src/usr.bin/audiocfg/main.c:1.15	Sat Aug 24 06:11:10 2019
+++ src/usr.bin/audiocfg/main.c	Sat Aug 24 07:39:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.15 2019/08/24 06:11:10 isaki Exp $ */
+/* $NetBSD: main.c,v 1.16 2019/08/24 07:39:42 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -75,15 +75,15 @@ const char *encoding_names[] = {
 u_int encoding_max = __arraycount(encoding_names);
 
 static void
-print_audiodev(struct audiodev *adev)
+print_audiodev(struct audiodev *adev, int i)
 {
 	struct audiofmt *f;
 	int j;
 
 	assert(adev != NULL);
 
-	printf("[%c] %s @ %s: ",
-	adev->defaultdev ? '*' : ' ',
+	printf("%u: [%c] %s @ %s: ",
+	i, adev->defaultdev ? '*' : ' ',
 	adev->xname, adev->pxname);
 	printf("%s", adev->audio_device.name);
 	if (strlen(adev->audio_device.version) > 0)
@@ -142,28 +142,6 @@ print_audiodev(struct audiodev *adev)
 	}
 }
 
-/* Always return non-null adev, or exit */
-static struct audiodev *
-getadev_fromstr(const char *str)
-{
-	struct audiodev *adev;
-	unsigned int i;
-
-	if (*str < '0' || *str > '9')
-		usage();
-		/* NOTREACHED */
-	errno = 0;
-	i = strtoul(str, NULL, 10);
-	if (errno)
-		usage();
-		/* NOTREACHED */
-	adev = audiodev_get(i);
-	if (adev == NULL) {
-		errx(EXIT_FAILURE, "no such device");
-	}
-	return adev;
-}
-
 int
 main(int argc, char *argv[])
 {
@@ -184,16 +162,36 @@ main(int argc, char *argv[])
 		/* NOTREACHED */
 
 	if (strcmp(argv[1], "list") == 0 && argc == 2) {
-		n = audiodev_maxunit();
-		for (i = 0; i <= n; i++) {
-			adev = audiodev_get(i);
-			if (adev)
-print_audiodev(adev);
-		}
+		n = audiodev_count();
+		for (i = 0; i < n; i++)
+			print_audiodev(audiodev_get(i), i);
 	} else if (strcmp(argv[1], "list") == 0 && argc == 3) {
-		print_audiodev(getadev_fromstr(argv[2]));
+		if (*argv[2] < '0' || *argv[2] > '9')
+			usage();
+			/* NOTREACHED */
+		errno = 0;
+		i = strtoul(argv[2], NULL, 10);
+		if (errno)
+			usage();
+			/* NOTREACHED */
+		adev = audiodev_get(i);
+		if (adev == NULL) {
+			errx(EXIT_FAILURE, "no such device");
+		}
+		print_audiodev(adev, i);
 	} else if (strcmp(argv[1], "default") == 0 && argc == 3) {
-		adev = 

CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 07:39:42 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c audiodev.h main.c

Log Message:
Revert about index number changes.  It breaks its usage and output format.
Pointed out by mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/audiocfg/main.c

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



Re: CVS commit: src/sys/arch/amd64/amd64

2019-08-24 Thread Maxime Villard

Le 21/08/2019 à 23:47, matthew green a écrit :

"Maxime Villard" writes:

Module Name:src
Committed By:   maxv
Date:   Wed Aug 21 16:35:10 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: locore.S

Log Message:
Switch from printf to panic. These messages were notorious for being
unreadable, and at least a clean panic allows the user to inspect the
system via DDB. Also simplify the output, EAX gets overwritten with
the error code so it indicates nothing meaningful.


thanks for this.  i'd been working on the same myself.

do you have a reliable way to trigger this issue?  i thought that
returning to userland with a lock held would do it, but i wasn't
able to get that to work reliably.  there's more work related to
crash dumps i'd like to work on but i got distracted by testing a
change similar to this one and didn't get back to it yet.


if you hard-code a splhigh() in a syscall and invoke it, you can see
the message; to get the unreadable/garbage output you likely need to
have two threads that invoke the syscall at the same time


CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:32:25 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c

Log Message:
Create a waveform in hardware native sample rate which is more efficient.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/audiocfg/audiodev.c

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



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:32:25 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c

Log Message:
Create a waveform in hardware native sample rate which is more efficient.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/audiocfg/audiodev.c

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

Modified files:

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.13 src/usr.bin/audiocfg/audiodev.c:1.14
--- src/usr.bin/audiocfg/audiodev.c:1.13	Sat Aug 24 06:16:27 2019
+++ src/usr.bin/audiocfg/audiodev.c	Sat Aug 24 06:32:25 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.13 2019/08/24 06:16:27 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.14 2019/08/24 06:32:25 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -51,8 +51,6 @@ static TAILQ_HEAD(audiodevhead, audiodev
 TAILQ_HEAD_INITIALIZER(audiodevlist);
 static unsigned int maxunit;
 
-#define AUDIODEV_SAMPLE_RATE	44100
-
 static int
 audiodev_getinfo(struct audiodev *adev)
 {
@@ -308,7 +306,7 @@ audiodev_test(struct audiodev *adev)
 	}
 
 	AUDIO_INITINFO();
-	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
+	info.play.sample_rate = adev->hwinfo.play.sample_rate;
 	info.play.channels = adev->hwinfo.play.channels;
 	info.play.precision = 16;
 	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
@@ -347,7 +345,7 @@ audiodev_test_chmask(struct audiodev *ad
 
 	rv = -1;
 
-	dtmf_new(, , info->play.sample_rate, 2,
+	dtmf_new(, , adev->hwinfo.play.sample_rate, 2,
 	adev->hwinfo.play.channels, chanmask, 350.0, 440.0);
 	if (buf == NULL) {
 		return -1;



re: CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread matthew green
"Tetsuya Isaki" writes:
> Module Name:  src
> Committed By: isaki
> Date: Sat Aug 24 05:45:25 UTC 2019
> 
> Modified Files:
>   src/usr.bin/audiocfg: audiodev.c audiodev.h main.c
> 
> Log Message:
> Use device unit number for index.
> The index number was too confusing such as
>  0: [ ] audio1 @ wss0
>  1: [*] audio0 @ yds0
> in my PC for example.  Here is new format:
>  [*] audio0 @ yds0
>  [ ] audio1 @ wss0
> In this style, devices are always listed in order of unit number
> and 0 always means audio0, 1 always means audio1.

this change gives me pause.

it seems to be a kind-of "cf_unit" abuse to me.  eg, if
i configure or usb-plug a lot, such that i only end up
with just "audio10" and "audio23" attached, the index
doesn't match the cf_unit.

perhaps you can sort the audio devices based upon cf_unit,
such that your original output would have the lines swapped
except for the prefix number, and then your sanity will be
saved for the normal use-case.

at the very least, please restore the previous output
format as i've used it in at least one script and perhaps
others hvae as well.  please consider that, as a general
rule, tool output is likely to be scraped and changing it
may break things, so formatting changes should be avoided
if possible.

thanks.


.mrg.


CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:16:27 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c

Log Message:
AUDIO_GETBUFINFO is more efficient for this purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/audiocfg/audiodev.c

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



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:16:27 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c

Log Message:
AUDIO_GETBUFINFO is more efficient for this purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/audiocfg/audiodev.c

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

Modified files:

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.12 src/usr.bin/audiocfg/audiodev.c:1.13
--- src/usr.bin/audiocfg/audiodev.c:1.12	Sat Aug 24 06:00:49 2019
+++ src/usr.bin/audiocfg/audiodev.c	Sat Aug 24 06:16:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.12 2019/08/24 06:00:49 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.13 2019/08/24 06:16:27 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -317,8 +317,8 @@ audiodev_test(struct audiodev *adev)
 		warn("ioctl AUDIO_SETINFO");
 		goto done;
 	}
-	if (ioctl(adev->fd, AUDIO_GETINFO, ) == -1) {
-		warn("ioctl AUDIO_GETINFO");
+	if (ioctl(adev->fd, AUDIO_GETBUFINFO, ) == -1) {
+		warn("ioctl AUDIO_GETBUFINFO");
 		goto done;
 	}
 



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:13:01 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Fix markup.  index of list command is optional.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audiocfg/audiocfg.1

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



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:13:01 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Fix markup.  index of list command is optional.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audiocfg/audiocfg.1

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

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.5 src/usr.bin/audiocfg/audiocfg.1:1.6
--- src/usr.bin/audiocfg/audiocfg.1:1.5	Thu May  9 09:34:58 2019
+++ src/usr.bin/audiocfg/audiocfg.1	Sat Aug 24 06:13:01 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.5 2019/05/09 09:34:58 wiz Exp $
+.\"	$NetBSD: audiocfg.1,v 1.6 2019/08/24 06:13:01 isaki Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -36,6 +36,7 @@
 .Sh SYNOPSIS
 .Nm
 .Cm list
+.Op Ar index
 .Nm
 .Cm default
 .Ar index



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:11:10 UTC 2019

Modified Files:
src/usr.bin/audiocfg: main.c

Log Message:
Make the same code that appears repeatedly a function.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/audiocfg/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/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.14 src/usr.bin/audiocfg/main.c:1.15
--- src/usr.bin/audiocfg/main.c:1.14	Sat Aug 24 06:00:49 2019
+++ src/usr.bin/audiocfg/main.c	Sat Aug 24 06:11:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.14 2019/08/24 06:00:49 isaki Exp $ */
+/* $NetBSD: main.c,v 1.15 2019/08/24 06:11:10 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -142,6 +142,28 @@ print_audiodev(struct audiodev *adev)
 	}
 }
 
+/* Always return non-null adev, or exit */
+static struct audiodev *
+getadev_fromstr(const char *str)
+{
+	struct audiodev *adev;
+	unsigned int i;
+
+	if (*str < '0' || *str > '9')
+		usage();
+		/* NOTREACHED */
+	errno = 0;
+	i = strtoul(str, NULL, 10);
+	if (errno)
+		usage();
+		/* NOTREACHED */
+	adev = audiodev_get(i);
+	if (adev == NULL) {
+		errx(EXIT_FAILURE, "no such device");
+	}
+	return adev;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -169,29 +191,9 @@ main(int argc, char *argv[])
 print_audiodev(adev);
 		}
 	} else if (strcmp(argv[1], "list") == 0 && argc == 3) {
-		errno = 0;
-		i = strtoul(argv[2], NULL, 10);
-		if (errno)
-			usage();
-			/* NOTREACHED */
-		adev = audiodev_get(i);
-		if (adev == NULL) {
-			errx(EXIT_FAILURE, "no such device");
-		}
-		print_audiodev(adev);
+		print_audiodev(getadev_fromstr(argv[2]));
 	} else if (strcmp(argv[1], "default") == 0 && argc == 3) {
-		if (*argv[2] < '0' || *argv[2] > '9')
-			usage();
-			/* NOTREACHED */
-		errno = 0;
-		i = strtoul(argv[2], NULL, 10);
-		if (errno)
-			usage();
-			/* NOTREACHED */
-		adev = audiodev_get(i);
-		if (adev == NULL) {
-			errx(EXIT_FAILURE, "no such device");
-		}
+		adev = getadev_fromstr(argv[2]);
 		printf("setting default audio device to %s\n", adev->xname);
 		if (audiodev_set_default(adev) == -1) {
 			errx(EXIT_FAILURE, "couldn't set default device");
@@ -199,19 +201,7 @@ main(int argc, char *argv[])
 	} else if (strcmp(argv[1], "set") == 0 && argc == 8) {
 		/* XXX bad commandline... */
 		/* audiocfg set  [p|r] */
-		if (*argv[2] < '0' || *argv[2] > '9')
-			usage();
-			/* NOTREACHED */
-		errno = 0;
-		i = strtoul(argv[2], NULL, 10);
-		if (errno)
-			usage();
-			/* NOTREACHED */
-		adev = audiodev_get(i);
-		if (adev == NULL) {
-			errx(EXIT_FAILURE, "no such device");
-		}
-
+		adev = getadev_fromstr(argv[2]);
 		mode = 0;
 		for (j = 0; j < strlen(argv[3]); j++) {
 			if (argv[3][j] == 'p')
@@ -243,18 +233,7 @@ main(int argc, char *argv[])
 			errx(EXIT_FAILURE, "couldn't set parameter");
 		}
 	} else if (strcmp(argv[1], "test") == 0 && argc == 3) {
-		if (*argv[2] < '0' || *argv[2] > '9')
-			usage();
-			/* NOTREACHED */
-		errno = 0;
-		i = strtoul(argv[2], NULL, 10);
-		if (errno)
-			usage();
-			/* NOTREACHED */
-		adev = audiodev_get(i);
-		if (adev == NULL) {
-			errx(EXIT_FAILURE, "no such device");
-		}
+		adev = getadev_fromstr(argv[2]);
 		print_audiodev(adev);
 		if (audiodev_test(adev) == -1)
 			return EXIT_FAILURE;



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:11:10 UTC 2019

Modified Files:
src/usr.bin/audiocfg: main.c

Log Message:
Make the same code that appears repeatedly a function.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/audiocfg/main.c

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



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:00:49 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c dtmf.c main.c

Log Message:
Use err(3)/warn(3) instead of perror(3)/fprintf(stderr,...).
Use getprogname(3) for usage().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/dtmf.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/audiocfg/main.c

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



CVS commit: src/usr.bin/audiocfg

2019-08-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug 24 06:00:49 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiodev.c dtmf.c main.c

Log Message:
Use err(3)/warn(3) instead of perror(3)/fprintf(stderr,...).
Use getprogname(3) for usage().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/dtmf.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/audiocfg/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/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.11 src/usr.bin/audiocfg/audiodev.c:1.12
--- src/usr.bin/audiocfg/audiodev.c:1.11	Sat Aug 24 05:51:06 2019
+++ src/usr.bin/audiocfg/audiodev.c	Sat Aug 24 06:00:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.11 2019/08/24 05:51:06 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.12 2019/08/24 06:00:49 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -159,7 +160,7 @@ audiodev_refresh(void)
 
 	fd = open(DRVCTLDEV, O_RDONLY);
 	if (fd == -1) {
-		perror("open " DRVCTLDEV);
+		warn("open %s", DRVCTLDEV);
 		return -1;
 	}
 
@@ -173,7 +174,7 @@ audiodev_refresh(void)
 
 	error = drvctl_foreach(fd, "audio", audiodev_cb, NULL);
 	if (error == -1) {
-		perror("drvctl");
+		warnx("drvctl failed");
 		return -1;
 	}
 
@@ -227,19 +228,19 @@ audiodev_set_default(struct audiodev *ad
 	unlink(_PATH_MIXER);
 
 	if (symlink(audiopath, _PATH_AUDIO) == -1) {
-		perror("symlink " _PATH_AUDIO);
+		warn("symlink %s", _PATH_AUDIO);
 		return -1;
 	}
 	if (symlink(soundpath, _PATH_SOUND) == -1) {
-		perror("symlink " _PATH_SOUND);
+		warn("symlink %s", _PATH_SOUND);
 		return -1;
 	}
 	if (symlink(audioctlpath, _PATH_AUDIOCTL) == -1) {
-		perror("symlink " _PATH_AUDIOCTL);
+		warn("symlink %s", _PATH_AUDIOCTL);
 		return -1;
 	}
 	if (symlink(mixerpath, _PATH_MIXER) == -1) {
-		perror("symlink " _PATH_MIXER);
+		warn("symlink %s", _PATH_MIXER);
 		return -1;
 	}
 
@@ -262,8 +263,7 @@ audiodev_set_param(struct audiodev *adev
 			break;
 	}
 	if (enc >= encoding_max) {
-		fprintf(stderr, "unknown encoding name: %s\n", encname);
-		errno = EINVAL;
+		warnx("unknown encoding name: %s", encname);
 		return -1;
 	}
 
@@ -286,7 +286,7 @@ audiodev_set_param(struct audiodev *adev
 	printf("setting %s to %s:%u, %uch, %uHz\n",
 	adev->xname, encname, prec, ch, freq);
 	if (ioctl(adev->ctlfd, AUDIO_SETFORMAT, ) == -1) {
-		perror("ioctl AUDIO_SETFORMAT");
+		warn("ioctl AUDIO_SETFORMAT");
 		return -1;
 	}
 	return 0;
@@ -303,7 +303,7 @@ audiodev_test(struct audiodev *adev)
 
 	adev->fd = open(adev->path, O_WRONLY);
 	if (adev->fd == -1) {
-		perror("open");
+		warn("open %s", adev->path);
 		return -1;
 	}
 
@@ -314,11 +314,11 @@ audiodev_test(struct audiodev *adev)
 	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
 	info.mode = AUMODE_PLAY;
 	if (ioctl(adev->fd, AUDIO_SETINFO, ) == -1) {
-		perror("ioctl AUDIO_SETINFO");
+		warn("ioctl AUDIO_SETINFO");
 		goto done;
 	}
 	if (ioctl(adev->fd, AUDIO_GETINFO, ) == -1) {
-		perror("ioctl AUDIO_GETINFO");
+		warn("ioctl AUDIO_GETINFO");
 		goto done;
 	}
 
@@ -363,7 +363,7 @@ audiodev_test_chmask(struct audiodev *ad
 			wlen = buflen;
 		ret = write(adev->fd, (char *)buf + off, wlen);
 		if (ret == -1) {
-			perror("write");
+			warn("write");
 			goto done;
 		}
 		wlen = ret;
@@ -372,7 +372,7 @@ audiodev_test_chmask(struct audiodev *ad
 	}
 
 	if (ioctl(adev->fd, AUDIO_DRAIN) == -1) {
-		perror("ioctl AUDIO_DRAIN");
+		warn("ioctl AUDIO_DRAIN");
 		goto done;
 	}
 

Index: src/usr.bin/audiocfg/dtmf.c
diff -u src/usr.bin/audiocfg/dtmf.c:1.3 src/usr.bin/audiocfg/dtmf.c:1.4
--- src/usr.bin/audiocfg/dtmf.c:1.3	Sun Aug 11 06:31:00 2013
+++ src/usr.bin/audiocfg/dtmf.c	Sat Aug 24 06:00:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dtmf.c,v 1.3 2013/08/11 06:31:00 dholland Exp $ */
+/* $NetBSD: dtmf.c,v 1.4 2019/08/24 06:00:49 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -28,6 +28,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -70,7 +71,7 @@ dtmf_new(int16_t **buf, size_t *buflen, 
 	*buflen = sample_rate * sizeof(int16_t) * sample_length * channels;
 	*buf = calloc(1, *buflen);
 	if (*buf == NULL) {
-		perror("calloc");
+		warn("calloc");
 		return;
 	}
 

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.13 src/usr.bin/audiocfg/main.c:1.14
--- src/usr.bin/audiocfg/main.c:1.13	Sat Aug 24 05:51:06 2019
+++ src/usr.bin/audiocfg/main.c	Sat Aug 24 06:00:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.13 2019/08/24 05:51:06 isaki Exp $ */
+/* $NetBSD: main.c,v 1.14 2019/08/24 06:00:49 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -27,6 +27,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,8 +39,10 @@
 #include "drvctl.h"
 
 __dead static