1/* $NetBSD: ipc.h,v 1.4 2011/05/24 18:29:23 joerg Exp $ */
2
3/*
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * This code is derived from software contributed to Berkeley by
13 * the Systems Programming Group of the University of Utah Computer
14 * Science Department.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * @(#)ipc.h 8.4 (Berkeley) 2/19/95
41 */
42
43/*
44 * SVID compatible ipc.h file
45 */
46
47#ifndef _COMPAT_SYS_IPC_H_
48#define _COMPAT_SYS_IPC_H_
49
50__BEGIN_DECLS
51/*
52 * Old IPC permission structure used before NetBSD 1.5.
53 */
54struct ipc_perm14 {
55 unsigned short cuid; /* creator user id */
56 unsigned short cgid; /* creator group id */
57 unsigned short uid; /* user id */
58 unsigned short gid; /* group id */
59 unsigned short mode; /* r/w permission */
60 unsigned short seq; /* sequence # (to generate unique
61 msg/sem/shm id) */
62 key_t key; /* user specified msg/sem/shm key */
63};
64
65static __inline void __ipc_perm14_to_native(const struct ipc_perm14 *, struct ipc_perm *);
66static __inline void __native_to_ipc_perm14(const struct ipc_perm *, struct ipc_perm14 *);
67static __inline void
68__ipc_perm14_to_native(const struct ipc_perm14 *operm, struct ipc_perm *perm)
69{
70
71#define CVT(x) perm->x = operm->x
72 CVT(uid);
73 CVT(gid);
74 CVT(cuid);
75 CVT(cgid);
76 CVT(mode);
77#undef CVT
78}
79
80static inline void
81__native_to_ipc_perm14(const struct ipc_perm *perm, struct ipc_perm14 *operm)
82{
83
84#define CVT(x) operm->x = perm->x
85 CVT(uid);
86 CVT(gid);
87 CVT(cuid);
88 CVT(cgid);
89 CVT(mode);
90#undef CVT
91
92 /*
93 * Not part of the API, but some programs might look at it.
94 */
95 operm->seq = perm->_seq;
96 operm->key = perm->_key;
97}
98
99#if defined(_KERNEL) && defined(SYSCTLFN_ARGS)
100int sysctl_kern_sysvipc50(SYSCTLFN_ARGS);
101#define KERN_SYSVIPC_OMSG_INFO 1 /* msginfo and msqid_ds50 */
102#define KERN_SYSVIPC_OSEM_INFO 2 /* seminfo and semid_ds50 */
103#define KERN_SYSVIPC_OSHM_INFO 3 /* shminfo and shmid_ds50 */
104#endif
105
106__END_DECLS
107
108#endif /* !_COMPAT_SYS_IPC_H_ */
109