#include "defs.h"
#ifdef SVR4
+#ifndef HAVE_MP_PROCFS
-static struct xlat proc_status_flags[] = {
+static const struct xlat proc_status_flags[] = {
{ PR_STOPPED, "PR_STOPPED" },
{ PR_ISTOP, "PR_ISTOP" },
{ PR_DSTOP, "PR_DSTOP" },
{ 0, NULL },
};
-static struct xlat proc_status_why[] = {
+static const struct xlat proc_status_why[] = {
{ PR_REQUESTED, "PR_REQUESTED" },
{ PR_SIGNALLED, "PR_SIGNALLED" },
{ PR_SYSENTRY, "PR_SYSENTRY" },
{ 0, NULL },
};
-static struct xlat proc_run_flags[] = {
+static const struct xlat proc_run_flags[] = {
{ PRCSIG, "PRCSIG" },
{ PRCFAULT, "PRCFAULT" },
{ PRSTRACE, "PRSTRACE" },
};
int
-proc_ioctl(tcp, code, arg)
-struct tcb *tcp;
-int code, arg;
+proc_ioctl(struct tcb *tcp, int code, int arg)
{
int val;
prstatus_t status;
tprintf(", {...}");
else {
tprintf(", {pr_flags=");
- if (!printflags(proc_status_flags, status.pr_flags))
- tprintf("0");
+ printflags(proc_status_flags, status.pr_flags, "PR_???");
if (status.pr_why) {
tprintf(", pr_why=");
printxval(proc_status_why, status.pr_why,
tprintf(", {...}");
else {
tprintf(", {pr_flags=");
- if (!printflags(proc_run_flags, run.pr_flags))
- tprintf("0");
+ printflags(proc_run_flags, run.pr_flags, "PR???");
tprintf(", ...}");
}
return 1;
tprintf(", [?]");
else {
tprintf(", [");
- if (!printflags(proc_status_flags, val))
- tprintf("0");
+ printflags(proc_status_flags, val, "PR_???");
tprintf("]");
}
return 1;
}
}
+#endif /* HAVE_MP_PROCFS */
#endif /* SVR4 */
+#ifdef FREEBSD
+#include <sys/pioctl.h>
+
+static const struct xlat proc_status_why[] = {
+ { S_EXEC, "S_EXEC" },
+ { S_SIG, "S_SIG" },
+ { S_SCE, "S_SCE" },
+ { S_SCX, "S_SCX" },
+ { S_CORE, "S_CORE" },
+ { S_EXIT, "S_EXIT" },
+ { 0, NULL }
+};
+
+static const struct xlat proc_status_flags[] = {
+ { PF_LINGER, "PF_LINGER" },
+ { PF_ISUGID, "PF_ISUGID" },
+ { 0, NULL }
+};
+
+int
+proc_ioctl(struct tcb *tcp, int code, int arg)
+{
+ int val;
+ struct procfs_status status;
+
+ if (entering(tcp))
+ return 0;
+
+ switch (code) {
+ case PIOCSTATUS:
+ case PIOCWAIT:
+ if (arg == 0)
+ tprintf(", NULL");
+ else if (syserror(tcp))
+ tprintf(", %x", arg);
+ else if (umove(tcp, arg, &status) < 0)
+ tprintf(", {...}");
+ else {
+ tprintf(", {state=%d, flags=", status.state);
+ printflags(proc_status_flags, status.flags, "PF_???");
+ tprintf(", events=");
+ printflags(proc_status_why, status.events, "S_???");
+ tprintf(", why=");
+ printxval(proc_status_why, status.why, "S_???");
+ tprintf(", val=%lu}", status.val);
+ }
+ return 1;
+ case PIOCBIS:
+ tprintf(", ");
+ printflags(proc_status_why, arg, "S_???");
+ return 1;
+ return 1;
+ case PIOCSFL:
+ tprintf(", ");
+ printflags(proc_status_flags, arg, "PF_???");
+ return 1;
+ case PIOCGFL:
+ if (syserror(tcp))
+ tprintf(", %#x", arg);
+ else if (umove(tcp, arg, &val) < 0)
+ tprintf(", {...}");
+ else {
+ tprintf(", [");
+ printflags(proc_status_flags, val, "PF_???");
+ tprintf("]");
+ }
+ return 1;
+ default:
+ /* ad naseum */
+ return 0;
+ }
+}
+#endif