]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/ipcs.c
ipcs: do not gettextize wordless strings
[thirdparty/util-linux.git] / sys-utils / ipcs.c
1 /* Original author unknown, may be "krishna balasub@cis.ohio-state.edu" */
2 /*
3 * Modified Sat Oct 9 10:55:28 1993 for 0.99.13
4 *
5 * Patches from Mike Jagdis (jaggy@purplet.demon.co.uk) applied Wed Feb 8
6 * 12:12:21 1995 by faith@cs.unc.edu to print numeric uids if no passwd file
7 * entry.
8 *
9 * Patch from arnolds@ifns.de (Heinz-Ado Arnolds) applied Mon Jul 1 19:30:41
10 * 1996 by janl@math.uio.no to add code missing in case PID: clauses.
11 *
12 * Patched to display the key field -- hy@picksys.com 12/18/96
13 *
14 * 1999-02-22 Arkadiusz Miƛkiewicz <misiek@pld.ORG.PL>
15 * - added Native Language Support
16 */
17
18 #include <errno.h>
19 #include <features.h>
20 #include <getopt.h>
21
22 #include "c.h"
23 #include "nls.h"
24 #include "closestream.h"
25
26 #include "ipcutils.h"
27
28 enum output_formats {
29 NOTSPECIFIED,
30 LIMITS,
31 STATUS,
32 CREATOR,
33 TIME,
34 PID
35 };
36 enum {
37 OPT_HUMAN = CHAR_MAX + 1
38 };
39
40 static void do_shm (char format, int unit);
41 static void print_shm (int id, int unit);
42 static void do_sem (char format);
43 static void print_sem (int id);
44 static void do_msg (char format, int unit);
45 static void print_msg (int id, int unit);
46
47 /* we read time as int64_t from /proc, so cast... */
48 #define xctime(_x) ctime((time_t *) (_x))
49
50 static void __attribute__ ((__noreturn__)) usage(FILE * out)
51 {
52 fprintf(out, USAGE_HEADER);
53 fprintf(out, " %s [resource ...] [output-format]\n", program_invocation_short_name);
54 fprintf(out, " %s [resource] -i <id>\n", program_invocation_short_name);
55 fprintf(out, USAGE_OPTIONS);
56 fputs(_(" -i, --id <id> print details on resource identified by <id>\n"), out);
57 fprintf(out, USAGE_HELP);
58 fprintf(out, USAGE_VERSION);
59 fprintf(out, USAGE_SEPARATOR);
60 fputs(_("Resource options:\n"), out);
61 fputs(_(" -m, --shmems shared memory segments\n"), out);
62 fputs(_(" -q, --queues message queues\n"), out);
63 fputs(_(" -s, --semaphores semaphores\n"), out);
64 fputs(_(" -a, --all all (default)\n"), out);
65 fprintf(out, USAGE_SEPARATOR);
66 fputs(_("Output format:\n"), out);
67 fputs(_(" -t, --time show attach, detach and change times\n"), out);
68 fputs(_(" -p, --pid show PIDs of creator and last operator\n"), out);
69 fputs(_(" -c, --creator show creator and owner\n"), out);
70 fputs(_(" -l, --limits show resource limits\n"), out);
71 fputs(_(" -u, --summary show status summary\n"), out);
72 fputs(_(" --human show sizes in human-readable format\n"), out);
73 fputs(_(" -b, --bytes show sizes in bytes\n"), out);
74 fprintf(out, USAGE_MAN_TAIL("ipcs(1)"));
75 exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
76 }
77
78 int main (int argc, char **argv)
79 {
80 int opt, msg = 0, shm = 0, sem = 0, id = 0, specific = 0;
81 char format = NOTSPECIFIED;
82 int unit = IPC_UNIT_DEFAULT;
83 static const struct option longopts[] = {
84 {"id", required_argument, NULL, 'i'},
85 {"queues", no_argument, NULL, 'q'},
86 {"shmems", no_argument, NULL, 'm'},
87 {"semaphores", no_argument, NULL, 's'},
88 {"all", no_argument, NULL, 'a'},
89 {"time", no_argument, NULL, 't'},
90 {"pid", no_argument, NULL, 'p'},
91 {"creator", no_argument, NULL, 'c'},
92 {"limits", no_argument, NULL, 'l'},
93 {"summary", no_argument, NULL, 'u'},
94 {"human", no_argument, NULL, OPT_HUMAN},
95 {"bytes", no_argument, NULL, 'b'},
96 {"version", no_argument, NULL, 'V'},
97 {"help", no_argument, NULL, 'h'},
98 {NULL, 0, NULL, 0}
99 };
100 char options[] = "i:qmsatpclubVh";
101
102 setlocale(LC_ALL, "");
103 bindtextdomain(PACKAGE, LOCALEDIR);
104 textdomain(PACKAGE);
105 atexit(close_stdout);
106
107 while ((opt = getopt_long(argc, argv, options, longopts, NULL)) != -1) {
108 switch (opt) {
109 case 'i':
110 id = atoi (optarg);
111 specific = 1;
112 break;
113 case 'a':
114 msg = shm = sem = 1;
115 break;
116 case 'q':
117 msg = 1;
118 break;
119 case 'm':
120 shm = 1;
121 break;
122 case 's':
123 sem = 1;
124 break;
125 case 't':
126 format = TIME;
127 break;
128 case 'c':
129 format = CREATOR;
130 break;
131 case 'p':
132 format = PID;
133 break;
134 case 'l':
135 format = LIMITS;
136 break;
137 case 'u':
138 format = STATUS;
139 break;
140 case OPT_HUMAN:
141 unit = IPC_UNIT_HUMAN;
142 break;
143 case 'b':
144 unit = IPC_UNIT_BYTES;
145 break;
146 case 'h':
147 usage(stdout);
148 case 'V':
149 printf(UTIL_LINUX_VERSION);
150 return EXIT_SUCCESS;
151 default:
152 usage(stderr);
153 }
154 }
155
156 if (specific && (msg + shm + sem != 1))
157 errx (EXIT_FAILURE,
158 _("when using an ID, a single resource must be specified"));
159 if (specific) {
160 if (msg)
161 print_msg (id, unit);
162 if (shm)
163 print_shm (id, unit);
164 if (sem)
165 print_sem (id);
166 } else {
167 if (!msg && !shm && !sem)
168 msg = shm = sem = 1;
169 printf ("\n");
170 if (msg) {
171 do_msg (format, unit);
172 printf ("\n");
173 }
174 if (shm) {
175 do_shm (format, unit);
176 printf ("\n");
177 }
178 if (sem) {
179 do_sem (format);
180 printf ("\n");
181 }
182 }
183 return EXIT_SUCCESS;
184 }
185
186 static void do_shm (char format, int unit)
187 {
188 struct passwd *pw;
189 struct shm_data *shmds, *shmdsp;
190
191 switch (format) {
192 case LIMITS:
193 {
194 struct ipc_limits lim;
195
196 printf (_("------ Shared Memory Limits --------\n"));
197 if (ipc_shm_get_limits(&lim))
198 return;
199 printf (_("max number of segments = %ju\n"), lim.shmmni);
200 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : unit,
201 _("max seg size"), lim.shmmax, "\n", 0);
202 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_KB : unit,
203 _("max total shared memory"),
204 (uint64_t) lim.shmall * getpagesize(), "\n", 0);
205 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
206 _("min seg size"), lim.shmmin, "\n", 0);
207 return;
208 }
209 case STATUS:
210 {
211 int maxid;
212 struct shm_info shm_info;
213
214 maxid = shmctl (0, SHM_INFO, (struct shmid_ds *) &shm_info);
215 if (maxid < 0) {
216 printf (_("kernel not configured for shared memory\n"));
217 return;
218 }
219
220 printf (_("------ Shared Memory Status --------\n"));
221 /*
222 * TRANSLATORS: This output format is maintained for backward
223 * compatibility as ipcs is used in scripts. For consistency
224 * with the rest, the translated form can follow this model:
225 *
226 * "segments allocated = %d\n"
227 * "pages allocated = %ld\n"
228 * "pages resident = %ld\n"
229 * "pages swapped = %ld\n"
230 * "swap performance = %ld attempts, %ld successes\n"
231 */
232 printf (_("segments allocated %d\n"
233 "pages allocated %ld\n"
234 "pages resident %ld\n"
235 "pages swapped %ld\n"
236 "Swap performance: %ld attempts\t %ld successes\n"),
237 shm_info.used_ids,
238 shm_info.shm_tot,
239 shm_info.shm_rss,
240 shm_info.shm_swp,
241 shm_info.swap_attempts, shm_info.swap_successes);
242 return;
243 }
244
245 /*
246 * Headers only
247 */
248 case CREATOR:
249 printf (_("------ Shared Memory Segment Creators/Owners --------\n"));
250 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
251 _("shmid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
252 break;
253
254 case TIME:
255 printf (_("------ Shared Memory Attach/Detach/Change Times --------\n"));
256 printf ("%-10s %-10s %-20s %-20s %-20s\n",
257 _("shmid"),_("owner"),_("attached"),_("detached"),
258 _("changed"));
259 break;
260
261 case PID:
262 printf (_("------ Shared Memory Creator/Last-op PIDs --------\n"));
263 printf ("%-10s %-10s %-10s %-10s\n",
264 _("shmid"),_("owner"),_("cpid"),_("lpid"));
265 break;
266
267 default:
268 printf (_("------ Shared Memory Segments --------\n"));
269 printf ("%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
270 _("key"),_("shmid"),_("owner"),_("perms"),
271 unit == IPC_UNIT_HUMAN ? _("size") : _("bytes"),
272 _("nattch"),_("status"));
273 break;
274 }
275
276 /*
277 * Print data
278 */
279 if (ipc_shm_get_info(-1, &shmds) < 1)
280 return;
281
282 for (shmdsp = shmds; shmdsp->next != NULL; shmdsp = shmdsp->next) {
283 if (format == CREATOR) {
284 ipc_print_perms(stdout, &shmdsp->shm_perm);
285 continue;
286 }
287 pw = getpwuid(shmdsp->shm_perm.uid);
288 switch (format) {
289 case TIME:
290 if (pw)
291 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
292 else
293 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
294 /* ctime uses static buffer: use separate calls */
295 printf(" %-20.16s", shmdsp->shm_atim
296 ? xctime(&shmdsp->shm_atim) + 4 : _("Not set"));
297 printf(" %-20.16s", shmdsp->shm_dtim
298 ? xctime(&shmdsp->shm_dtim) + 4 : _("Not set"));
299 printf(" %-20.16s\n", shmdsp->shm_ctim
300 ? xctime(&shmdsp->shm_ctim) + 4 : _("Not set"));
301 break;
302 case PID:
303 if (pw)
304 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
305 else
306 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
307 printf (" %-10u %-10u\n",
308 shmdsp->shm_cprid, shmdsp->shm_lprid);
309 break;
310
311 default:
312 printf("0x%08x ", shmdsp->shm_perm.key);
313 if (pw)
314 printf ("%-10d %-10.10s", shmdsp->shm_perm.id, pw->pw_name);
315 else
316 printf ("%-10d %-10u", shmdsp->shm_perm.id, shmdsp->shm_perm.uid);
317 printf (" %-10o ", shmdsp->shm_perm.mode & 0777);
318
319 if (unit == IPC_UNIT_HUMAN)
320 ipc_print_size(unit, NULL, shmdsp->shm_segsz, " ", 6);
321 else
322 ipc_print_size(unit, NULL, shmdsp->shm_segsz, NULL, -10);
323
324 printf (" %-10ju %-6s %-6s\n",
325 shmdsp->shm_nattch,
326 shmdsp->shm_perm.mode & SHM_DEST ? _("dest") : " ",
327 shmdsp->shm_perm.mode & SHM_LOCKED ? _("locked") : " ");
328 break;
329 }
330 }
331
332 ipc_shm_free_info(shmds);
333 return;
334 }
335
336 static void do_sem (char format)
337 {
338 struct passwd *pw;
339 struct sem_data *semds, *semdsp;
340
341 switch (format) {
342 case LIMITS:
343 {
344 struct ipc_limits lim;
345
346 printf (_("------ Semaphore Limits --------\n"));
347 if (ipc_sem_get_limits(&lim))
348 return;
349 printf (_("max number of arrays = %d\n"), lim.semmni);
350 printf (_("max semaphores per array = %d\n"), lim.semmsl);
351 printf (_("max semaphores system wide = %d\n"), lim.semmns);
352 printf (_("max ops per semop call = %d\n"), lim.semopm);
353 printf (_("semaphore max value = %d\n"), lim.semvmx);
354 return;
355 }
356 case STATUS:
357 {
358 struct seminfo seminfo;
359 union semun arg;
360 arg.array = (ushort *) (void *) &seminfo;
361 if (semctl (0, 0, SEM_INFO, arg) < 0) {
362 printf (_("kernel not configured for semaphores\n"));
363 return;
364 }
365 printf (_("------ Semaphore Status --------\n"));
366 printf (_("used arrays = %d\n"), seminfo.semusz);
367 printf (_("allocated semaphores = %d\n"), seminfo.semaem);
368 return;
369 }
370
371 case CREATOR:
372 printf (_("------ Semaphore Arrays Creators/Owners --------\n"));
373 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
374 _("semid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
375 break;
376
377 case TIME:
378 printf (_("------ Semaphore Operation/Change Times --------\n"));
379 printf ("%-8s %-10s %-26.24s %-26.24s\n",
380 _("semid"),_("owner"),_("last-op"),_("last-changed"));
381 break;
382
383 case PID:
384 break;
385
386 default:
387 printf (_("------ Semaphore Arrays --------\n"));
388 printf ("%-10s %-10s %-10s %-10s %-10s\n",
389 _("key"),_("semid"),_("owner"),_("perms"),_("nsems"));
390 break;
391 }
392
393 /*
394 * Print data
395 */
396 if (ipc_sem_get_info(-1, &semds) < 1)
397 return;
398
399 for (semdsp = semds; semdsp->next != NULL; semdsp = semdsp->next) {
400 if (format == CREATOR) {
401 ipc_print_perms(stdout, &semdsp->sem_perm);
402 continue;
403 }
404 pw = getpwuid(semdsp->sem_perm.uid);
405 switch (format) {
406 case TIME:
407 if (pw)
408 printf ("%-8d %-10.10s", semdsp->sem_perm.id, pw->pw_name);
409 else
410 printf ("%-8d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
411 printf (" %-26.24s", semdsp->sem_otime
412 ? xctime(&semdsp->sem_otime) : _("Not set"));
413 printf (" %-26.24s\n", semdsp->sem_ctime
414 ? xctime( &semdsp->sem_ctime) : _("Not set"));
415 break;
416 case PID:
417 break;
418
419 default:
420 printf("0x%08x ", semdsp->sem_perm.key);
421 if (pw)
422 printf ("%-10d %-10.10s", semdsp->sem_perm.id, pw->pw_name);
423 else
424 printf ("%-10d %-10u", semdsp->sem_perm.id, semdsp->sem_perm.uid);
425 printf (" %-10o %-10ju\n",
426 semdsp->sem_perm.mode & 0777,
427 semdsp->sem_nsems);
428 break;
429 }
430 }
431
432 ipc_sem_free_info(semds);
433 return;
434 }
435
436 static void do_msg (char format, int unit)
437 {
438 struct passwd *pw;
439 struct msg_data *msgds, *msgdsp;
440
441 switch (format) {
442 case LIMITS:
443 {
444 struct ipc_limits lim;
445
446 if (ipc_msg_get_limits(&lim))
447 return;
448 printf (_("------ Messages Limits --------\n"));
449 printf (_("max queues system wide = %d\n"), lim.msgmni);
450 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
451 _("max size of message"), lim.msgmax, "\n", 0);
452 ipc_print_size(unit == IPC_UNIT_DEFAULT ? IPC_UNIT_BYTES : unit,
453 _("default max size of queue"), lim.msgmnb, "\n", 0);
454 return;
455 }
456 case STATUS:
457 {
458 struct msginfo msginfo;
459 if (msgctl (0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo) < 0) {
460 printf (_("kernel not configured for message queues\n"));
461 return;
462 }
463 printf (_("------ Messages Status --------\n"));
464 printf (_("allocated queues = %d\n"), msginfo.msgpool);
465 printf (_("used headers = %d\n"), msginfo.msgmap);
466 ipc_print_size(unit, _("used space"), msginfo.msgtql,
467 unit == IPC_UNIT_DEFAULT ? _(" bytes\n") : "\n", 0);
468 return;
469 }
470 case CREATOR:
471 printf (_("------ Message Queues Creators/Owners --------\n"));
472 printf ("%-10s %-10s %-10s %-10s %-10s %-10s\n",
473 _("msqid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid"));
474 break;
475
476 case TIME:
477 printf (_("------ Message Queues Send/Recv/Change Times --------\n"));
478 printf ("%-8s %-10s %-20s %-20s %-20s\n",
479 _("msqid"),_("owner"),_("send"),_("recv"),_("change"));
480 break;
481
482 case PID:
483 printf (_("------ Message Queues PIDs --------\n"));
484 printf ("%-10s %-10s %-10s %-10s\n",
485 _("msqid"),_("owner"),_("lspid"),_("lrpid"));
486 break;
487
488 default:
489 printf (_("------ Message Queues --------\n"));
490 printf ("%-10s %-10s %-10s %-10s %-12s %-12s\n",
491 _("key"), _("msqid"), _("owner"), _("perms"),
492 unit == IPC_UNIT_HUMAN ? _("size") : _("used-bytes"),
493 _("messages"));
494 break;
495 }
496
497 /*
498 * Print data
499 */
500 if (ipc_msg_get_info(-1, &msgds) < 1)
501 return;
502
503 for (msgdsp = msgds; msgdsp->next != NULL; msgdsp = msgdsp->next) {
504 if (format == CREATOR) {
505 ipc_print_perms(stdout, &msgdsp->msg_perm);
506 continue;
507 }
508 pw = getpwuid(msgdsp->msg_perm.uid);
509 switch (format) {
510 case TIME:
511 if (pw)
512 printf ("%-8d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
513 else
514 printf ("%-8d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
515 printf (" %-20.16s", msgdsp->q_stime
516 ? xctime(&msgdsp->q_stime) + 4 : _("Not set"));
517 printf (" %-20.16s", msgdsp->q_rtime
518 ? xctime(&msgdsp->q_rtime) + 4 : _("Not set"));
519 printf (" %-20.16s\n", msgdsp->q_ctime
520 ? xctime(&msgdsp->q_ctime) + 4 : _("Not set"));
521 break;
522 case PID:
523 if (pw)
524 printf ("%-8d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
525 else
526 printf ("%-8d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
527 printf (" %5d %5d\n",
528 msgdsp->q_lspid, msgdsp->q_lrpid);
529 break;
530
531 default:
532 printf( "0x%08x ",msgdsp->msg_perm.key );
533 if (pw)
534 printf ("%-10d %-10.10s", msgdsp->msg_perm.id, pw->pw_name);
535 else
536 printf ("%-10d %-10u", msgdsp->msg_perm.id, msgdsp->msg_perm.uid);
537 printf (" %-10o ", msgdsp->msg_perm.mode & 0777);
538
539 if (unit == IPC_UNIT_HUMAN)
540 ipc_print_size(unit, NULL, msgdsp->q_cbytes, " ", 6);
541 else
542 ipc_print_size(unit, NULL, msgdsp->q_cbytes, NULL, -12);
543
544 printf (" %-12ju\n", msgdsp->q_qnum);
545 break;
546 }
547 }
548
549 ipc_msg_free_info(msgds);
550 return;
551 }
552
553 static void print_shm(int shmid, int unit)
554 {
555 struct shm_data *shmdata;
556
557 if (ipc_shm_get_info(shmid, &shmdata) < 1) {
558 warnx(_("id %d not found"), shmid);
559 return;
560 }
561
562 printf(_("\nShared memory Segment shmid=%d\n"), shmid);
563 printf(_("uid=%u\tgid=%u\tcuid=%u\tcgid=%u\n"),
564 shmdata->shm_perm.uid, shmdata->shm_perm.uid,
565 shmdata->shm_perm.cuid, shmdata->shm_perm.cgid);
566 printf(_("mode=%#o\taccess_perms=%#o\n"), shmdata->shm_perm.mode,
567 shmdata->shm_perm.mode & 0777);
568 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("size=") : _("bytes="),
569 shmdata->shm_segsz, "\t", 0);
570 printf(_("lpid=%u\tcpid=%u\tnattch=%jd\n"),
571 shmdata->shm_lprid, shmdata->shm_cprid,
572 shmdata->shm_nattch);
573 printf(_("att_time=%-26.24s\n"),
574 shmdata->shm_atim ? xctime(&(shmdata->shm_atim)) : _("Not set"));
575 printf(_("det_time=%-26.24s\n"),
576 shmdata->shm_dtim ? xctime(&shmdata->shm_dtim) : _("Not set"));
577 printf(_("change_time=%-26.24s\n"), xctime(&shmdata->shm_ctim));
578 printf("\n");
579
580 ipc_shm_free_info(shmdata);
581 }
582
583 void print_msg(int msgid, int unit)
584 {
585 struct msg_data *msgdata;
586
587 if (ipc_msg_get_info(msgid, &msgdata) < 1) {
588 warnx(_("id %d not found"), msgid);
589 return;
590 }
591
592 printf(_("\nMessage Queue msqid=%d\n"), msgid);
593 printf(_("uid=%u\tgid=%u\tcuid=%u\tcgid=%u\tmode=%#o\n"),
594 msgdata->msg_perm.uid, msgdata->msg_perm.uid,
595 msgdata->msg_perm.cuid, msgdata->msg_perm.cgid,
596 msgdata->msg_perm.mode);
597 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("csize=") : _("cbytes="),
598 msgdata->q_cbytes, "\t", 0);
599 ipc_print_size(unit, unit == IPC_UNIT_HUMAN ? _("qsize=") : _("qbytes="),
600 msgdata->q_qbytes, "\t", 0);
601 printf("qnum=%jd\tlspid=%d\tlrpid=%d\n",
602 msgdata->q_qnum,
603 msgdata->q_lspid, msgdata->q_lrpid);
604 printf(_("send_time=%-26.24s\n"),
605 msgdata->q_stime ? xctime(&msgdata->q_stime) : _("Not set"));
606 printf(_("rcv_time=%-26.24s\n"),
607 msgdata->q_rtime ? xctime(&msgdata->q_rtime) : _("Not set"));
608 printf(_("change_time=%-26.24s\n"),
609 msgdata->q_ctime ? xctime(&msgdata->q_ctime) : _("Not set"));
610 printf("\n");
611
612 ipc_msg_free_info(msgdata);
613 }
614
615 static void print_sem(int semid)
616 {
617 struct sem_data *semdata;
618 size_t i;
619
620 if (ipc_sem_get_info(semid, &semdata) < 1) {
621 warnx(_("id %d not found"), semid);
622 return;
623 }
624
625 printf(_("\nSemaphore Array semid=%d\n"), semid);
626 printf(_("uid=%u\t gid=%u\t cuid=%u\t cgid=%u\n"),
627 semdata->sem_perm.uid, semdata->sem_perm.uid,
628 semdata->sem_perm.cuid, semdata->sem_perm.cgid);
629 printf(_("mode=%#o, access_perms=%#o\n"),
630 semdata->sem_perm.mode, semdata->sem_perm.mode & 0777);
631 printf(_("nsems = %ju\n"), semdata->sem_nsems);
632 printf(_("otime = %-26.24s\n"),
633 semdata->sem_otime ? xctime(&semdata->sem_otime) : _("Not set"));
634 printf(_("ctime = %-26.24s\n"), xctime(&semdata->sem_ctime));
635
636 printf("%-10s %-10s %-10s %-10s %-10s\n",
637 _("semnum"), _("value"), _("ncount"), _("zcount"), _("pid"));
638
639 for (i = 0; i < semdata->sem_nsems; i++) {
640 struct sem_elem *e = &semdata->elements[i];
641 printf("%-10zd %-10d %-10d %-10d %-10d\n",
642 i, e->semval, e->ncount, e->zcount, e->pid);
643 }
644 printf("\n");
645 ipc_sem_free_info(semdata);
646 }