MCPcopy Create free account
hub / github.com/F-Stack/f-stack / procdesc_stat

Function procdesc_stat

freebsd/kern/sys_procdesc.c:510–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510static int
511procdesc_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
550static int
551procdesc_fill_kinfo(struct file *fp, struct kinfo_file *kif,

Callers

nothing calls this directly

Calls 3

bzeroFunction · 0.85
getboottimeFunction · 0.85
timevaladdFunction · 0.70

Tested by

no test coverage detected