at v4.16-rc7 3.4 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2#ifndef _UAPI_LINUX_MSG_H 3#define _UAPI_LINUX_MSG_H 4 5#include <linux/ipc.h> 6 7/* ipcs ctl commands */ 8#define MSG_STAT 11 9#define MSG_INFO 12 10 11/* msgrcv options */ 12#define MSG_NOERROR 010000 /* no error if message is too big */ 13#define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ 14#define MSG_COPY 040000 /* copy (not remove) all queue messages */ 15 16/* Obsolete, used only for backwards compatibility and libc5 compiles */ 17struct msqid_ds { 18 struct ipc_perm msg_perm; 19 struct msg *msg_first; /* first message on queue,unused */ 20 struct msg *msg_last; /* last message in queue,unused */ 21 __kernel_time_t msg_stime; /* last msgsnd time */ 22 __kernel_time_t msg_rtime; /* last msgrcv time */ 23 __kernel_time_t msg_ctime; /* last change time */ 24 unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */ 25 unsigned long msg_lqbytes; /* ditto */ 26 unsigned short msg_cbytes; /* current number of bytes on queue */ 27 unsigned short msg_qnum; /* number of messages in queue */ 28 unsigned short msg_qbytes; /* max number of bytes on queue */ 29 __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */ 30 __kernel_ipc_pid_t msg_lrpid; /* last receive pid */ 31}; 32 33/* Include the definition of msqid64_ds */ 34#include <asm/msgbuf.h> 35 36/* message buffer for msgsnd and msgrcv calls */ 37struct msgbuf { 38 __kernel_long_t mtype; /* type of message */ 39 char mtext[1]; /* message text */ 40}; 41 42/* buffer for msgctl calls IPC_INFO, MSG_INFO */ 43struct msginfo { 44 int msgpool; 45 int msgmap; 46 int msgmax; 47 int msgmnb; 48 int msgmni; 49 int msgssz; 50 int msgtql; 51 unsigned short msgseg; 52}; 53 54/* 55 * MSGMNI, MSGMAX and MSGMNB are default values which can be 56 * modified by sysctl. 57 * 58 * MSGMNI is the upper limit for the number of messages queues per 59 * namespace. 60 * It has been chosen to be as large possible without facilitating 61 * scenarios where userspace causes overflows when adjusting the limits via 62 * operations of the form retrieve current limit; add X; update limit". 63 * 64 * MSGMNB is the default size of a new message queue. Non-root tasks can 65 * decrease the size with msgctl(IPC_SET), root tasks 66 * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue 67 * size. The optimal value is application dependent. 68 * 16384 is used because it was always used (since 0.99.10) 69 * 70 * MAXMAX is the maximum size of an individual message, it's a global 71 * (per-namespace) limit that applies for all message queues. 72 * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into 73 * the queue. This is also an arbitrary choice (since 2.6.0). 74 */ 75 76#define MSGMNI 32000 /* <= IPCMNI */ /* max # of msg queue identifiers */ 77#define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ 78#define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ 79 80/* unused */ 81#define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */ 82#define MSGTQL MSGMNB /* number of system message headers */ 83#define MSGMAP MSGMNB /* number of entries in message map */ 84#define MSGSSZ 16 /* message segment size */ 85#define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */ 86#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) 87 88 89#endif /* _UAPI_LINUX_MSG_H */