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

Function note_procstat_files

freebsd/kern/imgact_elf.c:2409–2455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2407#endif
2408
2409static void
2410note_procstat_files(void *arg, struct sbuf *sb, size_t *sizep)
2411{
2412 struct proc *p;
2413 size_t size, sect_sz, i;
2414 ssize_t start_len, sect_len;
2415 int structsize, filedesc_flags;
2416
2417 if (coredump_pack_fileinfo)
2418 filedesc_flags = KERN_FILEDESC_PACK_KINFO;
2419 else
2420 filedesc_flags = 0;
2421
2422 p = (struct proc *)arg;
2423 structsize = sizeof(struct kinfo_file);
2424 if (sb == NULL) {
2425 size = 0;
2426 sb = sbuf_new(NULL, NULL, 128, SBUF_FIXEDLEN);
2427 sbuf_set_drain(sb, sbuf_count_drain, &size);
2428 sbuf_bcat(sb, &structsize, sizeof(structsize));
2429 PROC_LOCK(p);
2430 kern_proc_filedesc_out(p, sb, -1, filedesc_flags);
2431 sbuf_finish(sb);
2432 sbuf_delete(sb);
2433 *sizep = size;
2434 } else {
2435 sbuf_start_section(sb, &start_len);
2436
2437 sbuf_bcat(sb, &structsize, sizeof(structsize));
2438 PROC_LOCK(p);
2439 kern_proc_filedesc_out(p, sb, *sizep - sizeof(structsize),
2440 filedesc_flags);
2441
2442 sect_len = sbuf_end_section(sb, start_len, 0, 0);
2443 if (sect_len < 0)
2444 return;
2445 sect_sz = sect_len;
2446
2447 KASSERT(sect_sz <= *sizep,
2448 ("kern_proc_filedesc_out did not respect maxlen; "
2449 "requested %zu, got %zu", *sizep - sizeof(structsize),
2450 sect_sz - sizeof(structsize)));
2451
2452 for (i = 0; i < *sizep - sect_sz && sb->s_error == 0; i++)
2453 sbuf_putc(sb, 0);
2454 }
2455}
2456
2457#ifdef KINFO_VMENTRY_SIZE
2458CTASSERT(sizeof(struct kinfo_vmentry) == KINFO_VMENTRY_SIZE);

Callers

nothing calls this directly

Calls 9

sbuf_newFunction · 0.85
sbuf_set_drainFunction · 0.85
sbuf_bcatFunction · 0.85
kern_proc_filedesc_outFunction · 0.85
sbuf_finishFunction · 0.85
sbuf_deleteFunction · 0.85
sbuf_start_sectionFunction · 0.85
sbuf_end_sectionFunction · 0.85
sbuf_putcFunction · 0.85

Tested by

no test coverage detected