ipc.h

Go to the documentation of this file.
00001 /*-
00002  *© Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00003  * Copyright (c) 1988 University of Utah.
00004  * Copyright (c) 1990, 1993
00005  *      The Regents of the University of California.  All rights reserved.
00006  * (c) UNIX System Laboratories, Inc.
00007  * All or some portions of this file are derived from material licensed
00008  * to the University of California by American Telephone and Telegraph
00009  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
00010  * the permission of UNIX System Laboratories, Inc.
00011  *
00012  * This code is derived from software contributed to Berkeley by
00013  * the Systems Programming Group of the University of Utah Computer
00014  * Science Department.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions
00018  * are met:
00019  * 1. Redistributions of source code must retain the above copyright
00020  *    notice, this list of conditions and the following disclaimer.
00021  * 2. Redistributions in binary form must reproduce the above copyright
00022  *    notice, this list of conditions and the following disclaimer in the
00023  *    documentation and/or other materials provided with the distribution.
00024  * 4. Neither the name of the University nor the names of its contributors
00025  *    may be used to endorse or promote products derived from this software
00026  *    without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00029  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00032  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00034  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00035  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00036  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00037  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00038  * SUCH DAMAGE.
00039  *
00040  *      @(#)ipc.h       8.4 (Berkeley) 2/19/95
00041  * $FreeBSD: src/sys/sys/ipc.h,v 1.25 2005/01/07 02:29:23 imp Exp $
00042  */
00043 
00044 /*
00045  * SVID compatible ipc.h file
00046  */
00047 #ifndef _SYS_IPC_H_
00048 #define _SYS_IPC_H_
00049 
00050 #include <sys/cdefs.h>
00051 #include <sys/types.h>
00052 
00053 #ifndef _GID_T_DECLARED
00054 typedef __gid_t         gid_t;
00055 #define _GID_T_DECLARED
00056 #endif
00057 
00058 #ifndef _KEY_T_DECLARED
00059 typedef __key_t         key_t;
00060 #define _KEY_T_DECLARED
00061 #endif
00062 
00063 #ifndef _MODE_T_DECLARED
00064 typedef __mode_t        mode_t;
00065 #define _MODE_T_DECLARED
00066 #endif
00067 
00068 #ifndef _UID_T_DECLARED
00069 typedef __uid_t         uid_t;
00070 #define _UID_T_DECLARED
00071 #endif
00072 
00073 /*
00074  * XXX almost all members have wrong types.
00075  */
00076 struct ipc_perm {
00077         unsigned short  cuid;   /* creator user id */
00078         unsigned short  cgid;   /* creator group id */
00079         unsigned short  uid;    /* user id */
00080         unsigned short  gid;    /* group id */
00081         unsigned short  mode;   /* r/w permission */
00082         unsigned short  seq;    /* sequence # (to generate unique ipcid) */
00083         key_t           key;    /* user specified msg/sem/shm key */
00084 };
00085 
00086 #if __BSD_VISIBLE
00087 /* common mode bits */
00088 #define IPC_R           000400  /* read permission */
00089 #define IPC_W           000200  /* write/alter permission */
00090 #define IPC_M           010000  /* permission to change control info */
00091 #endif
00092 
00093 /* SVID required constants (same values as system 5) */
00094 #define IPC_CREAT       001000  /* create entry if key does not exist */
00095 #define IPC_EXCL        002000  /* fail if key exists */
00096 #define IPC_NOWAIT      004000  /* error if request must wait */
00097 
00098 #define IPC_PRIVATE     (key_t)0 /* private key */
00099 
00100 #define IPC_RMID        0       /* remove identifier */
00101 #define IPC_SET         1       /* set options */
00102 #define IPC_STAT        2       /* get options */
00103 #if __BSD_VISIBLE
00104 #define IPC_INFO        3       /* get info */
00105 #endif
00106 
00107 #ifdef _KERNEL
00108 /* Macros to convert between ipc ids and array indices or sequence ids */
00109 #define IPCID_TO_IX(id)         ((id) & 0xffff)
00110 #define IPCID_TO_SEQ(id)        (((id) >> 16) & 0xffff)
00111 #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
00112 
00113 struct thread;
00114 struct proc;
00115 struct vmspace;
00116 
00117 extern void (*shmfork_hook)(struct proc *, struct proc *);
00118 extern void (*shmexit_hook)(struct vmspace *);
00119 
00120 #else /* ! _KERNEL */
00121 
00122 __BEGIN_DECLS
00123 /*
00124 * Convert a pathname and project identifier to an IPC key.
00125 */
00126 IMPORT_C key_t ftok(const char *pathname, int proj_id);
00127 
00128 __END_DECLS
00129 
00130 #endif /* _KERNEL */
00131 
00132 #endif /* !_SYS_IPC_H_ */
00133 
00134 
00135 
00136 //  End of File

Copyright © Nokia Corporation 2001-2008
Back to top