| 508 | } |
| 509 | |
| 510 | static int |
| 511 | procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, |
| 512 | struct thread *td) |
| 513 | { |
| 514 | struct procdesc *pd; |
| 515 | struct timeval pstart, boottime; |
| 516 | |
| 517 | /* |
| 518 | * XXXRW: Perhaps we should cache some more information from the |
| 519 | * process so that we can return it reliably here even after it has |
| 520 | * died. For example, caching its credential data. |
| 521 | */ |
| 522 | bzero(sb, sizeof(*sb)); |
| 523 | pd = fp->f_data; |
| 524 | sx_slock(&proctree_lock); |
| 525 | if (pd->pd_proc != NULL) { |
| 526 | PROC_LOCK(pd->pd_proc); |
| 527 | AUDIT_ARG_PROCESS(pd->pd_proc); |
| 528 | |
| 529 | /* Set birth and [acm] times to process start time. */ |
| 530 | pstart = pd->pd_proc->p_stats->p_start; |
| 531 | getboottime(&boottime); |
| 532 | timevaladd(&pstart, &boottime); |
| 533 | TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); |
| 534 | sb->st_atim = sb->st_birthtim; |
| 535 | sb->st_ctim = sb->st_birthtim; |
| 536 | sb->st_mtim = sb->st_birthtim; |
| 537 | if (pd->pd_proc->p_state != PRS_ZOMBIE) |
| 538 | sb->st_mode = S_IFREG | S_IRWXU; |
| 539 | else |
| 540 | sb->st_mode = S_IFREG; |
| 541 | sb->st_uid = pd->pd_proc->p_ucred->cr_ruid; |
| 542 | sb->st_gid = pd->pd_proc->p_ucred->cr_rgid; |
| 543 | PROC_UNLOCK(pd->pd_proc); |
| 544 | } else |
| 545 | sb->st_mode = S_IFREG; |
| 546 | sx_sunlock(&proctree_lock); |
| 547 | return (0); |
| 548 | } |
| 549 | |
| 550 | static int |
| 551 | procdesc_fill_kinfo(struct file *fp, struct kinfo_file *kif, |
nothing calls this directly
no test coverage detected