X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8ad349bb6ed4a0be06e34c92be0d98b92e078db4..490019cf9519204c5fb36b2fba54ceb983bb6b72:/bsd/sys/msg.h diff --git a/bsd/sys/msg.h b/bsd/sys/msg.h index f43198c75..6f530fa66 100644 --- a/bsd/sys/msg.h +++ b/bsd/sys/msg.h @@ -1,31 +1,29 @@ /* - * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the - * License may not be used to create, or enable the creation or - * redistribution of, unlawful or unlicensed copies of an Apple operating - * system, or to circumvent, violate, or enable the circumvention or - * violation of, any terms of an Apple operating system software license - * agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and * limitations under the License. - * - * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ @@ -47,6 +45,12 @@ * * This software is provided ``AS IS'' without any warranties of any kind. */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ #ifndef _SYS_MSG_H_ #define _SYS_MSG_H_ @@ -70,25 +74,10 @@ * NOTE: The definition of the key_t type is implicit from the * inclusion of */ -#ifndef _PID_T -typedef __darwin_pid_t pid_t; -#define _PID_T -#endif - -#ifndef _TIME_T -#define _TIME_T -typedef __darwin_time_t time_t; -#endif - -#ifndef _SIZE_T -#define _SIZE_T -typedef __darwin_size_t size_t; -#endif - -#ifndef _SSIZE_T -#define _SSIZE_T -typedef __darwin_ssize_t ssize_t; -#endif +#include +#include +#include +#include /* [XSI] Used for the number of messages in the message queue */ typedef unsigned long msgqnum_t; @@ -96,7 +85,6 @@ typedef unsigned long msgqnum_t; /* [XSI] Used for the number of bytes allowed in a message queue */ typedef unsigned long msglen_t; - /* * Possible values for the fifth parameter to msgrcv(), in addition to the * IPC_NOWAIT flag, which is permitted. @@ -110,7 +98,8 @@ typedef unsigned long msglen_t; * legacy interface there for binary compatibility only. Currently, we * are only forcing this for programs requesting standards conformance. */ -#if defined(__POSIX_C_SOURCE) || defined(kernel) || defined(__LP64__) +#if __DARWIN_UNIX03 || defined(KERNEL) +#pragma pack(4) /* * Structure used internally. * @@ -123,7 +112,13 @@ typedef unsigned long msglen_t; * * NOTES: Reserved fields are not preserved across IPC_SET/IPC_STAT. */ -struct __msqid_ds_new { +#if (defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)) +struct msqid_ds +#else +#define msqid_ds __msqid_ds_new +struct __msqid_ds_new +#endif +{ struct __ipc_perm_new msg_perm; /* [XSI] msg queue permissions */ __int32_t msg_first; /* RESERVED: kernel use only */ __int32_t msg_last; /* RESERVED: kernel use only */ @@ -140,12 +135,12 @@ struct __msqid_ds_new { __int32_t msg_pad3; /* RESERVED: DO NOT USE */ __int32_t msg_pad4[4]; /* RESERVED: DO NOT USE */ }; -#define msqid_ds __msqid_ds_new -#else /* !_POSIX_C_SOURCE */ +#pragma pack() +#else /* !__DARWIN_UNIX03 */ #define msqid_ds __msqid_ds_old -#endif /* !_POSIX_C_SOURCE */ +#endif /* !__DARWIN_UNIX03 */ -#if !defined(__POSIX_C_SOURCE) && !defined(__LP64__) +#if !__DARWIN_UNIX03 struct __msqid_ds_old { struct __ipc_perm_old msg_perm; /* [XSI] msg queue permissions */ __int32_t msg_first; /* RESERVED: kernel use only */ @@ -163,25 +158,32 @@ struct __msqid_ds_old { __int32_t msg_pad3; /* RESERVED: DO NOT USE */ __int32_t msg_pad4[4]; /* RESERVED: DO NOT USE */ }; -#endif /* !_POSIX_C_SOURCE */ +#endif /* !__DARWIN_UNIX03 */ #ifdef KERNEL #ifdef __APPLE_API_PRIVATE #include -// LP64todo - should this move? - #if __DARWIN_ALIGN_NATURAL #pragma options align=natural #endif +typedef user_ulong_t user_msgqnum_t; +typedef user64_ulong_t user64_msgqnum_t; +typedef user32_ulong_t user32_msgqnum_t; + +typedef user_ulong_t user_msglen_t; +typedef user64_ulong_t user64_msglen_t; +typedef user32_ulong_t user32_msglen_t; + +/* kernel version */ struct user_msqid_ds { struct ipc_perm msg_perm; /* [XSI] msg queue permissions */ struct msg *msg_first; /* first message in the queue */ struct msg *msg_last; /* last message in the queue */ - msglen_t msg_cbytes; /* # of bytes on the queue */ - msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */ - msglen_t msg_qbytes; /* [XSI] max bytes on the queue */ + user_msglen_t msg_cbytes; /* # of bytes on the queue */ + user_msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */ + user_msglen_t msg_qbytes; /* [XSI] max bytes on the queue */ pid_t msg_lspid; /* [XSI] pid of last msgsnd() */ pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */ user_time_t msg_stime; /* [XSI] time of last msgsnd() */ @@ -193,15 +195,66 @@ struct user_msqid_ds { __int32_t msg_pad4[4]; }; +/* + * user64 version - this structure only has to be correct if + * compiled LP64, because the 32 bit kernel doesn't need it + */ +struct user64_msqid_ds { + struct ipc_perm msg_perm; /* [XSI] msg queue permissions */ + __int32_t msg_first; /* RESERVED: kernel use only */ + __int32_t msg_last; /* RESERVED: kernel use only */ + user64_msglen_t msg_cbytes; /* # of bytes on the queue */ + user64_msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */ + user64_msglen_t msg_qbytes; /* [XSI] max bytes on the queue */ + pid_t msg_lspid; /* [XSI] pid of last msgsnd() */ + pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */ + user64_time_t msg_stime; /* [XSI] time of last msgsnd() */ + __int32_t msg_pad1; /* RESERVED: DO NOT USE */ + user64_time_t msg_rtime; /* [XSI] time of last msgrcv() */ + __int32_t msg_pad2; /* RESERVED: DO NOT USE */ + user64_time_t msg_ctime; /* [XSI] time of last msgctl() */ + __int32_t msg_pad3; /* RESERVED: DO NOT USE */ + __int32_t msg_pad4[4]; +} __attribute__((__packed__)); + +struct user32_msqid_ds +{ + struct __ipc_perm_new msg_perm; /* [XSI] msg queue permissions */ + __int32_t msg_first; /* RESERVED: kernel use only */ + __int32_t msg_last; /* RESERVED: kernel use only */ + user32_msglen_t msg_cbytes; /* # of bytes on the queue */ + user32_msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */ + user32_msglen_t msg_qbytes; /* [XSI] max bytes on the queue */ + pid_t msg_lspid; /* [XSI] pid of last msgsnd() */ + pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */ + user32_time_t msg_stime; /* [XSI] time of last msgsnd() */ + __int32_t msg_pad1; /* RESERVED: DO NOT USE */ + user32_time_t msg_rtime; /* [XSI] time of last msgrcv() */ + __int32_t msg_pad2; /* RESERVED: DO NOT USE */ + user32_time_t msg_ctime; /* [XSI] time of last msgctl() */ + __int32_t msg_pad3; /* RESERVED: DO NOT USE */ + __int32_t msg_pad4[4]; /* RESERVED: DO NOT USE */ +}; + #if __DARWIN_ALIGN_NATURAL #pragma options align=reset #endif +struct label; + +/* + * Kernel wrapper for the user-level structure + */ +struct msqid_kernel { + struct user_msqid_ds u; + struct label *label; /* MAC framework label */ +}; + #endif /* __APPLE_API_PRIVATE */ #endif /* KERNEL */ -#ifndef _POSIX_C_SOURCE +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #ifdef __APPLE_API_UNSTABLE /* XXX kernel only; protect with macro later */ @@ -212,6 +265,7 @@ struct msg { /* 0 -> free header */ unsigned short msg_ts; /* size of this message */ short msg_spot; /* location of msg start in buffer */ + struct label *label; /* MAC label */ }; /* @@ -291,26 +345,28 @@ struct msgmap { extern char *msgpool; /* MSGMAX byte long msg buffer pool */ extern struct msgmap *msgmaps; /* MSGSEG msgmap structures */ extern struct msg *msghdrs; /* MSGTQL msg headers */ -extern struct user_msqid_ds *msqids; /* MSGMNI user_msqid_ds struct's */ +extern struct msqid_kernel *msqids; /* MSGMNI user_msqid_ds struct's */ #define MSG_LOCKED 01000 /* Is this msqid_ds locked? */ #endif /* KERNEL */ #endif /* __APPLE_API_UNSTABLE */ -#endif /* !_POSIX_C_SOURCE */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ #ifndef KERNEL __BEGIN_DECLS -#ifndef _POSIX_C_SOURCE +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) int msgsys(int, ...); -#endif /* !_POSIX_C_SOURCE */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ int msgctl(int, int, struct msqid_ds *) __DARWIN_ALIAS(msgctl); int msgget(key_t, int); -ssize_t msgrcv(int, void *, size_t, long, int); -int msgsnd(int, const void *, size_t, int); +ssize_t msgrcv(int, void *, size_t, long, int) __DARWIN_ALIAS_C(msgrcv); +int msgsnd(int, const void *, size_t, int) __DARWIN_ALIAS_C(msgsnd); __END_DECLS #endif /* !KERNEL */ #endif /* !_SYS_MSG_H_ */ + +