16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _UAPI_LINUX_MSG_H 3607ca46eSDavid Howells #define _UAPI_LINUX_MSG_H 4607ca46eSDavid Howells 5607ca46eSDavid Howells #include <linux/ipc.h> 6607ca46eSDavid Howells 7607ca46eSDavid Howells /* ipcs ctl commands */ 8607ca46eSDavid Howells #define MSG_STAT 11 9607ca46eSDavid Howells #define MSG_INFO 12 1023c8cec8SDavidlohr Bueso #define MSG_STAT_ANY 13 11607ca46eSDavid Howells 12607ca46eSDavid Howells /* msgrcv options */ 13607ca46eSDavid Howells #define MSG_NOERROR 010000 /* no error if message is too big */ 14607ca46eSDavid Howells #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ 154a674f34SStanislav Kinsbursky #define MSG_COPY 040000 /* copy (not remove) all queue messages */ 16607ca46eSDavid Howells 17607ca46eSDavid Howells /* Obsolete, used only for backwards compatibility and libc5 compiles */ 18607ca46eSDavid Howells struct msqid_ds { 19607ca46eSDavid Howells struct ipc_perm msg_perm; 20607ca46eSDavid Howells struct msg *msg_first; /* first message on queue,unused */ 21607ca46eSDavid Howells struct msg *msg_last; /* last message in queue,unused */ 22*2a785996SArnd Bergmann __kernel_old_time_t msg_stime; /* last msgsnd time */ 23*2a785996SArnd Bergmann __kernel_old_time_t msg_rtime; /* last msgrcv time */ 24*2a785996SArnd Bergmann __kernel_old_time_t msg_ctime; /* last change time */ 25607ca46eSDavid Howells unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */ 26607ca46eSDavid Howells unsigned long msg_lqbytes; /* ditto */ 27607ca46eSDavid Howells unsigned short msg_cbytes; /* current number of bytes on queue */ 28607ca46eSDavid Howells unsigned short msg_qnum; /* number of messages in queue */ 29607ca46eSDavid Howells unsigned short msg_qbytes; /* max number of bytes on queue */ 30607ca46eSDavid Howells __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */ 31607ca46eSDavid Howells __kernel_ipc_pid_t msg_lrpid; /* last receive pid */ 32607ca46eSDavid Howells }; 33607ca46eSDavid Howells 34607ca46eSDavid Howells /* Include the definition of msqid64_ds */ 35607ca46eSDavid Howells #include <asm/msgbuf.h> 36607ca46eSDavid Howells 37607ca46eSDavid Howells /* message buffer for msgsnd and msgrcv calls */ 38607ca46eSDavid Howells struct msgbuf { 39443d5670SH.J. Lu __kernel_long_t mtype; /* type of message */ 40607ca46eSDavid Howells char mtext[1]; /* message text */ 41607ca46eSDavid Howells }; 42607ca46eSDavid Howells 43607ca46eSDavid Howells /* buffer for msgctl calls IPC_INFO, MSG_INFO */ 44607ca46eSDavid Howells struct msginfo { 45607ca46eSDavid Howells int msgpool; 46607ca46eSDavid Howells int msgmap; 47607ca46eSDavid Howells int msgmax; 48607ca46eSDavid Howells int msgmnb; 49607ca46eSDavid Howells int msgmni; 50607ca46eSDavid Howells int msgssz; 51607ca46eSDavid Howells int msgtql; 52607ca46eSDavid Howells unsigned short msgseg; 53607ca46eSDavid Howells }; 54607ca46eSDavid Howells 55607ca46eSDavid Howells /* 560050ee05SManfred Spraul * MSGMNI, MSGMAX and MSGMNB are default values which can be 570050ee05SManfred Spraul * modified by sysctl. 580050ee05SManfred Spraul * 590050ee05SManfred Spraul * MSGMNI is the upper limit for the number of messages queues per 600050ee05SManfred Spraul * namespace. 610050ee05SManfred Spraul * It has been chosen to be as large possible without facilitating 620050ee05SManfred Spraul * scenarios where userspace causes overflows when adjusting the limits via 630050ee05SManfred Spraul * operations of the form retrieve current limit; add X; update limit". 640050ee05SManfred Spraul * 650050ee05SManfred Spraul * MSGMNB is the default size of a new message queue. Non-root tasks can 660050ee05SManfred Spraul * decrease the size with msgctl(IPC_SET), root tasks 670050ee05SManfred Spraul * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue 680050ee05SManfred Spraul * size. The optimal value is application dependent. 690050ee05SManfred Spraul * 16384 is used because it was always used (since 0.99.10) 700050ee05SManfred Spraul * 710050ee05SManfred Spraul * MAXMAX is the maximum size of an individual message, it's a global 720050ee05SManfred Spraul * (per-namespace) limit that applies for all message queues. 730050ee05SManfred Spraul * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into 740050ee05SManfred Spraul * the queue. This is also an arbitrary choice (since 2.6.0). 75607ca46eSDavid Howells */ 76607ca46eSDavid Howells 770050ee05SManfred Spraul #define MSGMNI 32000 /* <= IPCMNI */ /* max # of msg queue identifiers */ 78607ca46eSDavid Howells #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ 79607ca46eSDavid Howells #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ 80607ca46eSDavid Howells 81607ca46eSDavid Howells /* unused */ 82607ca46eSDavid Howells #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */ 83607ca46eSDavid Howells #define MSGTQL MSGMNB /* number of system message headers */ 84607ca46eSDavid Howells #define MSGMAP MSGMNB /* number of entries in message map */ 85607ca46eSDavid Howells #define MSGSSZ 16 /* message segment size */ 86607ca46eSDavid Howells #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */ 87607ca46eSDavid Howells #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) 88607ca46eSDavid Howells 89607ca46eSDavid Howells 90607ca46eSDavid Howells #endif /* _UAPI_LINUX_MSG_H */ 91