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