Index: share/man/man4/linux.4 =================================================================== --- share/man/man4/linux.4 +++ share/man/man4/linux.4 @@ -95,6 +95,10 @@ .Xr loader 8 tunables: .Bl -tag -width indent +.It Va compat.linux.debug +Enable debugging messages. +Set to 0 to silence them. +Defaults to 1. .It Va compat.linux.default_openfiles Default soft openfiles resource limit for Linux applications. Set to -1 to disable the limit. Index: sys/compat/linux/linux_mib.h =================================================================== --- sys/compat/linux/linux_mib.h +++ sys/compat/linux/linux_mib.h @@ -62,6 +62,7 @@ #define linux_use26(t) (linux_kernver(t) >= LINUX_KERNVER_2006000) +extern int linux_debug; extern int linux_default_openfiles; extern int linux_ignore_ip_recverr; extern int linux_preserve_vstatus; Index: sys/compat/linux/linux_mib.c =================================================================== --- sys/compat/linux/linux_mib.c +++ sys/compat/linux/linux_mib.c @@ -63,6 +63,10 @@ SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Linux mode"); +int linux_debug = 1; +SYSCTL_INT(_compat_linux, OID_AUTO, debug, CTLFLAG_RWTUN, + &linux_debug, 0, "Log warnings from linux(4); or 0 to disable"); + int linux_default_openfiles = 1024; SYSCTL_INT(_compat_linux, OID_AUTO, default_openfiles, CTLFLAG_RWTUN, &linux_default_openfiles, 0, Index: sys/compat/linux/linux_socket.c =================================================================== --- sys/compat/linux/linux_socket.c +++ sys/compat/linux/linux_socket.c @@ -946,7 +946,7 @@ struct msghdr msg; struct l_cmsghdr linux_cmsg; struct l_cmsghdr *ptr_cmsg; - struct l_msghdr linux_msg; + struct l_msghdr linux_msghdr; struct iovec *iov; socklen_t datalen; struct sockaddr *sa; @@ -958,7 +958,7 @@ l_size_t clen; int error, fflag; - error = copyin(msghdr, &linux_msg, sizeof(linux_msg)); + error = copyin(msghdr, &linux_msghdr, sizeof(linux_msghdr)); if (error != 0) return (error); @@ -969,10 +969,11 @@ * order to handle this case. This should be checked, but allows the * Linux ping to work. */ - if (PTRIN(linux_msg.msg_control) != NULL && linux_msg.msg_controllen == 0) - linux_msg.msg_control = PTROUT(NULL); + if (PTRIN(linux_msghdr.msg_control) != NULL && + linux_msghdr.msg_controllen == 0) + linux_msghdr.msg_control = PTROUT(NULL); - error = linux_to_bsd_msghdr(&msg, &linux_msg); + error = linux_to_bsd_msghdr(&msg, &linux_msghdr); if (error != 0) return (error); @@ -1010,7 +1011,7 @@ goto bad; } - if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) { + if (linux_msghdr.msg_controllen >= sizeof(struct l_cmsghdr)) { error = ENOBUFS; control = m_get(M_WAITOK, MT_CONTROL); @@ -1018,8 +1019,8 @@ data = mtod(control, void *); datalen = 0; - ptr_cmsg = PTRIN(linux_msg.msg_control); - clen = linux_msg.msg_controllen; + ptr_cmsg = PTRIN(linux_msghdr.msg_control); + clen = linux_msghdr.msg_controllen; do { error = copyin(ptr_cmsg, &linux_cmsg, sizeof(struct l_cmsghdr)); @@ -1154,7 +1155,7 @@ struct l_cmsghdr *linux_cmsg = NULL; struct l_ucred linux_ucred; socklen_t datalen, maxlen, outlen; - struct l_msghdr linux_msg; + struct l_msghdr linux_msghdr; struct iovec *iov, *uiov; struct mbuf *control = NULL; struct mbuf **controlp; @@ -1166,11 +1167,11 @@ void *data; int error, i, fd, fds, *fdp; - error = copyin(msghdr, &linux_msg, sizeof(linux_msg)); + error = copyin(msghdr, &linux_msghdr, sizeof(linux_msghdr)); if (error != 0) return (error); - error = linux_to_bsd_msghdr(msg, &linux_msg); + error = linux_to_bsd_msghdr(msg, &linux_msghdr); if (error != 0) return (error); @@ -1198,7 +1199,7 @@ goto bad; if (msg->msg_name) { - msg->msg_name = PTRIN(linux_msg.msg_name); + msg->msg_name = PTRIN(linux_msghdr.msg_name); error = bsd_to_linux_sockaddr(sa, &lsa, msg->msg_namelen); if (error == 0) error = copyout(lsa, PTRIN(msg->msg_name), @@ -1208,12 +1209,12 @@ goto bad; } - error = bsd_to_linux_msghdr(msg, &linux_msg); + error = bsd_to_linux_msghdr(msg, &linux_msghdr); if (error != 0) goto bad; - maxlen = linux_msg.msg_controllen; - linux_msg.msg_controllen = 0; + maxlen = linux_msghdr.msg_controllen; + linux_msghdr.msg_controllen = 0; if (control) { linux_cmsg = malloc(L_CMSG_HDRSZ, M_LINUX, M_WAITOK | M_ZERO); @@ -1221,7 +1222,7 @@ msg->msg_controllen = control->m_len; cm = CMSG_FIRSTHDR(msg); - outbuf = PTRIN(linux_msg.msg_control); + outbuf = PTRIN(linux_msghdr.msg_control); outlen = 0; while (cm != NULL) { linux_cmsg->cmsg_type = @@ -1287,7 +1288,7 @@ error = EMSGSIZE; goto bad; } else { - linux_msg.msg_flags |= LINUX_MSG_CTRUNC; + linux_msghdr.msg_flags |= LINUX_MSG_CTRUNC; m_dispose_extcontrolm(control); goto out; } @@ -1309,11 +1310,11 @@ cm = CMSG_NXTHDR(msg, cm); } - linux_msg.msg_controllen = outlen; + linux_msghdr.msg_controllen = outlen; } out: - error = copyout(&linux_msg, msghdr, sizeof(linux_msg)); + error = copyout(&linux_msghdr, msghdr, sizeof(linux_msghdr)); bad: if (control != NULL) { @@ -1810,7 +1811,7 @@ return (linux_sendfile(td, arg)); } - uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what); + linux_msg(td, "socket type %d not implemented", args->what); return (ENOSYS); } #endif /* __i386__ || __arm__ || (__amd64__ && COMPAT_LINUX32) */ Index: sys/compat/linux/linux_util.c =================================================================== --- sys/compat/linux/linux_util.c +++ sys/compat/linux/linux_util.c @@ -91,6 +91,9 @@ va_list ap; struct proc *p; + if (linux_debug == 0) + return; + p = td->td_proc; printf("linux: pid %d (%s): ", (int)p->p_pid, p->p_comm); va_start(ap, fmt);