Stylify ipcs/ipcs.c and ipcrm/ipcrm in preparation of the upcoming
changes as proposed in bin/118292. Feel free to mention any I have missed, there is much to learn with regarding to style(9). Approved by: grog@
This commit is contained in:
parent
8411d52a93
commit
fa44a2923e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174750
@ -32,17 +32,18 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/msg.h>
|
||||||
|
#include <sys/sem.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ipc.h>
|
|
||||||
#include <sys/msg.h>
|
|
||||||
#include <sys/sem.h>
|
|
||||||
#include <sys/shm.h>
|
|
||||||
|
|
||||||
#define IPC_TO_STR(x) (x == 'Q' ? "msq" : (x == 'M' ? "shm" : "sem"))
|
#define IPC_TO_STR(x) (x == 'Q' ? "msq" : (x == 'M' ? "shm" : "sem"))
|
||||||
#define IPC_TO_STRING(x) (x == 'Q' ? "message queue" : \
|
#define IPC_TO_STRING(x) (x == 'Q' ? "message queue" : \
|
||||||
@ -56,117 +57,133 @@ int shmrm(key_t, int);
|
|||||||
int semrm(key_t, int);
|
int semrm(key_t, int);
|
||||||
void not_configured(int);
|
void not_configured(int);
|
||||||
|
|
||||||
void usage(void)
|
void
|
||||||
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n%s\n",
|
|
||||||
"usage: ipcrm [-q msqid] [-m shmid] [-s semid]",
|
fprintf(stderr,
|
||||||
" [-Q msgkey] [-M shmkey] [-S semkey] ...");
|
"usage: ipcrm [-q msqid] [-m shmid] [-s semid]\n"
|
||||||
|
" [-Q msgkey] [-M shmkey] [-S semkey] ...\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int msgrm(key_t key, int id)
|
int
|
||||||
|
msgrm(key_t key, int id)
|
||||||
{
|
{
|
||||||
if (key) {
|
|
||||||
id = msgget(key, 0);
|
|
||||||
if (id == -1)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return msgctl(id, IPC_RMID, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int shmrm(key_t key, int id)
|
if (key) {
|
||||||
{
|
id = msgget(key, 0);
|
||||||
if (key) {
|
if (id == -1)
|
||||||
id = shmget(key, 0, 0);
|
return -1;
|
||||||
if (id == -1)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return shmctl(id, IPC_RMID, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int semrm(key_t key, int id)
|
|
||||||
{
|
|
||||||
union semun arg;
|
|
||||||
|
|
||||||
if (key) {
|
|
||||||
id = semget(key, 0, 0);
|
|
||||||
if (id == -1)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return semctl(id, 0, IPC_RMID, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void not_configured(int signo __unused)
|
|
||||||
{
|
|
||||||
signaled++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int c, result, errflg, target_id;
|
|
||||||
key_t target_key;
|
|
||||||
|
|
||||||
errflg = 0;
|
|
||||||
signal(SIGSYS, not_configured);
|
|
||||||
while ((c = getopt(argc, argv, ":q:m:s:Q:M:S:")) != -1) {
|
|
||||||
|
|
||||||
signaled = 0;
|
|
||||||
switch (c) {
|
|
||||||
case 'q':
|
|
||||||
case 'm':
|
|
||||||
case 's':
|
|
||||||
target_id = atoi(optarg);
|
|
||||||
if (c == 'q')
|
|
||||||
result = msgrm(0, target_id);
|
|
||||||
else if (c == 'm')
|
|
||||||
result = shmrm(0, target_id);
|
|
||||||
else
|
|
||||||
result = semrm(0, target_id);
|
|
||||||
if (result < 0) {
|
|
||||||
errflg++;
|
|
||||||
if (!signaled)
|
|
||||||
warn("%sid(%d): ", IPC_TO_STR(toupper(c)), target_id);
|
|
||||||
else
|
|
||||||
warnx("%ss are not configured in the running kernel",
|
|
||||||
IPC_TO_STRING(toupper(c)));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
case 'M':
|
|
||||||
case 'S':
|
|
||||||
target_key = atol(optarg);
|
|
||||||
if (target_key == IPC_PRIVATE) {
|
|
||||||
warnx("can't remove private %ss", IPC_TO_STRING(c));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c == 'Q')
|
|
||||||
result = msgrm(target_key, 0);
|
|
||||||
else if (c == 'M')
|
|
||||||
result = shmrm(target_key, 0);
|
|
||||||
else
|
|
||||||
result = semrm(target_key, 0);
|
|
||||||
if (result < 0) {
|
|
||||||
errflg++;
|
|
||||||
if (!signaled)
|
|
||||||
warn("%ss(%ld): ", IPC_TO_STR(c), target_key);
|
|
||||||
else
|
|
||||||
warnx("%ss are not configured in the running kernel",
|
|
||||||
IPC_TO_STRING(c));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ':':
|
|
||||||
fprintf(stderr, "option -%c requires an argument\n", optopt);
|
|
||||||
usage();
|
|
||||||
case '?':
|
|
||||||
fprintf(stderr, "unrecognized option: -%c\n", optopt);
|
|
||||||
usage();
|
|
||||||
}
|
}
|
||||||
}
|
return msgctl(id, IPC_RMID, NULL);
|
||||||
|
|
||||||
if (optind != argc) {
|
|
||||||
fprintf(stderr, "unknown argument: %s\n", argv[optind]);
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
exit(errflg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
shmrm(key_t key, int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (key) {
|
||||||
|
id = shmget(key, 0, 0);
|
||||||
|
if (id == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return shmctl(id, IPC_RMID, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
semrm(key_t key, int id)
|
||||||
|
{
|
||||||
|
union semun arg;
|
||||||
|
|
||||||
|
if (key) {
|
||||||
|
id = semget(key, 0, 0);
|
||||||
|
if (id == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return semctl(id, 0, IPC_RMID, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
not_configured(int signo __unused)
|
||||||
|
{
|
||||||
|
|
||||||
|
signaled++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int c, result, errflg, target_id;
|
||||||
|
key_t target_key;
|
||||||
|
|
||||||
|
errflg = 0;
|
||||||
|
signal(SIGSYS, not_configured);
|
||||||
|
while ((c = getopt(argc, argv, ":q:m:s:Q:M:S:")) != -1) {
|
||||||
|
|
||||||
|
signaled = 0;
|
||||||
|
switch (c) {
|
||||||
|
case 'q':
|
||||||
|
case 'm':
|
||||||
|
case 's':
|
||||||
|
target_id = atoi(optarg);
|
||||||
|
if (c == 'q')
|
||||||
|
result = msgrm(0, target_id);
|
||||||
|
else if (c == 'm')
|
||||||
|
result = shmrm(0, target_id);
|
||||||
|
else
|
||||||
|
result = semrm(0, target_id);
|
||||||
|
if (result < 0) {
|
||||||
|
errflg++;
|
||||||
|
if (!signaled)
|
||||||
|
warn("%sid(%d): ",
|
||||||
|
IPC_TO_STR(toupper(c)), target_id);
|
||||||
|
else
|
||||||
|
warnx(
|
||||||
|
"%ss are not configured "
|
||||||
|
"in the running kernel",
|
||||||
|
IPC_TO_STRING(toupper(c)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
case 'M':
|
||||||
|
case 'S':
|
||||||
|
target_key = atol(optarg);
|
||||||
|
if (target_key == IPC_PRIVATE) {
|
||||||
|
warnx("can't remove private %ss",
|
||||||
|
IPC_TO_STRING(c));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == 'Q')
|
||||||
|
result = msgrm(target_key, 0);
|
||||||
|
else if (c == 'M')
|
||||||
|
result = shmrm(target_key, 0);
|
||||||
|
else
|
||||||
|
result = semrm(target_key, 0);
|
||||||
|
if (result < 0) {
|
||||||
|
errflg++;
|
||||||
|
if (!signaled)
|
||||||
|
warn("%ss(%ld): ",
|
||||||
|
IPC_TO_STR(c), target_key);
|
||||||
|
else
|
||||||
|
warnx("%ss are not configured "
|
||||||
|
"in the running kernel",
|
||||||
|
IPC_TO_STRING(c));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ':':
|
||||||
|
fprintf(stderr,
|
||||||
|
"option -%c requires an argument\n", optopt);
|
||||||
|
usage();
|
||||||
|
case '?':
|
||||||
|
fprintf(stderr, "unrecognized option: -%c\n", optopt);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
fprintf(stderr, "unknown argument: %s\n", argv[optind]);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
exit(errflg);
|
||||||
|
}
|
||||||
|
@ -28,21 +28,6 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <err.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <grp.h>
|
|
||||||
#include <kvm.h>
|
|
||||||
#include <nlist.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <paths.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -53,6 +38,22 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/sem.h>
|
#include <sys/sem.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/msg.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <grp.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <nlist.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/* SysCtlGatherStruct structure. */
|
/* SysCtlGatherStruct structure. */
|
||||||
struct scgs_vector {
|
struct scgs_vector {
|
||||||
@ -63,10 +64,10 @@ struct scgs_vector {
|
|||||||
|
|
||||||
int use_sysctl = 1;
|
int use_sysctl = 1;
|
||||||
struct semid_kernel *sema;
|
struct semid_kernel *sema;
|
||||||
struct seminfo seminfo;
|
struct seminfo seminfo;
|
||||||
struct msginfo msginfo;
|
struct msginfo msginfo;
|
||||||
struct msqid_kernel *msqids;
|
struct msqid_kernel *msqids;
|
||||||
struct shminfo shminfo;
|
struct shminfo shminfo;
|
||||||
struct shmid_kernel *shmsegs;
|
struct shmid_kernel *shmsegs;
|
||||||
|
|
||||||
char *fmt_perm(u_short);
|
char *fmt_perm(u_short);
|
||||||
@ -75,6 +76,15 @@ void sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vec);
|
|||||||
void kget(int idx, void *addr, size_t size);
|
void kget(int idx, void *addr, size_t size);
|
||||||
void usage(void);
|
void usage(void);
|
||||||
uid_t user2uid(char *username);
|
uid_t user2uid(char *username);
|
||||||
|
void print_kmsqtotal(struct msginfo msginfo);
|
||||||
|
void print_kmsqheader(int option);
|
||||||
|
void print_kmsqptr(int i, int option, struct msqid_kernel *kmsqptr);
|
||||||
|
void print_kshmtotal(struct shminfo shminfo);
|
||||||
|
void print_kshmheader(int option);
|
||||||
|
void print_kshmptr(int i, int option, struct shmid_kernel *kshmptr);
|
||||||
|
void print_ksemtotal(struct seminfo seminfo);
|
||||||
|
void print_ksemheader(int option);
|
||||||
|
void print_ksemptr(int i, int option, struct semid_kernel *ksemaptr);
|
||||||
|
|
||||||
static struct nlist symbols[] = {
|
static struct nlist symbols[] = {
|
||||||
{"sema"},
|
{"sema"},
|
||||||
@ -92,32 +102,29 @@ static struct nlist symbols[] = {
|
|||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHMINFO_XVEC \
|
#define SHMINFO_XVEC X(shmmax, sizeof(u_long)) \
|
||||||
X(shmmax, sizeof(u_long)) \
|
X(shmmin, sizeof(u_long)) \
|
||||||
X(shmmin, sizeof(u_long)) \
|
X(shmmni, sizeof(u_long)) \
|
||||||
X(shmmni, sizeof(u_long)) \
|
X(shmseg, sizeof(u_long)) \
|
||||||
X(shmseg, sizeof(u_long)) \
|
X(shmall, sizeof(u_long))
|
||||||
X(shmall, sizeof(u_long))
|
|
||||||
|
|
||||||
#define SEMINFO_XVEC \
|
#define SEMINFO_XVEC X(semmap, sizeof(int)) \
|
||||||
X(semmap, sizeof(int)) \
|
X(semmni, sizeof(int)) \
|
||||||
X(semmni, sizeof(int)) \
|
X(semmns, sizeof(int)) \
|
||||||
X(semmns, sizeof(int)) \
|
X(semmnu, sizeof(int)) \
|
||||||
X(semmnu, sizeof(int)) \
|
X(semmsl, sizeof(int)) \
|
||||||
X(semmsl, sizeof(int)) \
|
X(semopm, sizeof(int)) \
|
||||||
X(semopm, sizeof(int)) \
|
X(semume, sizeof(int)) \
|
||||||
X(semume, sizeof(int)) \
|
X(semusz, sizeof(int)) \
|
||||||
X(semusz, sizeof(int)) \
|
X(semvmx, sizeof(int)) \
|
||||||
X(semvmx, sizeof(int)) \
|
X(semaem, sizeof(int))
|
||||||
X(semaem, sizeof(int))
|
|
||||||
|
|
||||||
#define MSGINFO_XVEC \
|
#define MSGINFO_XVEC X(msgmax, sizeof(int)) \
|
||||||
X(msgmax, sizeof(int)) \
|
X(msgmni, sizeof(int)) \
|
||||||
X(msgmni, sizeof(int)) \
|
X(msgmnb, sizeof(int)) \
|
||||||
X(msgmnb, sizeof(int)) \
|
X(msgtql, sizeof(int)) \
|
||||||
X(msgtql, sizeof(int)) \
|
X(msgssz, sizeof(int)) \
|
||||||
X(msgssz, sizeof(int)) \
|
X(msgseg, sizeof(int))
|
||||||
X(msgseg, sizeof(int))
|
|
||||||
|
|
||||||
#define X(a, b) { "kern.ipc." #a, offsetof(TYPEC, a), (b) },
|
#define X(a, b) { "kern.ipc." #a, offsetof(TYPEC, a), (b) },
|
||||||
#define TYPEC struct shminfo
|
#define TYPEC struct shminfo
|
||||||
@ -187,28 +194,10 @@ main(int argc, char *argv[])
|
|||||||
char *core = NULL, *user = NULL, *namelist = NULL;
|
char *core = NULL, *user = NULL, *namelist = NULL;
|
||||||
char kvmoferr[_POSIX2_LINE_MAX]; /* Error buf for kvm_openfiles. */
|
char kvmoferr[_POSIX2_LINE_MAX]; /* Error buf for kvm_openfiles. */
|
||||||
int i;
|
int i;
|
||||||
uid_t uid;
|
uid_t uid = 0;
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "MmQqSsabC:cN:optTu:y")) != -1)
|
while ((i = getopt(argc, argv, "MmQqSsabC:cN:optTu:y")) != -1)
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'M':
|
|
||||||
display = SHMTOTAL;
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
display = SHMINFO;
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
display = MSGTOTAL;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
display = MSGINFO;
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
display = SEMTOTAL;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
display = SEMINFO;
|
|
||||||
break;
|
|
||||||
case 'T':
|
case 'T':
|
||||||
display = SHMTOTAL | MSGTOTAL | SEMTOTAL;
|
display = SHMTOTAL | MSGTOTAL | SEMTOTAL;
|
||||||
break;
|
break;
|
||||||
@ -224,6 +213,12 @@ main(int argc, char *argv[])
|
|||||||
case 'c':
|
case 'c':
|
||||||
option |= CREATOR;
|
option |= CREATOR;
|
||||||
break;
|
break;
|
||||||
|
case 'M':
|
||||||
|
display = SHMTOTAL;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
display = SHMINFO;
|
||||||
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
namelist = optarg;
|
namelist = optarg;
|
||||||
break;
|
break;
|
||||||
@ -233,16 +228,28 @@ main(int argc, char *argv[])
|
|||||||
case 'p':
|
case 'p':
|
||||||
option |= PID;
|
option |= PID;
|
||||||
break;
|
break;
|
||||||
|
case 'Q':
|
||||||
|
display = MSGTOTAL;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
display = MSGINFO;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
display = SEMTOTAL;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
display = SEMINFO;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
option |= TIME;
|
option |= TIME;
|
||||||
break;
|
break;
|
||||||
case 'y':
|
|
||||||
use_sysctl = 0;
|
|
||||||
break;
|
|
||||||
case 'u':
|
case 'u':
|
||||||
user = optarg;
|
user = optarg;
|
||||||
uid = user2uid(user);
|
uid = user2uid(user);
|
||||||
break;
|
break;
|
||||||
|
case 'y':
|
||||||
|
use_sysctl = 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -265,195 +272,70 @@ main(int argc, char *argv[])
|
|||||||
case -1:
|
case -1:
|
||||||
errx(1, "unable to read kernel symbol table");
|
errx(1, "unable to read kernel symbol table");
|
||||||
default:
|
default:
|
||||||
#ifdef notdef /* they'll be told more civilly later */
|
|
||||||
warnx("nlist failed");
|
|
||||||
for (i = 0; symbols[i].n_name != NULL; i++)
|
|
||||||
if (symbols[i].n_value == 0)
|
|
||||||
warnx("symbol %s not found",
|
|
||||||
symbols[i].n_name);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kget(X_MSGINFO, &msginfo, sizeof(msginfo));
|
kget(X_MSGINFO, &msginfo, sizeof(msginfo));
|
||||||
if ((display & (MSGINFO | MSGTOTAL))) {
|
if ((display & (MSGINFO | MSGTOTAL))) {
|
||||||
if (display & MSGTOTAL) {
|
if (display & MSGTOTAL)
|
||||||
printf("msginfo:\n");
|
print_kmsqtotal(msginfo);
|
||||||
printf("\tmsgmax: %12d\t(max characters in a message)\n",
|
|
||||||
msginfo.msgmax);
|
|
||||||
printf("\tmsgmni: %12d\t(# of message queues)\n",
|
|
||||||
msginfo.msgmni);
|
|
||||||
printf("\tmsgmnb: %12d\t(max characters in a message queue)\n",
|
|
||||||
msginfo.msgmnb);
|
|
||||||
printf("\tmsgtql: %12d\t(max # of messages in system)\n",
|
|
||||||
msginfo.msgtql);
|
|
||||||
printf("\tmsgssz: %12d\t(size of a message segment)\n",
|
|
||||||
msginfo.msgssz);
|
|
||||||
printf("\tmsgseg: %12d\t(# of message segments in system)\n\n",
|
|
||||||
msginfo.msgseg);
|
|
||||||
}
|
|
||||||
if (display & MSGINFO) {
|
if (display & MSGINFO) {
|
||||||
struct msqid_kernel *kxmsqids;
|
struct msqid_kernel *kxmsqids;
|
||||||
size_t kxmsqids_len;
|
size_t kxmsqids_len;
|
||||||
|
|
||||||
|
kxmsqids_len =
|
||||||
kxmsqids_len = sizeof(struct msqid_kernel) * msginfo.msgmni;
|
sizeof(struct msqid_kernel) * msginfo.msgmni;
|
||||||
kxmsqids = malloc(kxmsqids_len);
|
kxmsqids = malloc(kxmsqids_len);
|
||||||
kget(X_MSQIDS, kxmsqids, kxmsqids_len);
|
kget(X_MSQIDS, kxmsqids, kxmsqids_len);
|
||||||
|
|
||||||
printf("Message Queues:\n");
|
print_kmsqheader(option);
|
||||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
|
||||||
"OWNER", "GROUP");
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
|
||||||
if (option & OUTSTANDING)
|
|
||||||
printf(" %20s %20s", "CBYTES", "QNUM");
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %20s", "QBYTES");
|
|
||||||
if (option & PID)
|
|
||||||
printf(" %12s %12s", "LSPID", "LRPID");
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %-8s %-8s %-8s", "STIME", "RTIME", "CTIME");
|
|
||||||
printf("\n");
|
|
||||||
for (i = 0; i < msginfo.msgmni; i += 1) {
|
for (i = 0; i < msginfo.msgmni; i += 1) {
|
||||||
if (kxmsqids[i].u.msg_qbytes != 0) {
|
if (kxmsqids[i].u.msg_qbytes != 0) {
|
||||||
char stime_buf[100], rtime_buf[100],
|
if (user &&
|
||||||
ctime_buf[100];
|
uid != kxmsqids[i].u.msg_perm.uid)
|
||||||
struct msqid_kernel *kmsqptr = &kxmsqids[i];
|
continue;
|
||||||
|
|
||||||
if (user)
|
print_kmsqptr(i, option, &kxmsqids[i]);
|
||||||
if (uid != kmsqptr->u.msg_perm.uid)
|
|
||||||
continue;
|
|
||||||
cvt_time(kmsqptr->u.msg_stime, stime_buf);
|
|
||||||
cvt_time(kmsqptr->u.msg_rtime, rtime_buf);
|
|
||||||
cvt_time(kmsqptr->u.msg_ctime, ctime_buf);
|
|
||||||
|
|
||||||
printf("q %12d %12d %s %8s %8s",
|
|
||||||
IXSEQ_TO_IPCID(i, kmsqptr->u.msg_perm),
|
|
||||||
(int)kmsqptr->u.msg_perm.key,
|
|
||||||
fmt_perm(kmsqptr->u.msg_perm.mode),
|
|
||||||
user_from_uid(kmsqptr->u.msg_perm.uid, 0),
|
|
||||||
group_from_gid(kmsqptr->u.msg_perm.gid, 0));
|
|
||||||
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %8s %8s",
|
|
||||||
user_from_uid(kmsqptr->u.msg_perm.cuid, 0),
|
|
||||||
group_from_gid(kmsqptr->u.msg_perm.cgid, 0));
|
|
||||||
|
|
||||||
if (option & OUTSTANDING)
|
|
||||||
printf(" %12lu %12lu",
|
|
||||||
kmsqptr->u.msg_cbytes,
|
|
||||||
kmsqptr->u.msg_qnum);
|
|
||||||
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %20lu",
|
|
||||||
kmsqptr->u.msg_qbytes);
|
|
||||||
|
|
||||||
if (option & PID)
|
|
||||||
printf(" %12d %12d",
|
|
||||||
kmsqptr->u.msg_lspid,
|
|
||||||
kmsqptr->u.msg_lrpid);
|
|
||||||
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %s %s %s",
|
|
||||||
stime_buf,
|
|
||||||
rtime_buf,
|
|
||||||
ctime_buf);
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (display & (MSGINFO | MSGTOTAL)) {
|
if (display & (MSGINFO | MSGTOTAL)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"SVID messages facility not configured in the system\n");
|
"SVID messages facility "
|
||||||
|
"not configured in the system\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
kget(X_SHMINFO, &shminfo, sizeof(shminfo));
|
kget(X_SHMINFO, &shminfo, sizeof(shminfo));
|
||||||
if ((display & (SHMINFO | SHMTOTAL))) {
|
if ((display & (SHMINFO | SHMTOTAL))) {
|
||||||
if (display & SHMTOTAL) {
|
|
||||||
printf("shminfo:\n");
|
if (display & SHMTOTAL)
|
||||||
printf("\tshmmax: %12d\t(max shared memory segment size)\n",
|
print_kshmtotal(shminfo);
|
||||||
shminfo.shmmax);
|
|
||||||
printf("\tshmmin: %12d\t(min shared memory segment size)\n",
|
|
||||||
shminfo.shmmin);
|
|
||||||
printf("\tshmmni: %12d\t(max number of shared memory identifiers)\n",
|
|
||||||
shminfo.shmmni);
|
|
||||||
printf("\tshmseg: %12d\t(max shared memory segments per process)\n",
|
|
||||||
shminfo.shmseg);
|
|
||||||
printf("\tshmall: %12d\t(max amount of shared memory in pages)\n\n",
|
|
||||||
shminfo.shmall);
|
|
||||||
}
|
|
||||||
if (display & SHMINFO) {
|
if (display & SHMINFO) {
|
||||||
struct shmid_kernel *kxshmids;
|
struct shmid_kernel *kxshmids;
|
||||||
size_t kxshmids_len;
|
size_t kxshmids_len;
|
||||||
|
|
||||||
kxshmids_len = sizeof(struct shmid_kernel) * shminfo.shmmni;
|
kxshmids_len =
|
||||||
|
sizeof(struct shmid_kernel) * shminfo.shmmni;
|
||||||
kxshmids = malloc(kxshmids_len);
|
kxshmids = malloc(kxshmids_len);
|
||||||
kget(X_SHMSEGS, kxshmids, kxshmids_len);
|
kget(X_SHMSEGS, kxshmids, kxshmids_len);
|
||||||
|
|
||||||
printf("Shared Memory:\n");
|
print_kshmheader(option);
|
||||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
|
||||||
"OWNER", "GROUP");
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
|
||||||
if (option & OUTSTANDING)
|
|
||||||
printf(" %12s", "NATTCH");
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %12s", "SEGSZ");
|
|
||||||
if (option & PID)
|
|
||||||
printf(" %12s %12s", "CPID", "LPID");
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %-8s %-8s %-8s", "ATIME", "DTIME", "CTIME");
|
|
||||||
printf("\n");
|
|
||||||
for (i = 0; i < shminfo.shmmni; i += 1) {
|
for (i = 0; i < shminfo.shmmni; i += 1) {
|
||||||
if (kxshmids[i].u.shm_perm.mode & 0x0800) {
|
if (kxshmids[i].u.shm_perm.mode & 0x0800) {
|
||||||
char atime_buf[100], dtime_buf[100],
|
if (user &&
|
||||||
ctime_buf[100];
|
uid != kxshmids[i].u.shm_perm.uid)
|
||||||
struct shmid_kernel *kshmptr = &kxshmids[i];
|
continue;
|
||||||
|
|
||||||
if (user)
|
print_kshmptr(i, option, &kxshmids[i]);
|
||||||
if (uid != kshmptr->u.shm_perm.uid)
|
|
||||||
continue;
|
|
||||||
cvt_time(kshmptr->u.shm_atime, atime_buf);
|
|
||||||
cvt_time(kshmptr->u.shm_dtime, dtime_buf);
|
|
||||||
cvt_time(kshmptr->u.shm_ctime, ctime_buf);
|
|
||||||
|
|
||||||
printf("m %12d %12d %s %8s %8s",
|
|
||||||
IXSEQ_TO_IPCID(i, kshmptr->u.shm_perm),
|
|
||||||
(int)kshmptr->u.shm_perm.key,
|
|
||||||
fmt_perm(kshmptr->u.shm_perm.mode),
|
|
||||||
user_from_uid(kshmptr->u.shm_perm.uid, 0),
|
|
||||||
group_from_gid(kshmptr->u.shm_perm.gid, 0));
|
|
||||||
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %8s %8s",
|
|
||||||
user_from_uid(kshmptr->u.shm_perm.cuid, 0),
|
|
||||||
group_from_gid(kshmptr->u.shm_perm.cgid, 0));
|
|
||||||
|
|
||||||
if (option & OUTSTANDING)
|
|
||||||
printf(" %12d",
|
|
||||||
kshmptr->u.shm_nattch);
|
|
||||||
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %12d",
|
|
||||||
kshmptr->u.shm_segsz);
|
|
||||||
|
|
||||||
if (option & PID)
|
|
||||||
printf(" %12d %12d",
|
|
||||||
kshmptr->u.shm_cpid,
|
|
||||||
kshmptr->u.shm_lpid);
|
|
||||||
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %s %s %s",
|
|
||||||
atime_buf,
|
|
||||||
dtime_buf,
|
|
||||||
ctime_buf);
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -461,7 +343,8 @@ main(int argc, char *argv[])
|
|||||||
} else
|
} else
|
||||||
if (display & (SHMINFO | SHMTOTAL)) {
|
if (display & (SHMINFO | SHMTOTAL)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"SVID shared memory facility not configured in the system\n");
|
"SVID shared memory facility "
|
||||||
|
"not configured in the system\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
kget(X_SEMINFO, &seminfo, sizeof(seminfo));
|
kget(X_SEMINFO, &seminfo, sizeof(seminfo));
|
||||||
@ -469,77 +352,25 @@ main(int argc, char *argv[])
|
|||||||
struct semid_kernel *kxsema;
|
struct semid_kernel *kxsema;
|
||||||
size_t kxsema_len;
|
size_t kxsema_len;
|
||||||
|
|
||||||
if (display & SEMTOTAL) {
|
if (display & SEMTOTAL)
|
||||||
printf("seminfo:\n");
|
print_ksemtotal(seminfo);
|
||||||
printf("\tsemmap: %12d\t(# of entries in semaphore map)\n",
|
|
||||||
seminfo.semmap);
|
|
||||||
printf("\tsemmni: %12d\t(# of semaphore identifiers)\n",
|
|
||||||
seminfo.semmni);
|
|
||||||
printf("\tsemmns: %12d\t(# of semaphores in system)\n",
|
|
||||||
seminfo.semmns);
|
|
||||||
printf("\tsemmnu: %12d\t(# of undo structures in system)\n",
|
|
||||||
seminfo.semmnu);
|
|
||||||
printf("\tsemmsl: %12d\t(max # of semaphores per id)\n",
|
|
||||||
seminfo.semmsl);
|
|
||||||
printf("\tsemopm: %12d\t(max # of operations per semop call)\n",
|
|
||||||
seminfo.semopm);
|
|
||||||
printf("\tsemume: %12d\t(max # of undo entries per process)\n",
|
|
||||||
seminfo.semume);
|
|
||||||
printf("\tsemusz: %12d\t(size in bytes of undo structure)\n",
|
|
||||||
seminfo.semusz);
|
|
||||||
printf("\tsemvmx: %12d\t(semaphore maximum value)\n",
|
|
||||||
seminfo.semvmx);
|
|
||||||
printf("\tsemaem: %12d\t(adjust on exit max value)\n\n",
|
|
||||||
seminfo.semaem);
|
|
||||||
}
|
|
||||||
if (display & SEMINFO) {
|
if (display & SEMINFO) {
|
||||||
kxsema_len = sizeof(struct semid_kernel) * seminfo.semmni;
|
kxsema_len =
|
||||||
|
sizeof(struct semid_kernel) * seminfo.semmni;
|
||||||
kxsema = malloc(kxsema_len);
|
kxsema = malloc(kxsema_len);
|
||||||
kget(X_SEMA, kxsema, kxsema_len);
|
kget(X_SEMA, kxsema, kxsema_len);
|
||||||
|
|
||||||
printf("Semaphores:\n");
|
print_ksemheader(option);
|
||||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
|
||||||
"OWNER", "GROUP");
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %12s", "NSEMS");
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %-8s %-8s", "OTIME", "CTIME");
|
|
||||||
printf("\n");
|
|
||||||
for (i = 0; i < seminfo.semmni; i += 1) {
|
for (i = 0; i < seminfo.semmni; i += 1) {
|
||||||
if ((kxsema[i].u.sem_perm.mode & SEM_ALLOC) != 0) {
|
if ((kxsema[i].u.sem_perm.mode & SEM_ALLOC) != 0) {
|
||||||
char ctime_buf[100], otime_buf[100];
|
if (user &&
|
||||||
struct semid_kernel *ksemaptr = &kxsema[i];
|
uid != kxsema[i].u.sem_perm.uid)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (user)
|
print_ksemptr(i, option, &kxsema[i]);
|
||||||
if (uid != ksemaptr->u.sem_perm.uid)
|
|
||||||
continue;
|
|
||||||
cvt_time(ksemaptr->u.sem_otime, otime_buf);
|
|
||||||
cvt_time(ksemaptr->u.sem_ctime, ctime_buf);
|
|
||||||
|
|
||||||
printf("s %12d %12d %s %8s %8s",
|
|
||||||
IXSEQ_TO_IPCID(i, ksemaptr->u.sem_perm),
|
|
||||||
(int)ksemaptr->u.sem_perm.key,
|
|
||||||
fmt_perm(ksemaptr->u.sem_perm.mode),
|
|
||||||
user_from_uid(ksemaptr->u.sem_perm.uid, 0),
|
|
||||||
group_from_gid(ksemaptr->u.sem_perm.gid, 0));
|
|
||||||
|
|
||||||
if (option & CREATOR)
|
|
||||||
printf(" %8s %8s",
|
|
||||||
user_from_uid(ksemaptr->u.sem_perm.cuid, 0),
|
|
||||||
group_from_gid(ksemaptr->u.sem_perm.cgid, 0));
|
|
||||||
|
|
||||||
if (option & BIGGEST)
|
|
||||||
printf(" %12d",
|
|
||||||
ksemaptr->u.sem_nsems);
|
|
||||||
|
|
||||||
if (option & TIME)
|
|
||||||
printf(" %s %s",
|
|
||||||
otime_buf,
|
|
||||||
ctime_buf);
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,14 +378,251 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (display & (SEMINFO | SEMTOTAL)) {
|
if (display & (SEMINFO | SEMTOTAL)) {
|
||||||
fprintf(stderr, "SVID semaphores facility not configured in the system\n");
|
fprintf(stderr,
|
||||||
|
"SVID semaphores facility "
|
||||||
|
"not configured in the system\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_sysctl)
|
if (!use_sysctl)
|
||||||
kvm_close(kd);
|
kvm_close(kd);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_kmsqtotal(struct msginfo msginfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("msginfo:\n");
|
||||||
|
printf("\tmsgmax: %12d\t(max characters in a message)\n",
|
||||||
|
msginfo.msgmax);
|
||||||
|
printf("\tmsgmni: %12d\t(# of message queues)\n",
|
||||||
|
msginfo.msgmni);
|
||||||
|
printf("\tmsgmnb: %12d\t(max characters in a message queue)\n",
|
||||||
|
msginfo.msgmnb);
|
||||||
|
printf("\tmsgtql: %12d\t(max # of messages in system)\n",
|
||||||
|
msginfo.msgtql);
|
||||||
|
printf("\tmsgssz: %12d\t(size of a message segment)\n",
|
||||||
|
msginfo.msgssz);
|
||||||
|
printf("\tmsgseg: %12d\t(# of message segments in system)\n\n",
|
||||||
|
msginfo.msgseg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_kmsqheader(int option) {
|
||||||
|
|
||||||
|
printf("Message Queues:\n");
|
||||||
|
printf("T %12s %12s %-11s %-8s %-8s",
|
||||||
|
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||||
|
if (option & OUTSTANDING)
|
||||||
|
printf(" %20s %20s", "CBYTES", "QNUM");
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %20s", "QBYTES");
|
||||||
|
if (option & PID)
|
||||||
|
printf(" %12s %12s", "LSPID", "LRPID");
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %-8s %-8s %-8s", "STIME", "RTIME", "CTIME");
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_kmsqptr(int i, int option, struct msqid_kernel *kmsqptr)
|
||||||
|
{
|
||||||
|
char stime_buf[100], rtime_buf[100], ctime_buf[100];
|
||||||
|
|
||||||
|
cvt_time(kmsqptr->u.msg_stime, stime_buf);
|
||||||
|
cvt_time(kmsqptr->u.msg_rtime, rtime_buf);
|
||||||
|
cvt_time(kmsqptr->u.msg_ctime, ctime_buf);
|
||||||
|
|
||||||
|
printf("q %12d %12d %s %8s %8s",
|
||||||
|
IXSEQ_TO_IPCID(i, kmsqptr->u.msg_perm),
|
||||||
|
(int)kmsqptr->u.msg_perm.key,
|
||||||
|
fmt_perm(kmsqptr->u.msg_perm.mode),
|
||||||
|
user_from_uid(kmsqptr->u.msg_perm.uid, 0),
|
||||||
|
group_from_gid(kmsqptr->u.msg_perm.gid, 0));
|
||||||
|
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %8s %8s",
|
||||||
|
user_from_uid(kmsqptr->u.msg_perm.cuid, 0),
|
||||||
|
group_from_gid(kmsqptr->u.msg_perm.cgid, 0));
|
||||||
|
|
||||||
|
if (option & OUTSTANDING)
|
||||||
|
printf(" %12lu %12lu",
|
||||||
|
kmsqptr->u.msg_cbytes,
|
||||||
|
kmsqptr->u.msg_qnum);
|
||||||
|
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %20lu", kmsqptr->u.msg_qbytes);
|
||||||
|
|
||||||
|
if (option & PID)
|
||||||
|
printf(" %12d %12d",
|
||||||
|
kmsqptr->u.msg_lspid,
|
||||||
|
kmsqptr->u.msg_lrpid);
|
||||||
|
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %s %s %s",
|
||||||
|
stime_buf,
|
||||||
|
rtime_buf,
|
||||||
|
ctime_buf);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_kshmtotal(struct shminfo shminfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("shminfo:\n");
|
||||||
|
printf("\tshmmax: %12d\t(max shared memory segment size)\n",
|
||||||
|
shminfo.shmmax);
|
||||||
|
printf("\tshmmin: %12d\t(min shared memory segment size)\n",
|
||||||
|
shminfo.shmmin);
|
||||||
|
printf("\tshmmni: %12d\t(max number of shared memory identifiers)\n",
|
||||||
|
shminfo.shmmni);
|
||||||
|
printf("\tshmseg: %12d\t(max shared memory segments per process)\n",
|
||||||
|
shminfo.shmseg);
|
||||||
|
printf("\tshmall: %12d\t(max amount of shared memory in pages)\n\n",
|
||||||
|
shminfo.shmall);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_kshmheader(int option)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("Shared Memory:\n");
|
||||||
|
printf("T %12s %12s %-11s %-8s %-8s",
|
||||||
|
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||||
|
if (option & OUTSTANDING)
|
||||||
|
printf(" %12s", "NATTCH");
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %12s", "SEGSZ");
|
||||||
|
if (option & PID)
|
||||||
|
printf(" %12s %12s", "CPID", "LPID");
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %-8s %-8s %-8s", "ATIME", "DTIME", "CTIME");
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_kshmptr(int i, int option, struct shmid_kernel *kshmptr)
|
||||||
|
{
|
||||||
|
char atime_buf[100], dtime_buf[100], ctime_buf[100];
|
||||||
|
|
||||||
|
cvt_time(kshmptr->u.shm_atime, atime_buf);
|
||||||
|
cvt_time(kshmptr->u.shm_dtime, dtime_buf);
|
||||||
|
cvt_time(kshmptr->u.shm_ctime, ctime_buf);
|
||||||
|
|
||||||
|
printf("m %12d %12d %s %8s %8s",
|
||||||
|
IXSEQ_TO_IPCID(i, kshmptr->u.shm_perm),
|
||||||
|
(int)kshmptr->u.shm_perm.key,
|
||||||
|
fmt_perm(kshmptr->u.shm_perm.mode),
|
||||||
|
user_from_uid(kshmptr->u.shm_perm.uid, 0),
|
||||||
|
group_from_gid(kshmptr->u.shm_perm.gid, 0));
|
||||||
|
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %8s %8s",
|
||||||
|
user_from_uid(kshmptr->u.shm_perm.cuid, 0),
|
||||||
|
group_from_gid(kshmptr->u.shm_perm.cgid, 0));
|
||||||
|
|
||||||
|
if (option & OUTSTANDING)
|
||||||
|
printf(" %12d",
|
||||||
|
kshmptr->u.shm_nattch);
|
||||||
|
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %12d",
|
||||||
|
kshmptr->u.shm_segsz);
|
||||||
|
|
||||||
|
if (option & PID)
|
||||||
|
printf(" %12d %12d",
|
||||||
|
kshmptr->u.shm_cpid,
|
||||||
|
kshmptr->u.shm_lpid);
|
||||||
|
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %s %s %s",
|
||||||
|
atime_buf,
|
||||||
|
dtime_buf,
|
||||||
|
ctime_buf);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_ksemtotal(struct seminfo seminfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("seminfo:\n");
|
||||||
|
printf("\tsemmap: %12d\t(# of entries in semaphore map)\n",
|
||||||
|
seminfo.semmap);
|
||||||
|
printf("\tsemmni: %12d\t(# of semaphore identifiers)\n",
|
||||||
|
seminfo.semmni);
|
||||||
|
printf("\tsemmns: %12d\t(# of semaphores in system)\n",
|
||||||
|
seminfo.semmns);
|
||||||
|
printf("\tsemmnu: %12d\t(# of undo structures in system)\n",
|
||||||
|
seminfo.semmnu);
|
||||||
|
printf("\tsemmsl: %12d\t(max # of semaphores per id)\n",
|
||||||
|
seminfo.semmsl);
|
||||||
|
printf("\tsemopm: %12d\t(max # of operations per semop call)\n",
|
||||||
|
seminfo.semopm);
|
||||||
|
printf("\tsemume: %12d\t(max # of undo entries per process)\n",
|
||||||
|
seminfo.semume);
|
||||||
|
printf("\tsemusz: %12d\t(size in bytes of undo structure)\n",
|
||||||
|
seminfo.semusz);
|
||||||
|
printf("\tsemvmx: %12d\t(semaphore maximum value)\n",
|
||||||
|
seminfo.semvmx);
|
||||||
|
printf("\tsemaem: %12d\t(adjust on exit max value)\n\n",
|
||||||
|
seminfo.semaem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_ksemheader(int option) {
|
||||||
|
|
||||||
|
printf("Semaphores:\n");
|
||||||
|
printf("T %12s %12s %-11s %-8s %-8s",
|
||||||
|
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %12s", "NSEMS");
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %-8s %-8s", "OTIME", "CTIME");
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_ksemptr(int i, int option, struct semid_kernel *ksemaptr)
|
||||||
|
{
|
||||||
|
char ctime_buf[100], otime_buf[100];
|
||||||
|
|
||||||
|
cvt_time(ksemaptr->u.sem_otime, otime_buf);
|
||||||
|
cvt_time(ksemaptr->u.sem_ctime, ctime_buf);
|
||||||
|
|
||||||
|
printf("s %12d %12d %s %8s %8s",
|
||||||
|
IXSEQ_TO_IPCID(i, ksemaptr->u.sem_perm),
|
||||||
|
(int)ksemaptr->u.sem_perm.key,
|
||||||
|
fmt_perm(ksemaptr->u.sem_perm.mode),
|
||||||
|
user_from_uid(ksemaptr->u.sem_perm.uid, 0),
|
||||||
|
group_from_gid(ksemaptr->u.sem_perm.gid, 0));
|
||||||
|
|
||||||
|
if (option & CREATOR)
|
||||||
|
printf(" %8s %8s",
|
||||||
|
user_from_uid(ksemaptr->u.sem_perm.cuid, 0),
|
||||||
|
group_from_gid(ksemaptr->u.sem_perm.cgid, 0));
|
||||||
|
|
||||||
|
if (option & BIGGEST)
|
||||||
|
printf(" %12d",
|
||||||
|
ksemaptr->u.sem_nsems);
|
||||||
|
|
||||||
|
if (option & TIME)
|
||||||
|
printf(" %s %s",
|
||||||
|
otime_buf,
|
||||||
|
ctime_buf);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vecarr)
|
sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vecarr)
|
||||||
{
|
{
|
||||||
@ -677,6 +745,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: ipcs [-abcmopqstyMQST] [-C corefile] [-N namelist] [-u user]\n");
|
"usage: "
|
||||||
|
"ipcs [-abcmopqstyMQST] [-C corefile] [-N namelist] [-u user]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user