FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ctype.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <machine/stdarg.h>
#include <sys/sbuf.h>
Go to the source code of this file.
Macros | |
#define | SBMALLOC(size) malloc(size, M_SBUF, M_WAITOK) |
#define | SBFREE(buf) free(buf, M_SBUF) |
#define | SBUF_ISDYNAMIC(s) ((s)->s_flags & SBUF_DYNAMIC) |
#define | SBUF_ISDYNSTRUCT(s) ((s)->s_flags & SBUF_DYNSTRUCT) |
#define | SBUF_ISFINISHED(s) ((s)->s_flags & SBUF_FINISHED) |
#define | SBUF_HASROOM(s) ((s)->s_len < (s)->s_size - 1) |
#define | SBUF_FREESPACE(s) ((s)->s_size - ((s)->s_len + 1)) |
#define | SBUF_CANEXTEND(s) ((s)->s_flags & SBUF_AUTOEXTEND) |
#define | SBUF_ISSECTION(s) ((s)->s_flags & SBUF_INSECTION) |
#define | SBUF_SETFLAG(s, f) do { (s)->s_flags |= (f); } while (0) |
#define | SBUF_CLEARFLAG(s, f) do { (s)->s_flags &= ~(f); } while (0) |
#define | SBUF_MINEXTENDSIZE 16 /* Should be power of 2. */ |
#define | SBUF_MAXEXTENDSIZE 4096 |
#define | SBUF_MAXEXTENDINCR 4096 |
#define | assert_sbuf_integrity(s) do { } while (0) |
#define | assert_sbuf_state(s, i) do { } while (0) |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_SBUF,"sbuf","string buffers") |
static int | sbuf_extendsize (int size) |
static int | sbuf_extend (struct sbuf *s, int addlen) |
static struct sbuf * | sbuf_newbuf (struct sbuf *s, char *buf, int length, int flags) |
struct sbuf * | sbuf_new (struct sbuf *s, char *buf, int length, int flags) |
struct sbuf * | sbuf_uionew (struct sbuf *s, struct uio *uio, int *error) |
void | sbuf_clear (struct sbuf *s) |
int | sbuf_setpos (struct sbuf *s, ssize_t pos) |
void | sbuf_set_drain (struct sbuf *s, sbuf_drain_func *func, void *ctx) |
static int | sbuf_drain (struct sbuf *s) |
static void | sbuf_put_byte (struct sbuf *s, int c) |
int | sbuf_bcat (struct sbuf *s, const void *buf, size_t len) |
int | sbuf_bcopyin (struct sbuf *s, const void *uaddr, size_t len) |
int | sbuf_bcpy (struct sbuf *s, const void *buf, size_t len) |
int | sbuf_cat (struct sbuf *s, const char *str) |
int | sbuf_copyin (struct sbuf *s, const void *uaddr, size_t len) |
int | sbuf_cpy (struct sbuf *s, const char *str) |
static void | sbuf_putc_func (int c, void *arg) |
int | sbuf_vprintf (struct sbuf *s, const char *fmt, va_list ap) |
int | sbuf_printf (struct sbuf *s, const char *fmt,...) |
int | sbuf_putc (struct sbuf *s, int c) |
int | sbuf_trim (struct sbuf *s) |
int | sbuf_error (const struct sbuf *s) |
int | sbuf_finish (struct sbuf *s) |
char * | sbuf_data (struct sbuf *s) |
ssize_t | sbuf_len (struct sbuf *s) |
void | sbuf_delete (struct sbuf *s) |
int | sbuf_done (const struct sbuf *s) |
void | sbuf_start_section (struct sbuf *s, ssize_t *old_lenp) |
ssize_t | sbuf_end_section (struct sbuf *s, ssize_t old_len, size_t pad, int c) |
#define assert_sbuf_integrity | ( | s | ) | do { } while (0) |
Definition at line 122 of file subr_sbuf.c.
Referenced by sbuf_bcat(), sbuf_bcopyin(), sbuf_bcpy(), sbuf_cat(), sbuf_clear(), sbuf_copyin(), sbuf_cpy(), sbuf_data(), sbuf_delete(), sbuf_end_section(), sbuf_finish(), sbuf_len(), sbuf_put_byte(), sbuf_set_drain(), sbuf_setpos(), sbuf_start_section(), sbuf_trim(), and sbuf_vprintf().
#define assert_sbuf_state | ( | s, | |
i | |||
) | do { } while (0) |
Definition at line 123 of file subr_sbuf.c.
Referenced by sbuf_bcat(), sbuf_bcopyin(), sbuf_bcpy(), sbuf_cat(), sbuf_copyin(), sbuf_cpy(), sbuf_data(), sbuf_end_section(), sbuf_finish(), sbuf_put_byte(), sbuf_set_drain(), sbuf_setpos(), sbuf_start_section(), sbuf_trim(), and sbuf_vprintf().
Definition at line 56 of file subr_sbuf.c.
Referenced by sbuf_delete(), sbuf_extend(), and sbuf_new().
#define SBMALLOC | ( | size | ) | malloc(size, M_SBUF, M_WAITOK) |
Definition at line 55 of file subr_sbuf.c.
Referenced by sbuf_extend(), sbuf_new(), and sbuf_newbuf().
#define SBUF_CANEXTEND | ( | s | ) | ((s)->s_flags & SBUF_AUTOEXTEND) |
Definition at line 71 of file subr_sbuf.c.
Referenced by sbuf_extend().
#define SBUF_CLEARFLAG | ( | s, | |
f | |||
) | do { (s)->s_flags &= ~(f); } while (0) |
Definition at line 78 of file subr_sbuf.c.
Referenced by sbuf_clear(), and sbuf_end_section().
#define SBUF_FREESPACE | ( | s | ) | ((s)->s_size - ((s)->s_len + 1)) |
Definition at line 70 of file subr_sbuf.c.
Referenced by sbuf_bcopyin(), sbuf_copyin(), and sbuf_put_byte().
#define SBUF_HASROOM | ( | s | ) | ((s)->s_len < (s)->s_size - 1) |
Definition at line 69 of file subr_sbuf.c.
#define SBUF_ISDYNAMIC | ( | s | ) | ((s)->s_flags & SBUF_DYNAMIC) |
Definition at line 66 of file subr_sbuf.c.
Referenced by sbuf_delete(), and sbuf_extend().
#define SBUF_ISDYNSTRUCT | ( | s | ) | ((s)->s_flags & SBUF_DYNSTRUCT) |
Definition at line 67 of file subr_sbuf.c.
Referenced by sbuf_delete().
#define SBUF_ISFINISHED | ( | s | ) | ((s)->s_flags & SBUF_FINISHED) |
Definition at line 68 of file subr_sbuf.c.
Referenced by sbuf_done().
#define SBUF_ISSECTION | ( | s | ) | ((s)->s_flags & SBUF_INSECTION) |
Definition at line 72 of file subr_sbuf.c.
Referenced by sbuf_copyin(), sbuf_end_section(), sbuf_put_byte(), sbuf_setpos(), sbuf_start_section(), sbuf_trim(), and sbuf_uionew().
#define SBUF_MAXEXTENDINCR 4096 |
Definition at line 87 of file subr_sbuf.c.
Referenced by sbuf_extendsize().
#define SBUF_MAXEXTENDSIZE 4096 |
Definition at line 86 of file subr_sbuf.c.
Referenced by sbuf_extendsize().
#define SBUF_MINEXTENDSIZE 16 /* Should be power of 2. */ |
Definition at line 80 of file subr_sbuf.c.
Referenced by sbuf_extendsize().
#define SBUF_SETFLAG | ( | s, | |
f | |||
) | do { (s)->s_flags |= (f); } while (0) |
Definition at line 77 of file subr_sbuf.c.
Referenced by sbuf_extend(), sbuf_finish(), sbuf_new(), sbuf_newbuf(), and sbuf_start_section().
__FBSDID | ( | "$BSDSUniX$" | ) |
|
static |
int sbuf_bcat | ( | struct sbuf * | s, |
const void * | buf, | ||
size_t | len | ||
) |
Definition at line 389 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, buf, and sbuf_put_byte().
Referenced by corehdr(), export_fd_to_sb(), get_ps_strings(), kern_proc_out(), kern_proc_vmmap_out(), note_fpregset(), note_procstat_auxv(), note_procstat_files(), note_procstat_groups(), note_procstat_osrel(), note_procstat_proc(), note_procstat_psstrings(), note_procstat_rlimit(), note_procstat_umask(), note_procstat_vmmap(), note_prpsinfo(), note_prstatus(), note_threadmd(), note_thrmisc(), proc_getauxv(), putnote(), sbuf_bcpy(), and sysctl_kern_malloc_stats().
int sbuf_bcopyin | ( | struct sbuf * | s, |
const void * | uaddr, | ||
size_t | len | ||
) |
Definition at line 412 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_extend(), and SBUF_FREESPACE.
int sbuf_bcpy | ( | struct sbuf * | s, |
const void * | buf, | ||
size_t | len | ||
) |
Definition at line 441 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_bcat(), and sbuf_clear().
int sbuf_cat | ( | struct sbuf * | s, |
const char * | str | ||
) |
Definition at line 455 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, and sbuf_put_byte().
Referenced by sbuf_cpy(), and sys_abort2().
void sbuf_clear | ( | struct sbuf * | s | ) |
Definition at line 269 of file subr_sbuf.c.
References assert_sbuf_integrity, and SBUF_CLEARFLAG.
Referenced by sbuf_bcpy(), sbuf_cpy(), sys_abort2(), sysctl_debug_witness_badstacks(), sysctl_kern_console(), and vfs_mountroot().
int sbuf_copyin | ( | struct sbuf * | s, |
const void * | uaddr, | ||
size_t | len | ||
) |
Definition at line 477 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_extend(), SBUF_FREESPACE, and SBUF_ISSECTION.
Referenced by sys_abort2().
int sbuf_cpy | ( | struct sbuf * | s, |
const char * | str | ||
) |
Definition at line 517 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_cat(), and sbuf_clear().
Referenced by cpufreq_levels_sysctl(), and cpufreq_settings_sysctl().
char* sbuf_data | ( | struct sbuf * | s | ) |
Definition at line 721 of file subr_sbuf.c.
References assert_sbuf_integrity, and assert_sbuf_state.
Referenced by cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), exec_shell_imgact(), fail_point_sysctl(), mount_argf(), sys_abort2(), sysctl_debug_witness_badstacks(), sysctl_kern_console(), and vfs_mountroot_parse().
void sbuf_delete | ( | struct sbuf * | s | ) |
Definition at line 753 of file subr_sbuf.c.
References assert_sbuf_integrity, SBFREE, SBUF_ISDYNAMIC, and SBUF_ISDYNSTRUCT.
Referenced by corehdr(), cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), exec_shell_imgact(), expand_name(), fail_point_sysctl(), kdb_sysctl_available(), mount_argf(), note_procstat_auxv(), note_procstat_files(), note_procstat_vmmap(), sbuf_uionew(), sys_abort2(), sysctl_debug_witness_badstacks(), sysctl_debug_witness_fullgraph(), sysctl_kern_console(), sysctl_kern_malloc_stats(), sysctl_kern_proc_args(), sysctl_kern_proc_auxv(), sysctl_kern_proc_env(), sysctl_kern_proc_filedesc(), sysctl_kern_proc_vmmap(), sysctl_out_proc(), and vfs_mountroot().
int sbuf_done | ( | const struct sbuf * | s | ) |
Definition at line 772 of file subr_sbuf.c.
References SBUF_ISFINISHED.
|
static |
Definition at line 326 of file subr_sbuf.c.
Referenced by sbuf_finish(), and sbuf_put_byte().
ssize_t sbuf_end_section | ( | struct sbuf * | s, |
ssize_t | old_len, | ||
size_t | pad, | ||
int | c | ||
) |
Definition at line 807 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, SBUF_CLEARFLAG, SBUF_ISSECTION, and sbuf_put_byte().
Referenced by corehdr(), and putnote().
int sbuf_error | ( | const struct sbuf * | s | ) |
Definition at line 684 of file subr_sbuf.c.
Referenced by expand_name().
|
static |
Definition at line 152 of file subr_sbuf.c.
References SBFREE, SBMALLOC, SBUF_CANEXTEND, sbuf_extendsize(), SBUF_ISDYNAMIC, and SBUF_SETFLAG.
Referenced by sbuf_bcopyin(), sbuf_copyin(), and sbuf_put_byte().
|
static |
Definition at line 133 of file subr_sbuf.c.
References SBUF_MAXEXTENDINCR, SBUF_MAXEXTENDSIZE, and SBUF_MINEXTENDSIZE.
Referenced by sbuf_extend(), and sbuf_newbuf().
int sbuf_finish | ( | struct sbuf * | s | ) |
Definition at line 694 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_drain(), and SBUF_SETFLAG.
Referenced by corehdr(), cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), exec_shell_imgact(), expand_name(), fail_point_sysctl(), kdb_sysctl_available(), mount_argf(), note_procstat_auxv(), note_procstat_files(), note_procstat_vmmap(), sys_abort2(), sysctl_debug_witness_badstacks(), sysctl_debug_witness_fullgraph(), sysctl_kern_console(), sysctl_kern_malloc_stats(), sysctl_kern_proc_args(), sysctl_kern_proc_auxv(), sysctl_kern_proc_env(), sysctl_kern_proc_filedesc(), sysctl_kern_proc_vmmap(), sysctl_out_proc(), and vfs_mountroot().
ssize_t sbuf_len | ( | struct sbuf * | s | ) |
Definition at line 736 of file subr_sbuf.c.
References assert_sbuf_integrity.
Referenced by cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), expand_name(), fail_point_sysctl(), mount_argf(), sysctl_debug_witness_badstacks(), and sysctl_kern_console().
struct sbuf* sbuf_new | ( | struct sbuf * | s, |
char * | buf, | ||
int | length, | ||
int | flags | ||
) |
Definition at line 211 of file subr_sbuf.c.
References SBFREE, SBMALLOC, sbuf_newbuf(), and SBUF_SETFLAG.
Referenced by corehdr(), cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), expand_name(), fail_point_sysctl(), note_procstat_auxv(), note_procstat_files(), note_procstat_vmmap(), sbuf_new_for_sysctl(), sbuf_uionew(), sys_abort2(), sysctl_debug_witness_badstacks(), and sysctl_kern_console().
|
static |
Definition at line 179 of file subr_sbuf.c.
References buf, SBMALLOC, sbuf_extendsize(), and SBUF_SETFLAG.
Referenced by sbuf_new().
int sbuf_printf | ( | struct sbuf * | s, |
const char * | fmt, | ||
... | |||
) |
Definition at line 632 of file subr_sbuf.c.
References result, and sbuf_vprintf().
Referenced by cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), exec_shell_imgact(), expand_name(), fail_point_get(), kdb_sysctl_available(), sbuf_printf_uuid(), stack_sbuf_print(), sys_abort2(), sysctl_debug_witness_badstacks(), sysctl_debug_witness_fullgraph(), sysctl_kern_console(), vfs_mountroot_conf0(), vfs_mountroot_readconf(), and witness_add_fullgraph().
|
static |
Definition at line 360 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, sbuf_drain(), sbuf_extend(), SBUF_FREESPACE, and SBUF_ISSECTION.
Referenced by sbuf_bcat(), sbuf_cat(), sbuf_end_section(), sbuf_putc(), and sbuf_putc_func().
int sbuf_putc | ( | struct sbuf * | s, |
int | c | ||
) |
Definition at line 647 of file subr_sbuf.c.
References sbuf_put_byte().
Referenced by expand_name().
|
static |
Definition at line 537 of file subr_sbuf.c.
References sbuf_put_byte().
Referenced by sbuf_vprintf().
void sbuf_set_drain | ( | struct sbuf * | s, |
sbuf_drain_func * | func, | ||
void * | ctx | ||
) |
Definition at line 311 of file subr_sbuf.c.
References assert_sbuf_integrity, and assert_sbuf_state.
Referenced by corehdr(), note_procstat_auxv(), note_procstat_files(), note_procstat_vmmap(), and sbuf_new_for_sysctl().
int sbuf_setpos | ( | struct sbuf * | s, |
ssize_t | pos | ||
) |
Definition at line 286 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, and SBUF_ISSECTION.
void sbuf_start_section | ( | struct sbuf * | s, |
ssize_t * | old_lenp | ||
) |
Definition at line 782 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, SBUF_ISSECTION, and SBUF_SETFLAG.
Referenced by corehdr(), and putnote().
int sbuf_trim | ( | struct sbuf * | s | ) |
Definition at line 660 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, and SBUF_ISSECTION.
Referenced by cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), fail_point_sysctl(), and sys_abort2().
struct sbuf* sbuf_uionew | ( | struct sbuf * | s, |
struct uio * | uio, | ||
int * | error | ||
) |
Definition at line 239 of file subr_sbuf.c.
References sbuf_delete(), SBUF_ISSECTION, sbuf_new(), and uiomove().
int sbuf_vprintf | ( | struct sbuf * | s, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 545 of file subr_sbuf.c.
References assert_sbuf_integrity, assert_sbuf_state, kvprintf(), and sbuf_putc_func().
Referenced by mount_argf(), and sbuf_printf().