Module Name:    src
Committed By:   christos
Date:           Mon Jul  1 01:35:53 UTC 2024

Modified Files:
        src/sys/compat/linux/arch/aarch64: syscalls.master
        src/sys/compat/linux/arch/alpha: syscalls.master
        src/sys/compat/linux/arch/amd64: syscalls.master
        src/sys/compat/linux/arch/arm: syscalls.master
        src/sys/compat/linux/arch/i386: syscalls.master
        src/sys/compat/linux/arch/m68k: syscalls.master
        src/sys/compat/linux/arch/mips: syscalls.master
        src/sys/compat/linux/arch/powerpc: syscalls.master
        src/sys/compat/linux/common: linux_mod.c linux_types.h
        src/sys/kern: sys_mqueue.c
        src/sys/miscfs/procfs: procfs.h procfs_linux.c procfs_subr.c
            procfs_vfsops.c procfs_vnops.c
        src/sys/modules/compat_linux: Makefile
Added Files:
        src/sys/compat/linux/common: linux_mqueue.c linux_mqueue.h

Log Message:
Add linux POSIX message queue support (Ricardo Branco)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/compat/linux/arch/aarch64/syscalls.master
cvs rdiff -u -r1.107 -r1.108 src/sys/compat/linux/arch/alpha/syscalls.master
cvs rdiff -u -r1.73 -r1.74 src/sys/compat/linux/arch/amd64/syscalls.master
cvs rdiff -u -r1.80 -r1.81 src/sys/compat/linux/arch/arm/syscalls.master
cvs rdiff -u -r1.135 -r1.136 src/sys/compat/linux/arch/i386/syscalls.master
cvs rdiff -u -r1.105 -r1.106 src/sys/compat/linux/arch/m68k/syscalls.master
cvs rdiff -u -r1.80 -r1.81 src/sys/compat/linux/arch/mips/syscalls.master
cvs rdiff -u -r1.85 -r1.86 src/sys/compat/linux/arch/powerpc/syscalls.master
cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux/common/linux_mod.c
cvs rdiff -u -r0 -r1.1 src/sys/compat/linux/common/linux_mqueue.c \
    src/sys/compat/linux/common/linux_mqueue.h
cvs rdiff -u -r1.33 -r1.34 src/sys/compat/linux/common/linux_types.h
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_mqueue.c
cvs rdiff -u -r1.86 -r1.87 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/procfs/procfs_linux.c
cvs rdiff -u -r1.119 -r1.120 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.116 -r1.117 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.232 -r1.233 src/sys/miscfs/procfs/procfs_vnops.c
cvs rdiff -u -r1.7 -r1.8 src/sys/modules/compat_linux/Makefile

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/arch/aarch64/syscalls.master
diff -u src/sys/compat/linux/arch/aarch64/syscalls.master:1.12 src/sys/compat/linux/arch/aarch64/syscalls.master:1.13
--- src/sys/compat/linux/arch/aarch64/syscalls.master:1.12	Sat Jun 29 09:46:09 2024
+++ src/sys/compat/linux/arch/aarch64/syscalls.master	Sun Jun 30 21:35:52 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.12 2024/06/29 13:46:09 christos Exp $
+	$NetBSD: syscalls.master,v 1.13 2024/07/01 01:35:52 christos Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -63,6 +63,7 @@
 #include <compat/linux/common/linux_shm.h>
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_mqueue.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
@@ -362,12 +363,23 @@
 177	NOARGS		{ gid_t|sys||getegid(void); }
 178	STD		{ pid_t|linux_sys||gettid(void); }
 179	STD		{ int|linux_sys||sysinfo(struct linux_sysinfo *arg); }
-180	UNIMPL		mq_open
-181	UNIMPL		mq_unlink
-182	UNIMPL		mq_timedsend
-183	UNIMPL		mq_timedreceive
-184	UNIMPL		mq_notify
-185	UNIMPL		mq_getsetattr
+180	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+181	STD		{ int|linux_sys||mq_unlink(const char *name); }
+182	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+183	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+184	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+185	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 #ifdef SYSVMSG
 186	NOARGS		{ int|sys||msgget(key_t key, int msgflg); }
 187	NOARGS		{ int|linux_sys||msgctl(int msqid, int cmd, \

Index: src/sys/compat/linux/arch/alpha/syscalls.master
diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.107 src/sys/compat/linux/arch/alpha/syscalls.master:1.108
--- src/sys/compat/linux/arch/alpha/syscalls.master:1.107	Sat Jun 29 09:46:09 2024
+++ src/sys/compat/linux/arch/alpha/syscalls.master	Sun Jun 30 21:35:52 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.107 2024/06/29 13:46:09 christos Exp $
+	$NetBSD: syscalls.master,v 1.108 2024/07/01 01:35:52 christos Exp $
 ;
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -76,7 +76,8 @@
 #include <compat/linux/common/linux_sem.h>
 #include <compat/linux/common/linux_shm.h>
 #include <compat/linux/common/linux_mmap.h>
-;#include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_mqueue.h>
 
 #include <compat/linux/linux_syscallargs.h>
 #include <compat/linux/arch/alpha/linux_osf1.h>
@@ -698,12 +699,23 @@
 429	UNIMPL		mbind
 430	UNIMPL		get_mempolicy
 431	UNIMPL		set_mempolicy
-432	UNIMPL		mq_open
-433	UNIMPL		mq_unlink
-434	UNIMPL		mq_timedsend
-435	UNIMPL		mq_timedreceive
-436	UNIMPL		mq_notify
-437	UNIMPL		mq_getsetattr
+432	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+433	STD		{ int|linux_sys||mq_unlink(const char *name); }
+434	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+435	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+436	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+437	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 438	STD		{ int|linux_sys||waitid(int idtype, id_t id, \
 			    linux_siginfo_t *infop, int options, \
 			    struct rusage50 *rusage); }

Index: src/sys/compat/linux/arch/amd64/syscalls.master
diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.73 src/sys/compat/linux/arch/amd64/syscalls.master:1.74
--- src/sys/compat/linux/arch/amd64/syscalls.master:1.73	Sat Jun 29 09:46:09 2024
+++ src/sys/compat/linux/arch/amd64/syscalls.master	Sun Jun 30 21:35:52 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.73 2024/06/29 13:46:09 christos Exp $
+	$NetBSD: syscalls.master,v 1.74 2024/07/01 01:35:52 christos Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -60,6 +60,7 @@
 #include <compat/linux/common/linux_shm.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_siginfo.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_machdep.h>
 
 #include <compat/linux/linux_syscallargs.h>
@@ -457,12 +458,23 @@
 237	UNIMPL		mbind
 238	UNIMPL		set_mempolicy
 239	UNIMPL		get_mempolicy
-240	UNIMPL		mq_open
-241	UNIMPL		mq_unlink
-242	UNIMPL		mq_timedsend
-243	UNIMPL		mq_timedreceive
-244	UNIMPL		mq_notify
-245	UNIMPL		mq_getsetattr
+240	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+241	STD		{ int|linux_sys||mq_unlink(const char *name); }
+242	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+243	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+244	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+245	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 246	UNIMPL		kexec_load
 247	STD		{ int|linux_sys||waitid(int idtype, id_t id, \
 			    linux_siginfo_t *infop, int options, \

Index: src/sys/compat/linux/arch/arm/syscalls.master
diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.80 src/sys/compat/linux/arch/arm/syscalls.master:1.81
--- src/sys/compat/linux/arch/arm/syscalls.master:1.80	Sat Jun 29 09:46:09 2024
+++ src/sys/compat/linux/arch/arm/syscalls.master	Sun Jun 30 21:35:52 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.80 2024/06/29 13:46:09 christos Exp $
+	$NetBSD: syscalls.master,v 1.81 2024/07/01 01:35:52 christos Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -48,6 +48,7 @@
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_sched.h>
 
 
@@ -467,12 +468,23 @@
 271	UNIMPL		pciconfig_iobase
 272	UNIMPL		pciconfig_read
 273	UNIMPL		pciconfig_write
-274	UNIMPL		mq_open
-275	UNIMPL		mq_unlink
-276	UNIMPL		mq_timedsend
-277	UNIMPL		mq_timedreceive
-278	UNIMPL		mq_notify
-279	UNIMPL		mq_getsetattr
+274	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+275	STD		{ int|linux_sys||mq_unlink(const char *name); }
+276	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+277	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+278	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+279	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 280	STD		{ int|linux_sys||waitid(int idtype, id_t id, \
 			    linux_siginfo_t *infop, int options, \
 			    struct rusage50 *rusage); }

Index: src/sys/compat/linux/arch/i386/syscalls.master
diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.135 src/sys/compat/linux/arch/i386/syscalls.master:1.136
--- src/sys/compat/linux/arch/i386/syscalls.master:1.135	Sat Jun 29 09:46:09 2024
+++ src/sys/compat/linux/arch/i386/syscalls.master	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.135 2024/06/29 13:46:09 christos Exp $
+	$NetBSD: syscalls.master,v 1.136 2024/07/01 01:35:53 christos Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -47,6 +47,7 @@
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_sched.h>
 
 #include <compat/linux/linux_syscallargs.h>
@@ -469,12 +470,23 @@
 274	UNIMPL		mbind
 275	UNIMPL		get_mempolicy
 276	UNIMPL		set_mempolicy
-277	UNIMPL		mq_open
-278	UNIMPL		mq_unlink
-279	UNIMPL		mq_timedsend
-280	UNIMPL		mq_timedreceive
-281	UNIMPL		mq_notify
-282	UNIMPL		mq_getsetattr
+277	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+278	STD		{ int|linux_sys||mq_unlink(const char *name); }
+279	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+280	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+281	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+282	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 283	UNIMPL		sys_kexec_load
 284	STD		{ int|linux_sys||waitid(int idtype, id_t id, \
 			    linux_siginfo_t *infop, int options, \

Index: src/sys/compat/linux/arch/m68k/syscalls.master
diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.105 src/sys/compat/linux/arch/m68k/syscalls.master:1.106
--- src/sys/compat/linux/arch/m68k/syscalls.master:1.105	Sat Jun 29 09:46:10 2024
+++ src/sys/compat/linux/arch/m68k/syscalls.master	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.105 2024/06/29 13:46:10 christos Exp $
+	$NetBSD: syscalls.master,v 1.106 2024/07/01 01:35:53 christos Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -51,6 +51,7 @@
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_mmap.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_sched.h>
 
 #include <compat/linux/linux_syscallargs.h>
@@ -478,12 +479,23 @@
 268	UNIMPL		mbind
 269	UNIMPL		get_mempolicy
 270	UNIMPL		set_mempolicy
-271	UNIMPL		mq_open
-272	UNIMPL		mq_unlink
-273	UNIMPL		mq_timedsend
-274	UNIMPL		mq_timedreceive
-275	UNIMPL		mq_notify
-276	UNIMPL		mq_getsetattr
+271	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+272	STD		{ int|linux_sys||mq_unlink(const char *name); }
+273	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+274	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+275	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+276	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 277	UNIMPL		waitid
 278	UNIMPL		vserver
 279	UNIMPL		add_key

Index: src/sys/compat/linux/arch/mips/syscalls.master
diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.80 src/sys/compat/linux/arch/mips/syscalls.master:1.81
--- src/sys/compat/linux/arch/mips/syscalls.master:1.80	Sat Jun 29 09:46:10 2024
+++ src/sys/compat/linux/arch/mips/syscalls.master	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.80 2024/06/29 13:46:10 christos Exp $  
+	$NetBSD: syscalls.master,v 1.81 2024/07/01 01:35:53 christos Exp $  
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -52,6 +52,7 @@
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_mmap.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_socketcall.h>
 #include <compat/linux/common/linux_sched.h>
 
@@ -468,12 +469,23 @@
 268	UNIMPL		mbind
 269	UNIMPL		get_mempolicy
 270	UNIMPL		set_mempolicy
-271	UNIMPL		mq_open
-272	UNIMPL		mq_unlink
-273	UNIMPL		mq_timedsend
-274	UNIMPL		mq_timedreceive
-275	UNIMPL		mq_notify
-276	UNIMPL		mq_getsetattr
+271	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+272	STD		{ int|linux_sys||mq_unlink(const char *name); }
+273	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+274	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+275	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+276	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 277	UNIMPL		vserve
 278	STD		{ int|linux_sys||waitid(int idtype, id_t id, \
 			    linux_siginfo_t *infop, int options, \

Index: src/sys/compat/linux/arch/powerpc/syscalls.master
diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.85 src/sys/compat/linux/arch/powerpc/syscalls.master:1.86
--- src/sys/compat/linux/arch/powerpc/syscalls.master:1.85	Sat Jun 29 09:46:10 2024
+++ src/sys/compat/linux/arch/powerpc/syscalls.master	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.85 2024/06/29 13:46:10 christos Exp $  
+	$NetBSD: syscalls.master,v 1.86 2024/07/01 01:35:53 christos Exp $  
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 
@@ -74,6 +74,7 @@
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_mmap.h>
+#include <compat/linux/common/linux_mqueue.h>
 #include <compat/linux/common/linux_sched.h>
 
 #include <compat/linux/linux_syscallargs.h>
@@ -469,12 +470,23 @@
 259	UNIMPL		/* reserved for new sys_mbind */
 260	UNIMPL		/* reserved for new sys_get_mempolicy */
 261	UNIMPL		/* reserved for new sys_set_mempolicy */
-262	UNIMPL		mq_open
-263	UNIMPL		mq_unlink
-264	UNIMPL		mq_timedsend
-265	UNIMPL		mq_timedreceive
-266	UNIMPL		mq_notify
-267	UNIMPL		mq_getsetattr
+262	STD		{ linux_mqd_t|linux_sys||mq_open(const char *name, \
+			    int oflag, linux_umode_t mode, \
+			    struct linux_mq_attr *attr); }
+263	STD		{ int|linux_sys||mq_unlink(const char *name); }
+264	STD		{ int|linux_sys||mq_timedsend(linux_mqd_t mqdes, \
+			    const char *msg_ptr, size_t msg_len, \
+			    unsigned int msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+265	STD		{ ssize_t|linux_sys||mq_timedreceive(linux_mqd_t mqdes, \
+			    char *msg_ptr, size_t msg_len, \
+			    unsigned int *msg_prio, \
+			    const struct linux_timespec *abs_timeout); }
+266	STD		{ int|linux_sys||mq_notify(linux_mqd_t mqdes, \
+			    const struct linux_sigevent *sevp); }
+267	STD		{ int|linux_sys||mq_getsetattr(linux_mqd_t mqdes, \
+			    const struct linux_mq_attr *newattr, \
+			    struct linux_mq_attr *oldattr); }
 268	UNIMPL		kexec_load
 269	UNIMPL		add_key
 270	UNIMPL		request_key

Index: src/sys/compat/linux/common/linux_mod.c
diff -u src/sys/compat/linux/common/linux_mod.c:1.15 src/sys/compat/linux/common/linux_mod.c:1.16
--- src/sys/compat/linux/common/linux_mod.c:1.15	Sat Aug 19 13:57:54 2023
+++ src/sys/compat/linux/common/linux_mod.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_mod.c,v 1.15 2023/08/19 17:57:54 christos Exp $	*/
+/*	$NetBSD: linux_mod.c,v 1.16 2024/07/01 01:35:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.15 2023/08/19 17:57:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.16 2024/07/01 01:35:53 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -66,7 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_mod.c,
 # define	MD3	""
 #endif
 
-#define REQ1    "compat_ossaudio,sysv_ipc,compat_util"
+#define REQ1    "compat_ossaudio,sysv_ipc,mqueue,compat_util"
 #define REQ2    ",compat_50,compat_43"
 
 MODULE(MODULE_CLASS_EXEC, compat_linux, REQ1 REQ2 MD1 MD2 MD3);

Index: src/sys/compat/linux/common/linux_types.h
diff -u src/sys/compat/linux/common/linux_types.h:1.33 src/sys/compat/linux/common/linux_types.h:1.34
--- src/sys/compat/linux/common/linux_types.h:1.33	Wed Nov 24 21:27:08 2021
+++ src/sys/compat/linux/common/linux_types.h	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_types.h,v 1.33 2021/11/25 02:27:08 ryo Exp $	*/
+/*	$NetBSD: linux_types.h,v 1.34 2024/07/01 01:35:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -58,6 +58,8 @@ typedef unsigned short linux_gid16_t;
 typedef unsigned short linux_uid16_t;
 typedef unsigned short linux_umode_t;
 
+typedef long linux_mqd_t;
+
 /*
  * From Linux include/asm-.../posix_types.h
  */

Index: src/sys/kern/sys_mqueue.c
diff -u src/sys/kern/sys_mqueue.c:1.48 src/sys/kern/sys_mqueue.c:1.49
--- src/sys/kern/sys_mqueue.c:1.48	Sat May 23 19:42:43 2020
+++ src/sys/kern/sys_mqueue.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_mqueue.c,v 1.48 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: sys_mqueue.c,v 1.49 2024/07/01 01:35:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.48 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.49 2024/07/01 01:35:53 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -70,11 +70,11 @@ __KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c
 MODULE(MODULE_CLASS_MISC, mqueue, NULL);
 
 /* System-wide limits. */
-static u_int			mq_open_max = MQ_OPEN_MAX;
-static u_int			mq_prio_max = MQ_PRIO_MAX;
-static u_int			mq_max_msgsize = 16 * MQ_DEF_MSGSIZE;
-static u_int			mq_def_maxmsg = 32;
-static u_int			mq_max_maxmsg = 16 * 32;
+u_int			mq_open_max = MQ_OPEN_MAX;
+static u_int		mq_prio_max = MQ_PRIO_MAX;
+u_int			mq_max_msgsize = 16 * MQ_DEF_MSGSIZE;
+u_int			mq_def_maxmsg = 32;
+u_int			mq_max_maxmsg = 16 * 32;
 
 static pool_cache_t		mqmsg_cache	__read_mostly;
 static kmutex_t			mqlist_lock	__cacheline_aligned;

Index: src/sys/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.86 src/sys/miscfs/procfs/procfs.h:1.87
--- src/sys/miscfs/procfs/procfs.h:1.86	Sun May 12 13:26:50 2024
+++ src/sys/miscfs/procfs/procfs.h	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.86 2024/05/12 17:26:50 christos Exp $	*/
+/*	$NetBSD: procfs.h,v 1.87 2024/07/01 01:35:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -103,6 +103,12 @@ typedef enum {
 	PFSmem,		/* the process's memory image */
 	PFSmeminfo,	/* system memory info (if -o linux) */
 	PFSmounts,	/* mounted filesystems (if -o linux) */
+	PFSmqueue,	/* sys/fs/mqueue subdirectory (if -o linux) */
+	PFSmq_msg_def,	/* sys/fs/mqueue/msg_default (if -o linux) */
+	PFSmq_msg_max,	/* sys/fs/mqueue/msg_max (if -o linux) */
+	PFSmq_siz_def,	/* sys/fs/mqueue/msgsize_default (if -o linux) */
+	PFSmq_siz_max,	/* sys/fs/mqueue/msgsize_max (if -o linux) */
+	PFSmq_qmax,	/* sys/fs/mqueue/queues_max (if -o linux) */
 	PFSnote,	/* process notifier */
 	PFSnotepg,	/* process group notifier */
 	PFSproc,	/* a process-specific sub-directory */
@@ -112,6 +118,8 @@ typedef enum {
 	PFSstat,	/* process status (if -o linux) */
 	PFSstatm,	/* process memory info (if -o linux) */
 	PFSstatus,	/* process status */
+	PFSsys,		/* sys subdirectory (if -o linux) */
+	PFSsysfs,	/* sys/fs subdirectory (if -o linux) */
 	PFSsysvipc,	/* sysvipc subdirectory (if -o linux) */
 	PFSsysvipc_msg,	/* sysvipc msg info (if -o linux) */
 	PFSsysvipc_sem,	/* sysvipc sem info (if -o linux) */
@@ -276,6 +284,16 @@ int procfs_dolimit(struct lwp *, struct 
     struct uio *);
 int procfs_dolimits(struct lwp *, struct proc *, struct pfsnode *,
     struct uio *);
+int procfs_domq_msg_def(struct lwp *, struct proc *, struct pfsnode *,
+    struct uio *);
+int procfs_domq_msg_max(struct lwp *, struct proc *, struct pfsnode *,
+    struct uio *);
+int procfs_domq_siz_def(struct lwp *, struct proc *, struct pfsnode *,
+    struct uio *);
+int procfs_domq_siz_max(struct lwp *, struct proc *, struct pfsnode *,
+    struct uio *);
+int procfs_domq_qmax(struct lwp *, struct proc *, struct pfsnode *,
+    struct uio *);
 int procfs_dosysvipc_msg(struct lwp *, struct proc *, struct pfsnode *,
     struct uio *);
 int procfs_dosysvipc_sem(struct lwp *, struct proc *, struct pfsnode *,

Index: src/sys/miscfs/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.88 src/sys/miscfs/procfs/procfs_linux.c:1.89
--- src/sys/miscfs/procfs/procfs_linux.c:1.88	Sun May 12 13:26:50 2024
+++ src/sys/miscfs/procfs/procfs_linux.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*      $NetBSD: procfs_linux.c,v 1.88 2024/05/12 17:26:50 christos Exp $      */
+/*      $NetBSD: procfs_linux.c,v 1.89 2024/07/01 01:35:53 christos Exp $      */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.88 2024/05/12 17:26:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.89 2024/07/01 01:35:53 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -71,6 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_linux
 #ifdef SYSVSHM
 #include <sys/shm.h>
 #endif
+#include <sys/mqueue.h>
 
 #include <miscfs/procfs/procfs.h>
 
@@ -82,6 +83,11 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_linux
 
 extern struct devsw_conv *devsw_conv;
 extern int max_devsw_convs;
+extern u_int mq_open_max;
+extern u_int mq_max_msgsize;
+extern u_int mq_def_maxmsg;
+extern u_int mq_max_maxmsg;
+
 
 #define PGTOB(p)	((unsigned long)(p) << PAGE_SHIFT)
 #define PGTOKB(p)	((unsigned long)(p) << (PAGE_SHIFT - 10))
@@ -897,3 +903,56 @@ out:
 	free(bf, M_TEMP);
 	return error;
 }
+
+static int
+print_uint(unsigned int value, struct uio *uio)
+{
+	char *bf;
+	int offset = 0;
+	int error = EFBIG;
+
+	bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
+	offset += snprintf(bf, LBFSZ, "%u\n", value);
+	if (offset >= LBFSZ)
+		goto out;
+
+	error = uiomove_frombuf(bf, offset, uio);
+out:
+	free(bf, M_TEMP);
+	return error;
+}
+
+int
+procfs_domq_msg_def(struct lwp *curl, struct proc *p,
+    struct pfsnode *pfs, struct uio *uio)
+{
+	return print_uint(mq_def_maxmsg, uio);
+}
+
+int
+procfs_domq_msg_max(struct lwp *curl, struct proc *p,
+    struct pfsnode *pfs, struct uio *uio)
+{
+	return print_uint(mq_max_maxmsg, uio);
+}
+
+int
+procfs_domq_siz_def(struct lwp *curl, struct proc *p,
+    struct pfsnode *pfs, struct uio *uio)
+{
+	return print_uint(MQ_DEF_MSGSIZE, uio);
+}
+
+int
+procfs_domq_siz_max(struct lwp *curl, struct proc *p,
+    struct pfsnode *pfs, struct uio *uio)
+{
+	return print_uint(mq_max_msgsize, uio);
+}
+
+int
+procfs_domq_qmax(struct lwp *curl, struct proc *p,
+    struct pfsnode *pfs, struct uio *uio)
+{
+	return print_uint(mq_open_max, uio);
+}

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.119 src/sys/miscfs/procfs/procfs_subr.c:1.120
--- src/sys/miscfs/procfs/procfs_subr.c:1.119	Sun May 12 13:26:50 2024
+++ src/sys/miscfs/procfs/procfs_subr.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.119 2024/05/12 17:26:50 christos Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.120 2024/07/01 01:35:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.119 2024/05/12 17:26:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.120 2024/07/01 01:35:53 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -299,6 +299,26 @@ procfs_rw(void *v)
 		error = procfs_dosysvipc_shm(curl, p, pfs, uio);
 		break;
 
+	case PFSmq_msg_def:
+		error = procfs_domq_msg_def(curl, p, pfs, uio);
+		break;
+
+	case PFSmq_msg_max:
+		error = procfs_domq_msg_max(curl, p, pfs, uio);
+		break;
+
+	case PFSmq_siz_def:
+		error = procfs_domq_siz_def(curl, p, pfs, uio);
+		break;
+
+	case PFSmq_siz_max:
+		error = procfs_domq_siz_max(curl, p, pfs, uio);
+		break;
+
+	case PFSmq_qmax:
+		error = procfs_domq_qmax(curl, p, pfs, uio);
+		break;
+
 #ifdef __HAVE_PROCFS_MACHDEP
 	PROCFS_MACHDEP_NODETYPE_CASES
 		error = procfs_machdep_rw(curl, l, pfs, uio);

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.116 src/sys/miscfs/procfs/procfs_vfsops.c:1.117
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.116	Sun May 12 13:26:50 2024
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.116 2024/05/12 17:26:50 christos Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.117 2024/07/01 01:35:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.116 2024/05/12 17:26:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.117 2024/07/01 01:35:53 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -437,6 +437,9 @@ procfs_loadvnode(struct mount *mp, struc
 		vp->v_type = VREG;
 		break;
 
+	case PFSsys:	/* /proc/sys = dr-xr-xr-x */
+	case PFSsysfs:	/* /proc/sys/fs = dr-xr-xr-x */
+	case PFSmqueue:	/* /proc/sys/fs/mqueue = dr-xr-xr-x */
 	case PFSsysvipc:/* /proc/sysvipc = dr-xr-xr-x */
 		if (pfs->pfs_fd == -1) {
 			pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|
@@ -445,6 +448,11 @@ procfs_loadvnode(struct mount *mp, struc
 			break;
 		}
 		/*FALLTHROUGH*/
+	case PFSmq_msg_def:	/* /proc/sys/fs/mqueue/msg_default = -r--r--r-- */
+	case PFSmq_msg_max:	/* /proc/sys/fs/mqueue/msg_max = -r--r--r-- */
+	case PFSmq_siz_def:	/* /proc/sys/fs/mqueue/msgsize_default = -r--r--r-- */
+	case PFSmq_siz_max:	/* /proc/sys/fs/mqueue/msgsize_max = -r--r--r-- */
+	case PFSmq_qmax:	/* /proc/sys/fs/mqueue/queues_max = -r--r--r-- */
 	case PFSsysvipc_msg:	/* /proc/sysvipc/msg = -r--r--r-- */
 	case PFSsysvipc_sem:	/* /proc/sysvipc/sem = -r--r--r-- */
 	case PFSsysvipc_shm:	/* /proc/sysvipc/shm = -r--r--r-- */

Index: src/sys/miscfs/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.232 src/sys/miscfs/procfs/procfs_vnops.c:1.233
--- src/sys/miscfs/procfs/procfs_vnops.c:1.232	Sun May 12 13:26:51 2024
+++ src/sys/miscfs/procfs/procfs_vnops.c	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.232 2024/05/12 17:26:51 christos Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.233 2024/07/01 01:35:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.232 2024/05/12 17:26:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.233 2024/07/01 01:35:53 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -203,6 +203,7 @@ static const struct proc_target proc_roo
 	{ DT_REG, N("stat"),	    PFScpustat,        procfs_validfile_linux },
 	{ DT_REG, N("loadavg"),	    PFSloadavg,        procfs_validfile_linux },
 	{ DT_REG, N("version"),     PFSversion,        procfs_validfile_linux },
+	{ DT_DIR, N("sys"),         PFSsys,            procfs_validfile_linux },
 	{ DT_DIR, N("sysvipc"),     PFSsysvipc,        procfs_validfile_linux },
 #undef N
 };
@@ -210,6 +211,52 @@ static const int nproc_root_targets =
     sizeof(proc_root_targets) / sizeof(proc_root_targets[0]);
 
 /*
+ * List of files in the sys directory
+ */
+static const struct proc_target proc_sys_targets[] = {
+#define N(s) sizeof(s)-1, s
+        /*        name              type            validp */
+	{ DT_DIR, N("."),	PFSsys,		procfs_validfile_linux },
+	{ DT_DIR, N(".."),	PFSroot,	NULL },
+	{ DT_REG, N("fs"),	PFSsysfs,	procfs_validfile_linux },
+#undef N
+};
+static const int nproc_sys_targets =
+    sizeof(proc_sys_targets) / sizeof(proc_sys_targets[0]);
+
+/*
+ * List of files in the sys/fs directory
+ */
+static const struct proc_target proc_sysfs_targets[] = {
+#define N(s) sizeof(s)-1, s
+        /*        name              type            validp */
+	{ DT_DIR, N("."),	PFSsysfs,	procfs_validfile_linux },
+	{ DT_DIR, N(".."),	PFSsys,		procfs_validfile_linux },
+	{ DT_REG, N("mqueue"),	PFSmqueue,	procfs_validfile_linux },
+#undef N
+};
+static const int nproc_sysfs_targets =
+    sizeof(proc_sysfs_targets) / sizeof(proc_sysfs_targets[0]);
+
+/*
+ * List of files in the sys/fs/mqueue directory
+ */
+static const struct proc_target proc_mqueue_targets[] = {
+#define N(s) sizeof(s)-1, s
+        /*        name              	type            validp */
+	{ DT_DIR, N("."),		PFSmqueue,	procfs_validfile_linux },
+	{ DT_DIR, N(".."),		PFSsysfs,	procfs_validfile_linux },
+	{ DT_REG, N("msg_default"),	PFSmq_msg_def,	procfs_validfile_linux },
+	{ DT_REG, N("msg_max"),		PFSmq_msg_max,	procfs_validfile_linux },
+	{ DT_REG, N("msgsize_default"),	PFSmq_siz_def,	procfs_validfile_linux },
+	{ DT_REG, N("msgsize_max"),	PFSmq_siz_max,	procfs_validfile_linux },
+	{ DT_REG, N("queues_max"),	PFSmq_qmax,	procfs_validfile_linux },
+#undef N
+};
+static const int nproc_mqueue_targets =
+    sizeof(proc_mqueue_targets) / sizeof(proc_mqueue_targets[0]);
+
+/*
  * List of files in the sysvipc directory
  */
 static const struct proc_target proc_sysvipc_targets[] = {
@@ -742,6 +789,11 @@ procfs_getattr(void *v)
 	case PFSself:
 	case PFScurproc:
 	case PFSroot:
+	case PFSmq_msg_def:
+	case PFSmq_msg_max:
+	case PFSmq_siz_def:
+	case PFSmq_siz_max:
+	case PFSmq_qmax:
 	case PFSsysvipc_msg:
 	case PFSsysvipc_sem:
 	case PFSsysvipc_shm:
@@ -754,6 +806,17 @@ procfs_getattr(void *v)
 		vap->va_uid = vap->va_gid = 0;
 		break;
 
+	case PFSsys:	/* proc/sys only contains "fs" */
+	case PFSsysfs:	/* proc/sys/fs only contains "mqueue" */
+		vap->va_nlink = 3;
+		vap->va_uid = vap->va_gid = 0;
+		break;
+
+	case PFSmqueue:
+		vap->va_nlink = 7;
+		vap->va_uid = vap->va_gid = 0;
+		break;
+
 	case PFSproc:
 	case PFStask:
 	case PFSfile:
@@ -868,6 +931,14 @@ procfs_getattr(void *v)
 	case PFSloadavg:
 	case PFSstatm:
 	case PFSversion:
+	case PFSsys:
+	case PFSsysfs:
+	case PFSmqueue:
+	case PFSmq_msg_def:
+	case PFSmq_msg_max:
+	case PFSmq_siz_def:
+	case PFSmq_siz_max:
+	case PFSmq_qmax:
 	case PFSsysvipc:
 	case PFSsysvipc_msg:
 	case PFSsysvipc_sem:
@@ -1188,15 +1259,47 @@ procfs_lookup(void *v)
 		procfs_proc_unlock(p);
 		return error;
 	}
-	case PFSsysvipc:
+	case PFSsys:
+	case PFSsysfs:
+	case PFSmqueue:
+	case PFSsysvipc: {
+		const struct proc_target *targets;
+		int ntargets;
+		pfstype parent;
+
+		switch (pfs->pfs_type) {
+		case PFSsys:
+			targets = proc_sys_targets;
+			ntargets = nproc_sys_targets;
+			parent = PFSroot;
+			break;
+		case PFSsysfs:
+			targets = proc_sysfs_targets;
+			ntargets = nproc_sysfs_targets;
+			parent = PFSsys;
+			break;
+		case PFSmqueue:
+			targets = proc_mqueue_targets;
+			ntargets = nproc_mqueue_targets;
+			parent = PFSsysfs;
+			break;
+		case PFSsysvipc:
+			targets = proc_sysvipc_targets;
+			ntargets = nproc_sysvipc_targets;
+			parent = PFSroot;
+			break;
+		default:
+			return (EINVAL);
+		}
+
 		if (cnp->cn_flags & ISDOTDOT) {
-			error = procfs_allocvp(dvp->v_mount, vpp, 0, PFSroot,
+			error = procfs_allocvp(dvp->v_mount, vpp, 0, parent,
 			    -1);
 			return (error);
 		}
 
-		for (i = 0; i < nproc_sysvipc_targets; i++) {
-			pt = &proc_sysvipc_targets[i];
+		for (i = 0; i < ntargets; i++) {
+			pt = &targets[i];
 			/*
 			 * check for node match.  proc is always NULL here,
 			 * so call pt_valid with constant NULL lwp.
@@ -1208,13 +1311,14 @@ procfs_lookup(void *v)
 				break;
 		}
 
-		if (i != nproc_sysvipc_targets) {
+		if (i != ntargets) {
 			error = procfs_allocvp(dvp->v_mount, vpp, 0,
 			    pt->pt_pfstype, -1);
 			return (error);
 		}
 
 		return (ENOENT);
+	}
 
 	default:
 		return (ENOTDIR);
@@ -1502,21 +1606,48 @@ procfs_readdir(void *v)
 	}
 
 	/*
-	 * sysvipc subdirectory
+	 * misc subdirectories
 	 */
+	case PFSsys:
+	case PFSsysfs:
+	case PFSmqueue:
 	case PFSsysvipc: {
+		const struct proc_target *targets;
+		int ntargets;
+
+		switch (pfs->pfs_type) {
+		case PFSsys:
+			targets = proc_sys_targets;
+			ntargets = nproc_sys_targets;
+			break;
+		case PFSsysfs:
+			targets = proc_sysfs_targets;
+			ntargets = nproc_sysfs_targets;
+			break;
+		case PFSmqueue:
+			targets = proc_mqueue_targets;
+			ntargets = nproc_mqueue_targets;
+			break;
+		case PFSsysvipc:
+			targets = proc_sysvipc_targets;
+			ntargets = nproc_sysvipc_targets;
+			break;
+		default:
+			return (EINVAL);
+		}
+
 		if ((error = procfs_proc_lock(vp->v_mount, pfs->pfs_pid, &p,
 					      ESRCH)) != 0)
 			return error;
 		if (ap->a_ncookies) {
-			ncookies = uimin(ncookies, (nproc_sysvipc_targets - i));
+			ncookies = uimin(ncookies, (ntargets - i));
 			cookies = malloc(ncookies * sizeof (off_t),
 			    M_TEMP, M_WAITOK);
 			*ap->a_cookies = cookies;
 		}
 
-		for (pt = &proc_sysvipc_targets[i];
-		     uio->uio_resid >= UIO_MX && i < nproc_sysvipc_targets; pt++, i++) {
+		for (pt = &targets[i];
+		     uio->uio_resid >= UIO_MX && i < ntargets; pt++, i++) {
 			if (pt->pt_valid &&
 			    (*pt->pt_valid)(NULL, vp->v_mount) == 0)
 				continue;

Index: src/sys/modules/compat_linux/Makefile
diff -u src/sys/modules/compat_linux/Makefile:1.7 src/sys/modules/compat_linux/Makefile:1.8
--- src/sys/modules/compat_linux/Makefile:1.7	Mon Aug 21 15:43:22 2023
+++ src/sys/modules/compat_linux/Makefile	Sun Jun 30 21:35:53 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.7 2023/08/21 19:43:22 christos Exp $
+#	$NetBSD: Makefile,v 1.8 2024/07/01 01:35:53 christos Exp $
 
 .include "../Makefile.inc"
 .include "../Makefile.assym"
@@ -13,7 +13,7 @@ SRCS+=	linux_fdio.c linux_file.c linux_h
 SRCS+=	linux_ipc.c linux_misc.c linux_mtio.c linux_sched.c
 SRCS+=	linux_sg.c linux_signal.c linux_signo.c linux_socket.c
 SRCS+=	linux_sysctl.c linux_termios.c linux_time.c linux_mod.c
-SRCS+=	linux_inotify.c
+SRCS+=	linux_inotify.c linux_mqueue.c
 
 .if ${MACHINE_CPU} == "aarch64"
 CPPFLAGS+=	-DEXEC_ELF64

Added files:

Index: src/sys/compat/linux/common/linux_mqueue.c
diff -u /dev/null src/sys/compat/linux/common/linux_mqueue.c:1.1
--- /dev/null	Sun Jun 30 21:35:54 2024
+++ src/sys/compat/linux/common/linux_mqueue.c	Sun Jun 30 21:35:53 2024
@@ -0,0 +1,315 @@
+/*	$NetBSD	*/
+
+/*-
+ * Copyright (c) 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
+__KERNEL_RCSID(0, "$NetBSD: linux_mqueue.c,v 1.1 2024/07/01 01:35:53 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/filedesc.h>
+#include <sys/fcntl.h>
+#include <sys/mqueue.h>
+#include <sys/syscallargs.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_sched.h>
+#include <compat/linux/common/linux_fcntl.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_sigevent.h>
+#include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_mqueue.h>
+
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_syscall.h>
+
+static void
+linux_to_bsd_mq_attr(const struct linux_mq_attr *lmp, struct mq_attr *bmp)
+{
+	memset(bmp, 0, sizeof(*bmp));
+	bmp->mq_flags = cvtto_bsd_mask(lmp->mq_flags, LINUX_O_NONBLOCK,
+	    O_NONBLOCK);
+	bmp->mq_maxmsg = lmp->mq_maxmsg;
+	bmp->mq_msgsize = lmp->mq_msgsize;
+	bmp->mq_curmsgs = lmp->mq_curmsgs;
+}
+
+static void
+bsd_to_linux_mq_attr(const struct mq_attr *bmp, struct linux_mq_attr *lmp)
+{
+	memset(lmp, 0, sizeof(*lmp));
+	lmp->mq_flags = cvtto_linux_mask(bmp->mq_flags, O_NONBLOCK,
+	    LINUX_O_NONBLOCK);
+	lmp->mq_maxmsg = bmp->mq_maxmsg;
+	lmp->mq_msgsize = bmp->mq_msgsize;
+	lmp->mq_curmsgs = bmp->mq_curmsgs;
+}
+
+/* Adapted from sys_mq_open */
+int
+linux_sys_mq_open(struct lwp *l, const struct linux_sys_mq_open_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(const char *) name;
+		syscallarg(int) oflag;
+		syscallarg(linux_umode_t) mode;
+		syscallarg(struct linux_mq_attr *) attr;
+	} */
+	struct linux_mq_attr lattr;
+	struct mq_attr *attr = NULL, a;
+	int error, oflag;
+
+	oflag = linux_to_bsd_ioflags(SCARG(uap, oflag));
+
+	if ((oflag & O_CREAT) != 0 && SCARG(uap, attr) != NULL) {
+		error = copyin(SCARG(uap, attr), &lattr, sizeof(lattr));
+		if (error)
+			return error;
+		linux_to_bsd_mq_attr(&lattr, &a);
+		attr = &a;
+	}
+
+	return mq_handle_open(l, SCARG(uap, name), oflag,
+	    (mode_t)SCARG(uap, mode), attr, retval);
+}
+
+int
+linux_sys_mq_unlink(struct lwp *l, const struct linux_sys_mq_unlink_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(const char *) name;
+	} */
+	struct sys_mq_unlink_args args;
+
+	SCARG(&args, name) = SCARG(uap, name);
+
+	return sys_mq_unlink(l, &args, retval);
+}
+
+/* Adapted from sys___mq_timedsend50 */
+int
+linux_sys_mq_timedsend(struct lwp *l, const struct linux_sys_mq_timedsend_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(const char *) msg_ptr;
+		syscallarg(size_t) msg_len;
+		syscallarg(unsigned int) msg_prio;
+		syscallarg(const struct linux_timespec *) abs_timeout;
+	} */
+	struct linux_timespec lts;
+	struct timespec ts, *tsp;
+	int error;
+
+	/* Get and convert time value */
+	if (SCARG(uap, abs_timeout)) {
+		error = copyin(SCARG(uap, abs_timeout), &lts, sizeof(lts));
+		if (error)
+			return error;
+		linux_to_native_timespec(&ts, &lts);
+		tsp = &ts;
+	} else {
+		tsp = NULL;
+	}
+
+	return mq_send1((mqd_t)SCARG(uap, mqdes), SCARG(uap, msg_ptr),
+	    SCARG(uap, msg_len), SCARG(uap, msg_prio), tsp);
+}
+
+/* Adapted from sys___mq_timedreceive50 */
+int
+linux_sys_mq_timedreceive(struct lwp *l,
+    const struct linux_sys_mq_timedreceive_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(char *) msg_ptr;
+		syscallarg(size_t) msg_len;
+		syscallarg(unsigned int *) msg_prio;
+		syscallarg(const struct linux_timespec *) abs_timeout;
+	}; */
+	struct linux_timespec lts;
+	struct timespec ts, *tsp;
+	ssize_t mlen;
+	int error;
+
+	/* Get and convert time value */
+	if (SCARG(uap, abs_timeout)) {
+		error = copyin(SCARG(uap, abs_timeout), &lts, sizeof(lts));
+		if (error)
+			return error;
+		linux_to_native_timespec(&ts, &lts);
+		tsp = &ts;
+	} else {
+		tsp = NULL;
+	}
+
+	error = mq_recv1((mqd_t)SCARG(uap, mqdes), SCARG(uap, msg_ptr),
+	    SCARG(uap, msg_len), SCARG(uap, msg_prio), tsp, &mlen);
+	if (error == 0)
+		*retval = mlen;
+
+	return error;
+}
+
+/* Adapted from sys_mq_notify */
+int
+linux_sys_mq_notify(struct lwp *l, const struct linux_sys_mq_notify_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(const struct linux_sigevent *) sevp;
+	} */
+	struct mqueue *mq;
+	struct sigevent sig;
+	int error;
+
+	if (SCARG(uap, sevp)) {
+		/* Get the signal from user-space */
+		error = linux_sigevent_copyin(SCARG(uap, sevp), &sig,
+		    sizeof(sig));
+		if (error)
+			return error;
+		if (sig.sigev_notify == SIGEV_SIGNAL &&
+		    (sig.sigev_signo <= 0 || sig.sigev_signo >= NSIG))
+			return EINVAL;
+	}
+
+	error = mqueue_get((mqd_t)SCARG(uap, mqdes), 0, &mq);
+	if (error)
+		return error;
+	if (SCARG(uap, sevp)) {
+		/* Register notification: set the signal and target process */
+		if (mq->mq_notify_proc == NULL) {
+			memcpy(&mq->mq_sig_notify, &sig,
+			    sizeof(struct sigevent));
+			mq->mq_notify_proc = l->l_proc;
+		} else {
+			/* Fail if someone else already registered */
+			error = EBUSY;
+		}
+	} else {
+		/* Unregister the notification */
+		mq->mq_notify_proc = NULL;
+	}
+	mutex_exit(&mq->mq_mtx);
+	fd_putfile((int)SCARG(uap, mqdes));
+
+	return error;
+}
+
+/* Adapted from sys_mq_getattr */
+static int
+linux_sys_mq_getattr(struct lwp *l,
+    const struct linux_sys_mq_getsetattr_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(const struct linux_mq_attr *) newattr;
+		syscallarg(struct linux_mq_attr *) oldattr;
+	} */
+	struct linux_mq_attr lattr;
+	struct mq_attr attr;
+	struct mqueue *mq;
+	int error;
+
+	error = mqueue_get((mqd_t)SCARG(uap, mqdes), 0, &mq);
+	if (error)
+		return error;
+	memcpy(&attr, &mq->mq_attrib, sizeof(struct mq_attr));
+	bsd_to_linux_mq_attr(&attr, &lattr);
+	mutex_exit(&mq->mq_mtx);
+	fd_putfile((int)SCARG(uap, mqdes));
+
+	return copyout(&lattr, SCARG(uap, oldattr), sizeof(lattr));
+}
+
+/* Adapted from sys_mq_setattr */
+static int
+linux_sys_mq_setattr(struct lwp *l,
+    const struct linux_sys_mq_getsetattr_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(const struct linux_mq_attr *) newattr;
+		syscallarg(struct linux_mq_attr *) oldattr;
+	} */
+	struct linux_mq_attr lattr;
+	struct mq_attr attr;
+	struct mqueue *mq;
+	int error, nonblock;
+
+	error = copyin(SCARG(uap, newattr), &lattr, sizeof(lattr));
+	if (error)
+		return error;
+	linux_to_bsd_mq_attr(&lattr, &attr);
+	nonblock = (attr.mq_flags & O_NONBLOCK);
+
+	error = mqueue_get((mqd_t)SCARG(uap, mqdes), 0, &mq);
+	if (error)
+		return error;
+
+	/* Copy the old attributes, if needed */
+	if (SCARG(uap, oldattr)) {
+		memcpy(&attr, &mq->mq_attrib, sizeof(struct mq_attr));
+		bsd_to_linux_mq_attr(&attr, &lattr);
+	}
+
+	/* Ignore everything, except O_NONBLOCK */
+	if (nonblock)
+		mq->mq_attrib.mq_flags |= O_NONBLOCK;
+	else
+		mq->mq_attrib.mq_flags &= ~O_NONBLOCK;
+
+	mutex_exit(&mq->mq_mtx);
+	fd_putfile((int)SCARG(uap, mqdes));
+
+	/* Copy the data to the user-space. */
+	if (SCARG(uap, oldattr))
+		return copyout(&lattr, SCARG(uap, oldattr), sizeof(lattr));
+
+	return 0;
+}
+
+int
+linux_sys_mq_getsetattr(struct lwp *l,
+    const struct linux_sys_mq_getsetattr_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(linux_mqd_t) mqdes;
+		syscallarg(const struct linux_mq_attr *) newattr;
+		syscallarg(struct linux_mq_attr *) oldattr;
+	} */
+	if (SCARG(uap, newattr) == NULL)
+		return linux_sys_mq_getattr(l, uap, retval);
+	return linux_sys_mq_setattr(l, uap, retval);
+}
Index: src/sys/compat/linux/common/linux_mqueue.h
diff -u /dev/null src/sys/compat/linux/common/linux_mqueue.h:1.1
--- /dev/null	Sun Jun 30 21:35:54 2024
+++ src/sys/compat/linux/common/linux_mqueue.h	Sun Jun 30 21:35:53 2024
@@ -0,0 +1,40 @@
+/*	$NetBSD	*/
+
+/*-
+ * Copyright (c) 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _LINUX_MQUEUE_H
+#define _LINUX_MQUEUE_H
+
+struct linux_mq_attr {
+	long	mq_flags;	/* message queue flags			*/
+	long	mq_maxmsg;	/* maximum number of messages		*/
+	long	mq_msgsize;	/* maximum message size			*/
+	long	mq_curmsgs;	/* number of messages currently queued  */
+	long	__reserved[4];	/* ignored for input, zeroed for output */
+};
+
+#endif /* !_LINUX_MQUEUE_H */

Reply via email to