1174891Sedwin/*
2174891Sedwin * Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
3174891Sedwin * All rights reserved.
4174891Sedwin *
5174891Sedwin * Redistribution and use in source and binary forms, with or without
6174891Sedwin * modification, are permitted provided that the following conditions
7174891Sedwin * are met:
8174891Sedwin * 1. Redistributions of source code must retain the above copyright
9174891Sedwin *    notice, this list of conditions and the following disclaimer.
10174891Sedwin * 2. Redistributions in binary form must reproduce the above copyright
11174891Sedwin *    notice, this list of conditions and the following disclaimer in the
12174891Sedwin *    documentation and/or other materials provided with the distribution.
13174891Sedwin * 3. The name of the author may not be used to endorse or promote products
14174891Sedwin *    derived from this software without specific prior written permission.
15174891Sedwin *
16174891Sedwin * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17174891Sedwin * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18174891Sedwin * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
19174891Sedwin * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20174891Sedwin * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21174891Sedwin * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22174891Sedwin * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23174891Sedwin * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24174891Sedwin * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25174891Sedwin * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26174891Sedwin *
27228992Suqs * The split of ipcs.c into ipcs.c and ipc.c to accommodate the
28174891Sedwin * changes in ipcrm.c was done by Edwin Groothuis <edwin@FreeBSD.org>
29174891Sedwin *
30174891Sedwin * $FreeBSD$
31174891Sedwin */
32174891Sedwin
33174891Sedwin/* Part of struct nlist symbols[] */
34174891Sedwin#define X_SEMA		0
35174891Sedwin#define X_SEMINFO	1
36174891Sedwin#define X_MSGINFO	2
37174891Sedwin#define X_MSQIDS	3
38174891Sedwin#define X_SHMINFO	4
39174891Sedwin#define X_SHMSEGS	5
40174891Sedwin
41174891Sedwin#define	SHMINFO		1
42174891Sedwin#define	SHMTOTAL	2
43174891Sedwin#define	MSGINFO		4
44174891Sedwin#define	MSGTOTAL	8
45174891Sedwin#define	SEMINFO		16
46174891Sedwin#define	SEMTOTAL	32
47174891Sedwin
48174891Sedwin#define IPC_TO_STR(x) (x == 'Q' ? "msq" : (x == 'M' ? "shm" : "sem"))
49174891Sedwin#define IPC_TO_STRING(x) (x == 'Q' ? "message queue" : \
50174891Sedwin	    (x == 'M' ? "shared memory segment" : "semaphore"))
51174891Sedwin
52174891Sedwin/* SysCtlGatherStruct structure. */
53174891Sedwinstruct scgs_vector {
54174891Sedwin	const char *sysctl;
55174891Sedwin	off_t offset;
56174891Sedwin	size_t size;
57174891Sedwin};
58174891Sedwin
59174891Sedwinvoid	kget(int idx, void *addr, size_t size);
60174891Sedwinvoid	sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vec);
61174891Sedwin
62174891Sedwinextern int use_sysctl;
63174891Sedwinextern struct nlist symbols[];
64174891Sedwinextern kvm_t *kd;
65174891Sedwin
66174891Sedwinextern struct semid_kernel	*sema;
67174891Sedwinextern struct seminfo		seminfo;
68174891Sedwinextern struct msginfo		msginfo;
69174891Sedwinextern struct msqid_kernel	*msqids;
70174891Sedwinextern struct shminfo		shminfo;
71174891Sedwinextern struct shmid_kernel	*shmsegs;
72