From: Manfred Spraul Add -ENOSYS stubs for the posix message queue syscalls. The API is a direct mapping of the api from the unix spec, with two exceptions: - mq_close() doesn't exist. Message queue file descriptors can be closed with close(). - mq_notify(SIGEV_THREAD) cannot be implemented in the kernel. The kernel returns a pollable file descriptor . User space must poll (or read) this descriptor and call the notifier function if the file descriptor is signaled. --- 25-akpm/arch/i386/kernel/entry.S | 9 +++++++++ 25-akpm/include/asm-i386/unistd.h | 11 ++++++++++- 25-akpm/include/linux/mqueue.h | 36 ++++++++++++++++++++++++++++++++++++ 25-akpm/include/linux/syscalls.h | 9 +++++++++ 25-akpm/kernel/sys.c | 6 ++++++ 5 files changed, 70 insertions(+), 1 deletion(-) diff -puN arch/i386/kernel/entry.S~mq-02-syscalls arch/i386/kernel/entry.S --- 25/arch/i386/kernel/entry.S~mq-02-syscalls Tue Apr 6 14:29:05 2004 +++ 25-akpm/arch/i386/kernel/entry.S Tue Apr 6 16:16:42 2004 @@ -882,5 +882,14 @@ ENTRY(sys_call_table) .long sys_utimes .long sys_fadvise64_64 .long sys_ni_syscall /* sys_vserver */ + .long sys_ni_syscall /* sys_mbind */ + .long sys_ni_syscall /* 275 sys_get_mempolicy */ + .long sys_ni_syscall /* sys_set_mempolicy */ + .long sys_mq_open + .long sys_mq_unlink + .long sys_mq_timedsend + .long sys_mq_timedreceive /* 280 */ + .long sys_mq_notify + .long sys_mq_getsetattr syscall_table_size=(.-sys_call_table) diff -puN include/asm-i386/unistd.h~mq-02-syscalls include/asm-i386/unistd.h --- 25/include/asm-i386/unistd.h~mq-02-syscalls Tue Apr 6 14:29:05 2004 +++ 25-akpm/include/asm-i386/unistd.h Tue Apr 6 16:17:27 2004 @@ -279,8 +279,17 @@ #define __NR_utimes 271 #define __NR_fadvise64_64 272 #define __NR_vserver 273 +#define __NR_mbind 274 +#define __NR_get_mempolicy 275 +#define __NR_set_mempolicy 276 +#define __NR_mq_open 277 +#define __NR_mq_unlink (__NR_mq_open+1) +#define __NR_mq_timedsend (__NR_mq_open+2) +#define __NR_mq_timedreceive (__NR_mq_open+3) +#define __NR_mq_notify (__NR_mq_open+4) +#define __NR_mq_getsetattr (__NR_mq_open+5) -#define NR_syscalls 274 +#define NR_syscalls 283 /* user-visible error numbers are in the range -1 - -124: see */ diff -puN /dev/null include/linux/mqueue.h --- /dev/null Thu Apr 11 07:25:15 2002 +++ 25-akpm/include/linux/mqueue.h Tue Apr 6 16:15:02 2004 @@ -0,0 +1,36 @@ +/* Copyright (C) 2003 Krzysztof Benedyczak & Michal Wronski + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + It is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this software; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LINUX_MQUEUE_H +#define _LINUX_MQUEUE_H + +#define MQ_PRIO_MAX 32768 + +typedef int mqd_t; + +struct 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 */ +}; + +#define NOTIFY_NONE 0 +#define NOTIFY_WOKENUP 1 +#define NOTIFY_REMOVED 2 + +#endif diff -puN include/linux/syscalls.h~mq-02-syscalls include/linux/syscalls.h --- 25/include/linux/syscalls.h~mq-02-syscalls Tue Apr 6 14:29:05 2004 +++ 25-akpm/include/linux/syscalls.h Tue Apr 6 14:29:05 2004 @@ -48,6 +48,8 @@ struct timex; struct timezone; struct tms; struct utimbuf; +typedef int mqd_t; +struct mq_attr; #include #include @@ -450,6 +452,13 @@ asmlinkage long sys_shmget(key_t key, si asmlinkage long sys_shmdt(char __user *shmaddr); asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf); +asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr); +asmlinkage long sys_mq_unlink(const char __user *name); +asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout); +asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout); +asmlinkage long sys_mq_notify(mqd_t mqdes, const struct sigevent __user *notification); +asmlinkage long sys_mq_getsetattr(mqd_t mqdes, const struct mq_attr __user *mqstat, struct mq_attr __user *omqstat); + asmlinkage long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn); asmlinkage long sys_pciconfig_read(unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len, diff -puN kernel/sys.c~mq-02-syscalls kernel/sys.c --- 25/kernel/sys.c~mq-02-syscalls Tue Apr 6 14:29:05 2004 +++ 25-akpm/kernel/sys.c Tue Apr 6 16:15:01 2004 @@ -260,6 +260,12 @@ cond_syscall(sys_msgctl) cond_syscall(sys_shmget) cond_syscall(sys_shmdt) cond_syscall(sys_shmctl) +cond_syscall(sys_mq_open) +cond_syscall(sys_mq_unlink) +cond_syscall(sys_mq_timedsend) +cond_syscall(sys_mq_timedreceive) +cond_syscall(sys_mq_notify) +cond_syscall(sys_mq_getsetattr) /* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read) _