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>
|
||||
__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 <err.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.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_STRING(x) (x == 'Q' ? "message queue" : \
|
||||
@ -56,16 +57,20 @@ int shmrm(key_t, int);
|
||||
int semrm(key_t, 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]",
|
||||
" [-Q msgkey] [-M shmkey] [-S semkey] ...");
|
||||
|
||||
fprintf(stderr,
|
||||
"usage: ipcrm [-q msqid] [-m shmid] [-s semid]\n"
|
||||
" [-Q msgkey] [-M shmkey] [-S semkey] ...\n");
|
||||
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)
|
||||
@ -74,8 +79,10 @@ int msgrm(key_t key, int id)
|
||||
return msgctl(id, IPC_RMID, NULL);
|
||||
}
|
||||
|
||||
int shmrm(key_t key, int id)
|
||||
int
|
||||
shmrm(key_t key, int id)
|
||||
{
|
||||
|
||||
if (key) {
|
||||
id = shmget(key, 0, 0);
|
||||
if (id == -1)
|
||||
@ -84,7 +91,8 @@ int shmrm(key_t key, int id)
|
||||
return shmctl(id, IPC_RMID, NULL);
|
||||
}
|
||||
|
||||
int semrm(key_t key, int id)
|
||||
int
|
||||
semrm(key_t key, int id)
|
||||
{
|
||||
union semun arg;
|
||||
|
||||
@ -96,12 +104,15 @@ int semrm(key_t key, int id)
|
||||
return semctl(id, 0, IPC_RMID, arg);
|
||||
}
|
||||
|
||||
void not_configured(int signo __unused)
|
||||
void
|
||||
not_configured(int signo __unused)
|
||||
{
|
||||
|
||||
signaled++;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c, result, errflg, target_id;
|
||||
key_t target_key;
|
||||
@ -125,9 +136,12 @@ int main(int argc, char *argv[])
|
||||
if (result < 0) {
|
||||
errflg++;
|
||||
if (!signaled)
|
||||
warn("%sid(%d): ", IPC_TO_STR(toupper(c)), target_id);
|
||||
warn("%sid(%d): ",
|
||||
IPC_TO_STR(toupper(c)), target_id);
|
||||
else
|
||||
warnx("%ss are not configured in the running kernel",
|
||||
warnx(
|
||||
"%ss are not configured "
|
||||
"in the running kernel",
|
||||
IPC_TO_STRING(toupper(c)));
|
||||
}
|
||||
break;
|
||||
@ -136,7 +150,8 @@ int main(int argc, char *argv[])
|
||||
case 'S':
|
||||
target_key = atol(optarg);
|
||||
if (target_key == IPC_PRIVATE) {
|
||||
warnx("can't remove private %ss", IPC_TO_STRING(c));
|
||||
warnx("can't remove private %ss",
|
||||
IPC_TO_STRING(c));
|
||||
continue;
|
||||
}
|
||||
if (c == 'Q')
|
||||
@ -148,14 +163,17 @@ int main(int argc, char *argv[])
|
||||
if (result < 0) {
|
||||
errflg++;
|
||||
if (!signaled)
|
||||
warn("%ss(%ld): ", IPC_TO_STR(c), target_key);
|
||||
warn("%ss(%ld): ",
|
||||
IPC_TO_STR(c), target_key);
|
||||
else
|
||||
warnx("%ss are not configured in the running kernel",
|
||||
warnx("%ss are not configured "
|
||||
"in the running kernel",
|
||||
IPC_TO_STRING(c));
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
fprintf(stderr, "option -%c requires an argument\n", optopt);
|
||||
fprintf(stderr,
|
||||
"option -%c requires an argument\n", optopt);
|
||||
usage();
|
||||
case '?':
|
||||
fprintf(stderr, "unrecognized option: -%c\n", optopt);
|
||||
@ -169,4 +187,3 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
exit(errflg);
|
||||
}
|
||||
|
||||
|
@ -28,21 +28,6 @@
|
||||
#include <sys/cdefs.h>
|
||||
__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/param.h>
|
||||
#include <sys/time.h>
|
||||
@ -53,6 +38,22 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.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. */
|
||||
struct scgs_vector {
|
||||
@ -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 usage(void);
|
||||
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[] = {
|
||||
{"sema"},
|
||||
@ -92,15 +102,13 @@ static struct nlist symbols[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
#define SHMINFO_XVEC \
|
||||
X(shmmax, sizeof(u_long)) \
|
||||
#define SHMINFO_XVEC X(shmmax, sizeof(u_long)) \
|
||||
X(shmmin, sizeof(u_long)) \
|
||||
X(shmmni, sizeof(u_long)) \
|
||||
X(shmseg, sizeof(u_long)) \
|
||||
X(shmall, sizeof(u_long))
|
||||
|
||||
#define SEMINFO_XVEC \
|
||||
X(semmap, sizeof(int)) \
|
||||
#define SEMINFO_XVEC X(semmap, sizeof(int)) \
|
||||
X(semmni, sizeof(int)) \
|
||||
X(semmns, sizeof(int)) \
|
||||
X(semmnu, sizeof(int)) \
|
||||
@ -111,8 +119,7 @@ X(semusz, sizeof(int)) \
|
||||
X(semvmx, sizeof(int)) \
|
||||
X(semaem, sizeof(int))
|
||||
|
||||
#define MSGINFO_XVEC \
|
||||
X(msgmax, sizeof(int)) \
|
||||
#define MSGINFO_XVEC X(msgmax, sizeof(int)) \
|
||||
X(msgmni, sizeof(int)) \
|
||||
X(msgmnb, sizeof(int)) \
|
||||
X(msgtql, sizeof(int)) \
|
||||
@ -187,28 +194,10 @@ main(int argc, char *argv[])
|
||||
char *core = NULL, *user = NULL, *namelist = NULL;
|
||||
char kvmoferr[_POSIX2_LINE_MAX]; /* Error buf for kvm_openfiles. */
|
||||
int i;
|
||||
uid_t uid;
|
||||
uid_t uid = 0;
|
||||
|
||||
while ((i = getopt(argc, argv, "MmQqSsabC:cN:optTu:y")) != -1)
|
||||
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':
|
||||
display = SHMTOTAL | MSGTOTAL | SEMTOTAL;
|
||||
break;
|
||||
@ -224,6 +213,12 @@ main(int argc, char *argv[])
|
||||
case 'c':
|
||||
option |= CREATOR;
|
||||
break;
|
||||
case 'M':
|
||||
display = SHMTOTAL;
|
||||
break;
|
||||
case 'm':
|
||||
display = SHMINFO;
|
||||
break;
|
||||
case 'N':
|
||||
namelist = optarg;
|
||||
break;
|
||||
@ -233,16 +228,28 @@ main(int argc, char *argv[])
|
||||
case 'p':
|
||||
option |= PID;
|
||||
break;
|
||||
case 'Q':
|
||||
display = MSGTOTAL;
|
||||
break;
|
||||
case 'q':
|
||||
display = MSGINFO;
|
||||
break;
|
||||
case 'S':
|
||||
display = SEMTOTAL;
|
||||
break;
|
||||
case 's':
|
||||
display = SEMINFO;
|
||||
break;
|
||||
case 't':
|
||||
option |= TIME;
|
||||
break;
|
||||
case 'y':
|
||||
use_sysctl = 0;
|
||||
break;
|
||||
case 'u':
|
||||
user = optarg;
|
||||
uid = user2uid(user);
|
||||
break;
|
||||
case 'y':
|
||||
use_sysctl = 0;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
@ -265,20 +272,127 @@ main(int argc, char *argv[])
|
||||
case -1:
|
||||
errx(1, "unable to read kernel symbol table");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
kget(X_MSGINFO, &msginfo, sizeof(msginfo));
|
||||
if ((display & (MSGINFO | MSGTOTAL))) {
|
||||
if (display & MSGTOTAL) {
|
||||
if (display & MSGTOTAL)
|
||||
print_kmsqtotal(msginfo);
|
||||
|
||||
if (display & MSGINFO) {
|
||||
struct msqid_kernel *kxmsqids;
|
||||
size_t kxmsqids_len;
|
||||
|
||||
kxmsqids_len =
|
||||
sizeof(struct msqid_kernel) * msginfo.msgmni;
|
||||
kxmsqids = malloc(kxmsqids_len);
|
||||
kget(X_MSQIDS, kxmsqids, kxmsqids_len);
|
||||
|
||||
print_kmsqheader(option);
|
||||
|
||||
for (i = 0; i < msginfo.msgmni; i += 1) {
|
||||
if (kxmsqids[i].u.msg_qbytes != 0) {
|
||||
if (user &&
|
||||
uid != kxmsqids[i].u.msg_perm.uid)
|
||||
continue;
|
||||
|
||||
print_kmsqptr(i, option, &kxmsqids[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (MSGINFO | MSGTOTAL)) {
|
||||
fprintf(stderr,
|
||||
"SVID messages facility "
|
||||
"not configured in the system\n");
|
||||
}
|
||||
|
||||
kget(X_SHMINFO, &shminfo, sizeof(shminfo));
|
||||
if ((display & (SHMINFO | SHMTOTAL))) {
|
||||
|
||||
if (display & SHMTOTAL)
|
||||
print_kshmtotal(shminfo);
|
||||
|
||||
if (display & SHMINFO) {
|
||||
struct shmid_kernel *kxshmids;
|
||||
size_t kxshmids_len;
|
||||
|
||||
kxshmids_len =
|
||||
sizeof(struct shmid_kernel) * shminfo.shmmni;
|
||||
kxshmids = malloc(kxshmids_len);
|
||||
kget(X_SHMSEGS, kxshmids, kxshmids_len);
|
||||
|
||||
print_kshmheader(option);
|
||||
|
||||
for (i = 0; i < shminfo.shmmni; i += 1) {
|
||||
if (kxshmids[i].u.shm_perm.mode & 0x0800) {
|
||||
if (user &&
|
||||
uid != kxshmids[i].u.shm_perm.uid)
|
||||
continue;
|
||||
|
||||
print_kshmptr(i, option, &kxshmids[i]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (SHMINFO | SHMTOTAL)) {
|
||||
fprintf(stderr,
|
||||
"SVID shared memory facility "
|
||||
"not configured in the system\n");
|
||||
}
|
||||
|
||||
kget(X_SEMINFO, &seminfo, sizeof(seminfo));
|
||||
if ((display & (SEMINFO | SEMTOTAL))) {
|
||||
struct semid_kernel *kxsema;
|
||||
size_t kxsema_len;
|
||||
|
||||
if (display & SEMTOTAL)
|
||||
print_ksemtotal(seminfo);
|
||||
|
||||
if (display & SEMINFO) {
|
||||
kxsema_len =
|
||||
sizeof(struct semid_kernel) * seminfo.semmni;
|
||||
kxsema = malloc(kxsema_len);
|
||||
kget(X_SEMA, kxsema, kxsema_len);
|
||||
|
||||
print_ksemheader(option);
|
||||
|
||||
for (i = 0; i < seminfo.semmni; i += 1) {
|
||||
if ((kxsema[i].u.sem_perm.mode & SEM_ALLOC) != 0) {
|
||||
if (user &&
|
||||
uid != kxsema[i].u.sem_perm.uid)
|
||||
continue;
|
||||
|
||||
print_ksemptr(i, option, &kxsema[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (SEMINFO | SEMTOTAL)) {
|
||||
fprintf(stderr,
|
||||
"SVID semaphores facility "
|
||||
"not configured in the system\n");
|
||||
}
|
||||
|
||||
if (!use_sysctl)
|
||||
kvm_close(kd);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
print_kmsqtotal(struct msginfo msginfo)
|
||||
{
|
||||
|
||||
printf("msginfo:\n");
|
||||
printf("\tmsgmax: %12d\t(max characters in a message)\n",
|
||||
msginfo.msgmax);
|
||||
@ -293,18 +407,12 @@ main(int argc, char *argv[])
|
||||
printf("\tmsgseg: %12d\t(# of message segments in system)\n\n",
|
||||
msginfo.msgseg);
|
||||
}
|
||||
if (display & MSGINFO) {
|
||||
struct msqid_kernel *kxmsqids;
|
||||
size_t kxmsqids_len;
|
||||
|
||||
|
||||
kxmsqids_len = sizeof(struct msqid_kernel) * msginfo.msgmni;
|
||||
kxmsqids = malloc(kxmsqids_len);
|
||||
kget(X_MSQIDS, kxmsqids, kxmsqids_len);
|
||||
void print_kmsqheader(int option) {
|
||||
|
||||
printf("Message Queues:\n");
|
||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
||||
"OWNER", "GROUP");
|
||||
printf("T %12s %12s %-11s %-8s %-8s",
|
||||
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||
if (option & CREATOR)
|
||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||
if (option & OUTSTANDING)
|
||||
@ -316,15 +424,13 @@ main(int argc, char *argv[])
|
||||
if (option & TIME)
|
||||
printf(" %-8s %-8s %-8s", "STIME", "RTIME", "CTIME");
|
||||
printf("\n");
|
||||
for (i = 0; i < msginfo.msgmni; i += 1) {
|
||||
if (kxmsqids[i].u.msg_qbytes != 0) {
|
||||
char stime_buf[100], rtime_buf[100],
|
||||
ctime_buf[100];
|
||||
struct msqid_kernel *kmsqptr = &kxmsqids[i];
|
||||
}
|
||||
|
||||
void
|
||||
print_kmsqptr(int i, int option, struct msqid_kernel *kmsqptr)
|
||||
{
|
||||
char stime_buf[100], rtime_buf[100], ctime_buf[100];
|
||||
|
||||
if (user)
|
||||
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);
|
||||
@ -347,8 +453,7 @@ main(int argc, char *argv[])
|
||||
kmsqptr->u.msg_qnum);
|
||||
|
||||
if (option & BIGGEST)
|
||||
printf(" %20lu",
|
||||
kmsqptr->u.msg_qbytes);
|
||||
printf(" %20lu", kmsqptr->u.msg_qbytes);
|
||||
|
||||
if (option & PID)
|
||||
printf(" %12d %12d",
|
||||
@ -363,18 +468,11 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (MSGINFO | MSGTOTAL)) {
|
||||
fprintf(stderr,
|
||||
"SVID messages facility not configured in the system\n");
|
||||
}
|
||||
|
||||
kget(X_SHMINFO, &shminfo, sizeof(shminfo));
|
||||
if ((display & (SHMINFO | SHMTOTAL))) {
|
||||
if (display & SHMTOTAL) {
|
||||
void
|
||||
print_kshmtotal(struct shminfo shminfo)
|
||||
{
|
||||
|
||||
printf("shminfo:\n");
|
||||
printf("\tshmmax: %12d\t(max shared memory segment size)\n",
|
||||
shminfo.shmmax);
|
||||
@ -387,17 +485,14 @@ main(int argc, char *argv[])
|
||||
printf("\tshmall: %12d\t(max amount of shared memory in pages)\n\n",
|
||||
shminfo.shmall);
|
||||
}
|
||||
if (display & SHMINFO) {
|
||||
struct shmid_kernel *kxshmids;
|
||||
size_t kxshmids_len;
|
||||
|
||||
kxshmids_len = sizeof(struct shmid_kernel) * shminfo.shmmni;
|
||||
kxshmids = malloc(kxshmids_len);
|
||||
kget(X_SHMSEGS, kxshmids, kxshmids_len);
|
||||
void
|
||||
print_kshmheader(int option)
|
||||
{
|
||||
|
||||
printf("Shared Memory:\n");
|
||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
||||
"OWNER", "GROUP");
|
||||
printf("T %12s %12s %-11s %-8s %-8s",
|
||||
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||
if (option & CREATOR)
|
||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||
if (option & OUTSTANDING)
|
||||
@ -409,15 +504,13 @@ main(int argc, char *argv[])
|
||||
if (option & TIME)
|
||||
printf(" %-8s %-8s %-8s", "ATIME", "DTIME", "CTIME");
|
||||
printf("\n");
|
||||
for (i = 0; i < shminfo.shmmni; i += 1) {
|
||||
if (kxshmids[i].u.shm_perm.mode & 0x0800) {
|
||||
char atime_buf[100], dtime_buf[100],
|
||||
ctime_buf[100];
|
||||
struct shmid_kernel *kshmptr = &kxshmids[i];
|
||||
}
|
||||
|
||||
void
|
||||
print_kshmptr(int i, int option, struct shmid_kernel *kshmptr)
|
||||
{
|
||||
char atime_buf[100], dtime_buf[100], ctime_buf[100];
|
||||
|
||||
if (user)
|
||||
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);
|
||||
@ -455,21 +548,11 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (SHMINFO | SHMTOTAL)) {
|
||||
fprintf(stderr,
|
||||
"SVID shared memory facility not configured in the system\n");
|
||||
}
|
||||
|
||||
kget(X_SEMINFO, &seminfo, sizeof(seminfo));
|
||||
if ((display & (SEMINFO | SEMTOTAL))) {
|
||||
struct semid_kernel *kxsema;
|
||||
size_t kxsema_len;
|
||||
void
|
||||
print_ksemtotal(struct seminfo seminfo)
|
||||
{
|
||||
|
||||
if (display & SEMTOTAL) {
|
||||
printf("seminfo:\n");
|
||||
printf("\tsemmap: %12d\t(# of entries in semaphore map)\n",
|
||||
seminfo.semmap);
|
||||
@ -492,14 +575,13 @@ main(int argc, char *argv[])
|
||||
printf("\tsemaem: %12d\t(adjust on exit max value)\n\n",
|
||||
seminfo.semaem);
|
||||
}
|
||||
if (display & SEMINFO) {
|
||||
kxsema_len = sizeof(struct semid_kernel) * seminfo.semmni;
|
||||
kxsema = malloc(kxsema_len);
|
||||
kget(X_SEMA, kxsema, kxsema_len);
|
||||
|
||||
void
|
||||
print_ksemheader(int option) {
|
||||
|
||||
printf("Semaphores:\n");
|
||||
printf("T %12s %12s %-11s %-8s %-8s", "ID", "KEY", "MODE",
|
||||
"OWNER", "GROUP");
|
||||
printf("T %12s %12s %-11s %-8s %-8s",
|
||||
"ID", "KEY", "MODE", "OWNER", "GROUP");
|
||||
if (option & CREATOR)
|
||||
printf(" %-8s %-8s", "CREATOR", "CGROUP");
|
||||
if (option & BIGGEST)
|
||||
@ -507,14 +589,13 @@ main(int argc, char *argv[])
|
||||
if (option & TIME)
|
||||
printf(" %-8s %-8s", "OTIME", "CTIME");
|
||||
printf("\n");
|
||||
for (i = 0; i < seminfo.semmni; i += 1) {
|
||||
if ((kxsema[i].u.sem_perm.mode & SEM_ALLOC) != 0) {
|
||||
char ctime_buf[100], otime_buf[100];
|
||||
struct semid_kernel *ksemaptr = &kxsema[i];
|
||||
}
|
||||
|
||||
void
|
||||
print_ksemptr(int i, int option, struct semid_kernel *ksemaptr)
|
||||
{
|
||||
char ctime_buf[100], otime_buf[100];
|
||||
|
||||
if (user)
|
||||
if (uid != ksemaptr->u.sem_perm.uid)
|
||||
continue;
|
||||
cvt_time(ksemaptr->u.sem_otime, otime_buf);
|
||||
cvt_time(ksemaptr->u.sem_ctime, ctime_buf);
|
||||
|
||||
@ -541,19 +622,6 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
} else
|
||||
if (display & (SEMINFO | SEMTOTAL)) {
|
||||
fprintf(stderr, "SVID semaphores facility not configured in the system\n");
|
||||
}
|
||||
if (!use_sysctl)
|
||||
kvm_close(kd);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vecarr)
|
||||
@ -677,6 +745,7 @@ usage(void)
|
||||
{
|
||||
|
||||
fprintf(stderr,
|
||||
"usage: ipcs [-abcmopqstyMQST] [-C corefile] [-N namelist] [-u user]\n");
|
||||
"usage: "
|
||||
"ipcs [-abcmopqstyMQST] [-C corefile] [-N namelist] [-u user]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user