Enhance msgctl syscall decoding
Make parser of msgctl syscall print struct msqid_ds. * ipc_msgctl.c (msqid_ds_t): New typedef. Mpersify it. (print_msqid_ds): New function. Use msqid_ds_t. (sys_msgctl): Use print_msqid_ds. * tests/ipc_msg.c: Update for struct msqid_ds support.
This commit is contained in:
parent
0a6af9b0a4
commit
d0a61871c8
60
ipc_msgctl.c
60
ipc_msgctl.c
@ -34,14 +34,64 @@
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#include <sys/msg.h>
|
||||
#include DEF_MPERS_TYPE(msqid_ds_t)
|
||||
typedef struct msqid_ds msqid_ds_t;
|
||||
#include MPERS_DEFS
|
||||
|
||||
#include "xlat/msgctl_flags.h"
|
||||
|
||||
static void
|
||||
print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
|
||||
{
|
||||
if (cmd & IPC_64)
|
||||
cmd &= ~IPC_64;
|
||||
msqid_ds_t msqid_ds;
|
||||
switch (cmd) {
|
||||
case IPC_SET:
|
||||
case IPC_STAT:
|
||||
if (umove_or_printaddr(tcp, addr, &msqid_ds))
|
||||
return;
|
||||
|
||||
tprints("{msg_perm={");
|
||||
printuid("uid=", msqid_ds.msg_perm.uid);
|
||||
printuid(", gid=", msqid_ds.msg_perm.gid);
|
||||
tprints(", mode=");
|
||||
tprints(sprintmode(msqid_ds.msg_perm.mode));
|
||||
|
||||
if (cmd != IPC_STAT) {
|
||||
tprints("}, ...}");
|
||||
break;
|
||||
}
|
||||
|
||||
tprintf(", key=%u", (unsigned) msqid_ds.msg_perm.__key);
|
||||
printuid(", cuid=", msqid_ds.msg_perm.cuid);
|
||||
printuid(", cgid=", msqid_ds.msg_perm.cgid);
|
||||
tprints("}");
|
||||
tprintf(", msg_stime=%u", (unsigned) msqid_ds.msg_stime);
|
||||
tprintf(", msg_rtime=%u", (unsigned) msqid_ds.msg_rtime);
|
||||
tprintf(", msg_ctime=%u", (unsigned) msqid_ds.msg_ctime);
|
||||
tprintf(", msg_qnum=%u", (unsigned) msqid_ds.msg_qnum);
|
||||
tprintf(", msg_qbytes=%u", (unsigned) msqid_ds.msg_qbytes);
|
||||
tprintf(", msg_lspid=%u", (unsigned) msqid_ds.msg_lspid);
|
||||
tprintf(", msg_lrpid=%u", (unsigned) msqid_ds.msg_lrpid);
|
||||
tprints("}");
|
||||
break;
|
||||
|
||||
default:
|
||||
printaddr(addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SYS_FUNC(msgctl)
|
||||
{
|
||||
tprintf("%lu, ", tcp->u_arg[0]);
|
||||
PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
|
||||
tprints(", ");
|
||||
printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
|
||||
return RVAL_DECODED;
|
||||
if (entering(tcp)) {
|
||||
tprintf("%lu, ", tcp->u_arg[0]);
|
||||
PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
|
||||
tprints(", ");
|
||||
} else {
|
||||
const long addr = tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2];
|
||||
print_msqid_ds(tcp, addr, tcp->u_arg[1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -15,7 +15,17 @@ main(void)
|
||||
|
||||
if (msgctl(id, IPC_STAT, &ds))
|
||||
goto fail;
|
||||
printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, %p\\) += 0\n", id, &ds);
|
||||
printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, gid=%u, "
|
||||
"mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, msg_rtime=%u, "
|
||||
"msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, "
|
||||
"msg_lrpid=%u\\}\\) += 0\n",
|
||||
id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
|
||||
(unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key,
|
||||
(unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid,
|
||||
(unsigned) ds.msg_stime, (unsigned) ds.msg_rtime,
|
||||
(unsigned) ds.msg_ctime, (unsigned) ds.msg_qnum,
|
||||
(unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid,
|
||||
(unsigned) ds.msg_lrpid);
|
||||
|
||||
int max = msgctl(0, MSG_INFO, &ds);
|
||||
if (max < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user