Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_ktrace.c
Show First 20 Lines • Show All 692 Lines • ▼ Show 20 Lines | ktruserret(struct thread *td) | ||||
ktrace_enter(td); | ktrace_enter(td); | ||||
sx_xlock(&ktrace_sx); | sx_xlock(&ktrace_sx); | ||||
ktr_drain(td); | ktr_drain(td); | ||||
sx_xunlock(&ktrace_sx); | sx_xunlock(&ktrace_sx); | ||||
ktrace_exit(td); | ktrace_exit(td); | ||||
} | } | ||||
void | void | ||||
ktrnamei(path) | ktrnamei(const char *path) | ||||
char *path; | |||||
{ | { | ||||
struct ktr_request *req; | struct ktr_request *req; | ||||
int namelen; | int namelen; | ||||
char *buf = NULL; | char *buf = NULL; | ||||
namelen = strlen(path); | namelen = strlen(path); | ||||
if (namelen > 0) { | if (namelen > 0) { | ||||
buf = malloc(namelen, M_KTRACE, M_WAITOK); | buf = malloc(namelen, M_KTRACE, M_WAITOK); | ||||
▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | #ifdef KTRACE | ||||
/* | /* | ||||
* Need something to (un)trace. | * Need something to (un)trace. | ||||
*/ | */ | ||||
if (ops != KTROP_CLEARFILE && facs == 0) | if (ops != KTROP_CLEARFILE && facs == 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
kiop = NULL; | kiop = NULL; | ||||
ktrace_enter(td); | |||||
if (ops != KTROP_CLEAR) { | if (ops != KTROP_CLEAR) { | ||||
/* | /* | ||||
* an operation which requires a file argument. | * an operation which requires a file argument. | ||||
*/ | */ | ||||
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td); | NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td); | ||||
flags = FREAD | FWRITE | O_NOFOLLOW; | flags = FREAD | FWRITE | O_NOFOLLOW; | ||||
error = vn_open(&nd, &flags, 0, NULL); | error = vn_open(&nd, &flags, 0, NULL); | ||||
if (error) { | if (error) | ||||
ktrace_exit(td); | |||||
return (error); | return (error); | ||||
} | |||||
NDFREE(&nd, NDF_ONLY_PNBUF); | NDFREE(&nd, NDF_ONLY_PNBUF); | ||||
vp = nd.ni_vp; | vp = nd.ni_vp; | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
if (vp->v_type != VREG) { | if (vp->v_type != VREG) { | ||||
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td); | (void)vn_close(vp, FREAD|FWRITE, td->td_ucred, td); | ||||
ktrace_exit(td); | |||||
return (EACCES); | return (EACCES); | ||||
} | } | ||||
kiop = ktr_io_params_alloc(td, vp); | kiop = ktr_io_params_alloc(td, vp); | ||||
} | } | ||||
/* | /* | ||||
* Clear all uses of the tracefile. | * Clear all uses of the tracefile. | ||||
*/ | */ | ||||
ktrace_enter(td); | |||||
if (ops == KTROP_CLEARFILE) { | if (ops == KTROP_CLEARFILE) { | ||||
restart: | restart: | ||||
sx_slock(&allproc_lock); | sx_slock(&allproc_lock); | ||||
FOREACH_PROC_IN_SYSTEM(p) { | FOREACH_PROC_IN_SYSTEM(p) { | ||||
old_kiop = NULL; | old_kiop = NULL; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (p->p_ktrioparms != NULL && | if (p->p_ktrioparms != NULL && | ||||
p->p_ktrioparms->vp == vp) { | p->p_ktrioparms->vp == vp) { | ||||
▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines |