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

Function sysctl_kern_proc_filedesc

freebsd/kern/kern_descrip.c:4561–4584  ·  view source on GitHub ↗

* Get per-process file descriptors for use by procstat(1), et al. */

Source from the content-addressed store, hash-verified

4559 * Get per-process file descriptors for use by procstat(1), et al.
4560 */
4561static int
4562sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS)
4563{
4564 struct sbuf sb;
4565 struct proc *p;
4566 ssize_t maxlen;
4567 int error, error2, *name;
4568
4569 name = (int *)arg1;
4570
4571 sbuf_new_for_sysctl(&sb, NULL, FILEDESC_SBUF_SIZE, req);
4572 sbuf_clear_flags(&sb, SBUF_INCLUDENUL);
4573 error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p);
4574 if (error != 0) {
4575 sbuf_delete(&sb);
4576 return (error);
4577 }
4578 maxlen = req->oldptr != NULL ? req->oldlen : -1;
4579 error = kern_proc_filedesc_out(p, &sb, maxlen,
4580 KERN_FILEDESC_PACK_KINFO);
4581 error2 = sbuf_finish(&sb);
4582 sbuf_delete(&sb);
4583 return (error != 0 ? error : error2);
4584}
4585
4586#ifdef COMPAT_FREEBSD7
4587#ifdef KINFO_OFILE_SIZE

Callers

nothing calls this directly

Calls 6

sbuf_new_for_sysctlFunction · 0.85
sbuf_clear_flagsFunction · 0.85
sbuf_deleteFunction · 0.85
kern_proc_filedesc_outFunction · 0.85
sbuf_finishFunction · 0.85
pgetFunction · 0.70

Tested by

no test coverage detected