Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_procdesc.c
Show First 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | procdesc_kqfilter(struct file *fp, struct knote *kn) | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, | procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, | ||||
struct thread *td) | struct thread *td) | ||||
{ | { | ||||
struct procdesc *pd; | struct procdesc *pd; | ||||
struct timeval pstart; | struct timeval pstart, boottime; | ||||
/* | /* | ||||
* XXXRW: Perhaps we should cache some more information from the | * XXXRW: Perhaps we should cache some more information from the | ||||
* process so that we can return it reliably here even after it has | * process so that we can return it reliably here even after it has | ||||
* died. For example, caching its credential data. | * died. For example, caching its credential data. | ||||
*/ | */ | ||||
bzero(sb, sizeof(*sb)); | bzero(sb, sizeof(*sb)); | ||||
pd = fp->f_data; | pd = fp->f_data; | ||||
sx_slock(&proctree_lock); | sx_slock(&proctree_lock); | ||||
if (pd->pd_proc != NULL) { | if (pd->pd_proc != NULL) { | ||||
PROC_LOCK(pd->pd_proc); | PROC_LOCK(pd->pd_proc); | ||||
AUDIT_ARG_PROCESS(pd->pd_proc); | AUDIT_ARG_PROCESS(pd->pd_proc); | ||||
/* Set birth and [acm] times to process start time. */ | /* Set birth and [acm] times to process start time. */ | ||||
pstart = pd->pd_proc->p_stats->p_start; | pstart = pd->pd_proc->p_stats->p_start; | ||||
getboottime(&boottime); | |||||
timevaladd(&pstart, &boottime); | timevaladd(&pstart, &boottime); | ||||
TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); | TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); | ||||
sb->st_atim = sb->st_birthtim; | sb->st_atim = sb->st_birthtim; | ||||
sb->st_ctim = sb->st_birthtim; | sb->st_ctim = sb->st_birthtim; | ||||
sb->st_mtim = sb->st_birthtim; | sb->st_mtim = sb->st_birthtim; | ||||
if (pd->pd_proc->p_state != PRS_ZOMBIE) | if (pd->pd_proc->p_state != PRS_ZOMBIE) | ||||
sb->st_mode = S_IFREG | S_IRWXU; | sb->st_mode = S_IFREG | S_IRWXU; | ||||
else | else | ||||
Show All 21 Lines |