diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2002-06-10 19:15:07 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2002-06-10 19:15:07 +0000 |
commit | 0f22659edc025a76144d07a67d273b4e1d8dffce (patch) | |
tree | 4c675ebe51638397cc65cdba50b346dcbfd497c1 /sys/dev | |
parent | e64b74e7bbb98855b6ad174e656039b41f3b9f59 (diff) |
new ioctl that reports the current emulation a process uses; needed for
attaching to a running process
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/systrace.c | 16 | ||||
-rw-r--r-- | sys/dev/systrace.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c index 587f43214ec..6923d319d6e 100644 --- a/sys/dev/systrace.c +++ b/sys/dev/systrace.c @@ -82,6 +82,7 @@ struct str_policy { #define STR_PROC_ONQUEUE 0x01 #define STR_PROC_WAITANSWER 0x02 #define STR_PROC_SYSCALLRES 0x04 +#define STR_PROC_REPORT 0x08 /* Report emulation */ struct str_process { TAILQ_ENTRY(str_process) next; @@ -239,6 +240,7 @@ systracef_ioctl(fp, cmd, data, p) DPRINTF(("%s: attach to %d: %d\n", __FUNCTION__, pid, ret)); goto unlock; case STRIOCDETACH: + case STRIOCREPORT: pid = *(pid_t *)data; if (!pid) ret = EINVAL; @@ -300,6 +302,9 @@ systracef_ioctl(fp, cmd, data, p) case STRIOCDETACH: ret = systrace_detach(strp); break; + case STRIOCREPORT: + SET(strp->flags, STR_PROC_REPORT); + break; case STRIOCANSWER: ret = systrace_answer(strp, (struct systrace_answer *)data); break; @@ -691,7 +696,15 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) /* Report change in emulation */ systrace_lock(); - if (p->p_emul != oldemul && (strp = p->p_systrace) != NULL) { + strp = p->p_systrace; + + /* See if we should force a report */ + if (strp != NULL && ISSET(strp->flags, STR_PROC_REPORT)) { + CLR(strp->flags, STR_PROC_REPORT); + oldemul = NULL; + } + + if (p->p_emul != oldemul && strp != NULL) { fst = strp->parent; lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); systrace_unlock(); @@ -983,6 +996,7 @@ systrace_attach(struct fsystrace *fst, pid_t pid) } error = systrace_insert_process(fst, proc); + out: return (error); } diff --git a/sys/dev/systrace.h b/sys/dev/systrace.h index 2a56c614558..b427fd82af7 100644 --- a/sys/dev/systrace.h +++ b/sys/dev/systrace.h @@ -95,6 +95,7 @@ struct systrace_policy { #define STRIOCPOLICY _IOWR('s', 105, struct systrace_policy) #define STRIOCGETCWD _IOW('s', 106, pid_t) #define STRIOCRESCWD _IO('s', 107) +#define STRIOCREPORT _IOW('s', 108, pid_t) #define SYSTR_POLICY_ASK 0 #define SYSTR_POLICY_PERMIT 1 |