Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / ipc.h @ 14

History | View | Annotate | Download (4.75 KB)

1
/*        $NetBSD: ipc.h,v 1.36 2015/05/19 12:17:53 joerg Exp $        */
2

    
3
/*
4
 * Copyright (c) 1988 University of Utah.
5
 * Copyright (c) 1990, 1993
6
 *        The Regents of the University of California.  All rights reserved.
7
 * (c) UNIX System Laboratories, Inc.
8
 * All or some portions of this file are derived from material licensed
9
 * to the University of California by American Telephone and Telegraph
10
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11
 * the permission of UNIX System Laboratories, Inc.
12
 *
13
 * This code is derived from software contributed to Berkeley by
14
 * the Systems Programming Group of the University of Utah Computer
15
 * Science Department.
16
 *
17
 * Redistribution and use in source and binary forms, with or without
18
 * modification, are permitted provided that the following conditions
19
 * are met:
20
 * 1. Redistributions of source code must retain the above copyright
21
 *    notice, this list of conditions and the following disclaimer.
22
 * 2. Redistributions in binary form must reproduce the above copyright
23
 *    notice, this list of conditions and the following disclaimer in the
24
 *    documentation and/or other materials provided with the distribution.
25
 * 3. Neither the name of the University nor the names of its contributors
26
 *    may be used to endorse or promote products derived from this software
27
 *    without specific prior written permission.
28
 *
29
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39
 * SUCH DAMAGE.
40
 *
41
 *        @(#)ipc.h        8.4 (Berkeley) 2/19/95
42
 */
43

    
44
/*
45
 * SVID compatible ipc.h file
46
 */
47

    
48
#ifndef _SYS_IPC_H_
49
#define _SYS_IPC_H_
50

    
51
#include <sys/featuretest.h>
52
#include <sys/types.h>
53

    
54
struct ipc_perm {
55
        uid_t                uid;        /* user id */
56
        gid_t                gid;        /* group id */
57
        uid_t                cuid;        /* creator user id */
58
        gid_t                cgid;        /* creator group id */
59
        mode_t                mode;        /* r/w permission */
60

    
61
        /*
62
         * These members are private and used only in the internal
63
         * implementation of this interface.
64
         */
65
        unsigned short        _seq;        /* sequence # (to generate unique
66
                                   msg/sem/shm id) */
67
        key_t                _key;        /* user specified msg/sem/shm key */
68
};
69

    
70
#if defined(_NETBSD_SOURCE)
71
/* Warning: 64-bit structure padding is needed here */
72
struct ipc_perm_sysctl {
73
        uint64_t        _key;
74
        uid_t                uid;
75
        gid_t                gid;
76
        uid_t                cuid;
77
        gid_t                cgid;
78
        mode_t                mode;
79
        int16_t                _seq;
80
        int16_t                pad;
81
};
82
#endif /* _NETBSD_SOURCE */
83

    
84
/* Common access type bits, used with ipcperm(). */
85
#define        IPC_R                000400        /* read permission */
86
#define        IPC_W                000200        /* write/alter permission */
87
#define        IPC_M                010000        /* permission to change control info */
88

    
89
/* X/Open required constants (same values as system 5) */
90
#define        IPC_CREAT        001000        /* create entry if key does not exist */
91
#define        IPC_EXCL        002000        /* fail if key exists */
92
#define        IPC_NOWAIT        004000        /* error if request must wait */
93

    
94
#define        IPC_PRIVATE        (key_t)0 /* private key */
95

    
96
#define        IPC_RMID        0        /* remove identifier */
97
#define        IPC_SET                1        /* set options */
98
#define        IPC_STAT        2        /* get options */
99

    
100
#if defined(__minix)
101
#define IPC_INFO       500       /* See ipcs. */
102
#endif /* !defined(__minix) */
103

    
104
/*
105
 * Macros to convert between ipc ids and array indices or sequence ids.
106
 * The first of these is used by ipcs(1), and so is defined outside the
107
 * kernel as well.
108
 */
109
#if defined(_NETBSD_SOURCE)
110
#define        IXSEQ_TO_IPCID(ix,perm)        (((perm._seq) << 16) | (ix & 0xffff))
111
#endif
112

    
113
#ifdef _KERNEL
114
#include <sys/sysctl.h>
115
#define        IPCID_TO_IX(id)                ((id) & 0xffff)
116
#define        IPCID_TO_SEQ(id)        (((id) >> 16) & 0xffff)
117

    
118
struct kauth_cred;
119
__BEGIN_DECLS
120
int        ipcperm(struct kauth_cred *, struct ipc_perm *, int);
121

    
122
void        sysvipcinit(void);
123
void        sysvipcfini(void);
124
__END_DECLS
125

    
126
/*
127
 * sysctl helper routine for kern.ipc.sysvipc_info subtree.
128
 */
129

    
130
#define SYSCTL_FILL_PERM(src, dst) do { \
131
        (dst)._key = (src)._key; \
132
        (dst).uid = (src).uid; \
133
        (dst).gid = (src).gid; \
134
        (dst).cuid = (src).cuid; \
135
        (dst).cgid = (src).cgid; \
136
        (dst).mode = (src).mode; \
137
        (dst)._seq = (src)._seq; \
138
} while (/*CONSTCOND*/ 0);
139

    
140
/*
141
 * Set-up the sysctl routine for COMPAT_50
142
 */
143

    
144
__BEGIN_DECLS
145
void sysvipc50_set_compat_sysctl(int (*)(SYSCTLFN_PROTO));
146
__END_DECLS
147

    
148
#else /* _KERNEL */
149
__BEGIN_DECLS
150
key_t        ftok(const char *, int);
151
__END_DECLS
152
#endif
153
#endif /* !_SYS_IPC_H_ */