]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/ipcutils.h
2 * SPDX-License-Identifier: GPL-2.0-or-later
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * Copyright (C) 2012 Sami Kerola <kerolasa@iki.fi>
10 * Copyright (C) 2012-2023 Karel Zak <kzak@redhat.com>
12 #ifndef UTIL_LINUX_IPCUTILS_H
13 #define UTIL_LINUX_IPCUTILS_H
21 #include <sys/types.h>
29 * SHM_DEST and SHM_LOCKED are defined in kernel headers, but inside
30 * #ifdef __KERNEL__ ... #endif
33 /* shm_mode upper byte flags */
34 # define SHM_DEST 01000 /* segment will be destroyed on last detach */
35 # define SHM_LOCKED 02000 /* segment will not be swapped */
38 /* For older kernels the same holds for the defines below */
49 unsigned long shm_tot
; /* total allocated shm */
50 unsigned long shm_rss
; /* total resident shm */
51 unsigned long shm_swp
; /* total swapped shm */
52 unsigned long swap_attempts
;
53 unsigned long swap_successes
;
62 /* Some versions of libc only define IPC_INFO when __USE_GNU is defined. */
68 * * The last arg of semctl is a union semun, but where is it defined? X/OPEN
69 * * tells us to define it ourselves, but until recently Linux include files
70 * * would also define it.
72 #ifndef HAVE_UNION_SEMUN
73 /* according to X/OPEN we have to define it ourselves */
77 unsigned short int *array
;
78 struct seminfo
*__buf
;
83 * X/OPEN (Jan 1987) does not define fields key, seq in struct ipc_perm;
84 * glibc-1.09 has no support for sysv ipc.
85 * glibc 2 uses __key, __seq
87 #if defined (__GLIBC__) && __GLIBC__ >= 2
93 /* Size printing in ipcs is using these. */
102 uint64_t shmmni
; /* max number of segments */
103 uint64_t shmmax
; /* max segment size */
104 uint64_t shmall
; /* max total shared memory */
105 uint64_t shmmin
; /* min segment size */
107 int semmni
; /* max number of arrays */
108 int semmsl
; /* max semaphores per array */
109 int semmns
; /* max semaphores system wide */
110 int semopm
; /* max ops per semop call */
111 unsigned int semvmx
; /* semaphore max value (constant) */
113 int msgmni
; /* max queues system wide */
114 uint64_t msgmax
; /* max size of message */
115 int msgmnb
; /* default max size of queue */
118 extern int ipc_msg_get_limits(struct ipc_limits
*lim
);
119 extern int ipc_sem_get_limits(struct ipc_limits
*lim
);
120 extern int ipc_shm_get_limits(struct ipc_limits
*lim
);
125 uid_t uid
; /* current uid */
126 gid_t gid
; /* current gid */
127 uid_t cuid
; /* creator uid */
128 gid_t cgid
; /* creator gid */
132 extern void ipc_print_perms(FILE *f
, struct ipc_stat
*is
);
133 extern void ipc_print_size(int unit
, char *msg
, uint64_t size
, const char *end
, int width
);
135 /* See 'struct shmid_kernel' in kernel sources
138 struct ipc_stat shm_perm
;
142 int64_t shm_atim
; /* __kernel_time_t is signed long */
150 struct shm_data
*next
;
153 extern int ipc_shm_get_info(int id
, struct shm_data
**shmds
);
154 extern void ipc_shm_free_info(struct shm_data
*shmds
);
156 /* See 'struct sem_array' in kernel sources
160 int ncount
; /* processes waiting on increase semval */
161 int zcount
; /* processes waiting on semval set to zero */
162 pid_t pid
; /* process last executed semop(2) call */
165 struct ipc_stat sem_perm
;
171 struct sem_elem
*elements
;
172 struct sem_data
*next
;
175 extern int ipc_sem_get_info(int id
, struct sem_data
**semds
);
176 extern void ipc_sem_free_info(struct sem_data
*semds
);
178 /* See 'struct msg_queue' in kernel sources
181 struct ipc_stat msg_perm
;
192 struct msg_data
*next
;
195 extern int ipc_msg_get_info(int id
, struct msg_data
**msgds
);
196 extern void ipc_msg_free_info(struct msg_data
*msgds
);
198 #endif /* UTIL_LINUX_IPCUTILS_H */