Home | History | Annotate | Line # | Download | only in sys
      1 /*	$NetBSD: ipc.h,v 1.7 2019/02/21 08:25:00 mrg 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 #ifdef _KERNEL
     51 #include <lib/libkern/libkern.h>
     52 #else
     53 #include <string.h>
     54 #endif
     55 
     56 __BEGIN_DECLS
     57 /*
     58  * Old IPC permission structure used before NetBSD 1.5.
     59  */
     60 struct ipc_perm14 {
     61 	unsigned short	cuid;	/* creator user id */
     62 	unsigned short	cgid;	/* creator group id */
     63 	unsigned short	uid;	/* user id */
     64 	unsigned short	gid;	/* group id */
     65 	unsigned short	mode;	/* r/w permission */
     66 	unsigned short	seq;	/* sequence # (to generate unique
     67 				   msg/sem/shm id) */
     68 	key_t	key;		/* user specified msg/sem/shm key */
     69 };
     70 
     71 static __inline void	__ipc_perm14_to_native(const struct ipc_perm14 *, struct ipc_perm *);
     72 static __inline void	__native_to_ipc_perm14(const struct ipc_perm *, struct ipc_perm14 *);
     73 static __inline void
     74 __ipc_perm14_to_native(const struct ipc_perm14 *operm, struct ipc_perm *perm)
     75 {
     76 
     77 	memset(perm, 0, sizeof *perm);
     78 #define	CVT(x)	perm->x = operm->x
     79 	CVT(uid);
     80 	CVT(gid);
     81 	CVT(cuid);
     82 	CVT(cgid);
     83 	CVT(mode);
     84 #undef CVT
     85 }
     86 
     87 static __inline void
     88 __native_to_ipc_perm14(const struct ipc_perm *perm, struct ipc_perm14 *operm)
     89 {
     90 
     91 	memset(operm, 0, sizeof *operm);
     92 #define	CVT(x)	operm->x = perm->x
     93 	CVT(uid);
     94 	CVT(gid);
     95 	CVT(cuid);
     96 	CVT(cgid);
     97 	CVT(mode);
     98 #undef CVT
     99 
    100 	/*
    101 	 * Not part of the API, but some programs might look at it.
    102 	 */
    103 	operm->seq = perm->_seq;
    104 	operm->key = perm->_key;
    105 }
    106 
    107 #if defined(_KERNEL) && defined(SYSCTLFN_ARGS)
    108 int sysctl_kern_sysvipc50(SYSCTLFN_ARGS);
    109 #define	KERN_SYSVIPC_OMSG_INFO		1	/* msginfo and msqid_ds50 */
    110 #define	KERN_SYSVIPC_OSEM_INFO		2	/* seminfo and semid_ds50 */
    111 #define	KERN_SYSVIPC_OSHM_INFO		3	/* shminfo and shmid_ds50 */
    112 #endif
    113 
    114 __END_DECLS
    115 
    116 #endif /* !_COMPAT_SYS_IPC_H_ */
    117