diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 186b84c8e0f0..9f10ba5152fe 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -2395,7 +2395,7 @@ linux_ioctl(struct thread *td, struct linux_ioctl_args *args) } fdrop(fp, td); - printf("linux: 'ioctl' fd=%d, cmd=0x%x ('%c',%d) not implemented\n", + linux_msg(td, "ioctl fd=%d, cmd=0x%x ('%c',%d) is not implemented", args->fd, (int)(args->cmd & 0xffff), (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c index f977c57ead10..6dd21eb6bc7f 100644 --- a/sys/compat/linux/linux_ipc.c +++ b/sys/compat/linux/linux_ipc.c @@ -556,7 +556,7 @@ linux_semctl(struct thread *td, struct linux_semctl_args *args) case LINUX_SETALL: /* FALLTHROUGH */ default: - uprintf("linux: 'ipc' typ=%d not implemented\n", + linux_msg(td, "ipc type %d is not implemented", args->cmd & ~LINUX_IPC_64); return EINVAL; } @@ -783,8 +783,7 @@ linux_shmctl(struct thread *td, struct linux_shmctl_args *args) case LINUX_SHM_LOCK: case LINUX_SHM_UNLOCK: default: - uprintf("linux: 'ipc' typ=%d not implemented\n", - args->cmd & ~LINUX_IPC_64); + linux_msg(td, "ipc typ=%d not implemented", args->cmd & ~LINUX_IPC_64); return EINVAL; } } diff --git a/sys/compat/linux/linux_sysctl.c b/sys/compat/linux/linux_sysctl.c index 86a8758b56c8..699b5d6f01fb 100644 --- a/sys/compat/linux/linux_sysctl.c +++ b/sys/compat/linux/linux_sysctl.c @@ -35,10 +35,13 @@ #include #include #include +#include #include #include +#include + #define LINUX_CTL_KERN 1 #define LINUX_CTL_VM 2 #define LINUX_CTL_NET 3 @@ -78,6 +81,7 @@ int linux_sysctl(struct thread *td, struct linux_sysctl_args *args) { struct l___sysctl_args la; + struct sbuf *sb; l_int *mib; int error, i; @@ -113,10 +117,18 @@ linux_sysctl(struct thread *td, struct linux_sysctl_args *args) break; } - printf("linux: sysctl: unhandled name="); - for (i = 0; i < la.nlen; i++) - printf("%c%d", (i) ? ',' : '{', mib[i]); - printf("}\n"); + sb = sbuf_new(NULL, NULL, 20 + la.nlen * 5, SBUF_AUTOEXTEND); + if (sb == NULL) { + linux_msg(td, "sysctl is not implemented"); + } else { + sbuf_printf(sb, "sysctl "); + for (i = 0; i < la.nlen; i++) + sbuf_printf(sb, "%c%d", (i) ? ',' : '{', mib[i]); + sbuf_printf(sb, "} is not implemented"); + sbuf_finish(sb); + linux_msg(td, "%s", sbuf_data(sb)); + sbuf_delete(sb); + } free(mib, M_TEMP); return (ENOTDIR); diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index 7b34586966e2..5bd8c15fa359 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -37,6 +37,8 @@ #include #include +#include + #include const char linux_emul_path[] = "/compat/linux"; @@ -200,3 +202,17 @@ linux_emul_convpath(td, path, pathseg, pbuf, cflag) bcopy(ptr, buf, len); return error; } + +void +linux_msg(const struct thread *td, const char *fmt, ...) +{ + va_list ap; + struct proc *p; + + p = td->td_proc; + printf("linux: pid %d (%s): ", (int)p->p_pid, p->p_comm); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + printf("\n"); +} diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index bf9cadd6804a..72fe4373955b 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -108,16 +109,18 @@ int linux_emul_find(struct thread *, caddr_t *, char *, char **, int); int \ linux_ ## s(struct thread *p, struct linux_ ## s ## _args *args) \ { \ - return (unsupported_msg(p, #s)); \ + return (unimplemented_syscall(p, #s)); \ } \ struct __hack +void linux_msg(const struct thread *td, const char *fmt, ...) + __printflike(2, 3); + static __inline int -unsupported_msg(struct thread *td, const char *fname) +unimplemented_syscall(struct thread *td, const char *syscallname) { - printf("linux: syscall %s is obsoleted or not implemented pid %ld " - "(%s)\n", fname, (long)td->td_proc->p_pid, td->td_proc->p_comm); + linux_msg(td, "syscall %s not implemented", syscallname); return (ENOSYS); }