FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_printf.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/kdb.h>
#include <sys/mutex.h>
#include <sys/sx.h>
#include <sys/kernel.h>
#include <sys/msgbuf.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/stddef.h>
#include <sys/sysctl.h>
#include <sys/tty.h>
#include <sys/syslog.h>
#include <sys/cons.h>
#include <sys/uio.h>
#include <sys/ctype.h>
#include <sys/sbuf.h>
#include <machine/stdarg.h>
Go to the source code of this file.
Data Structures | |
struct | putchar_arg |
struct | snprintf_arg |
Macros | |
#define | TOCONS 0x01 |
#define | TOTTY 0x02 |
#define | TOLOG 0x04 |
#define | MAXNBUF (sizeof(intmax_t) * NBBY + 1) |
#define | BOOT_TAG_SZ 32 |
#define | BOOT_TAG "---<<BOOT>>---" |
#define | CONSCHUNK 128 |
#define | PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | msglogchar (int c, int pri) |
static void | msglogstr (char *str, int pri, int filter_cr) |
static void | prf_putbuf (char *bufr, int flags, int pri) |
static void | putchar (int ch, void *arg) |
static char * | ksprintn (char *nbuf, uintmax_t num, int base, int *len, int upper) |
static void | snprintf_func (int ch, void *arg) |
SYSCTL_STRING (_kern, OID_AUTO, boot_tag, CTLFLAG_RDTUN|CTLFLAG_NOFETCH, current_boot_tag, 0, "Tag added to dmesg at start of boot") | |
SYSCTL_INT (_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN, &log_console_output, 0, "Duplicate console output to the syslog") | |
SYSCTL_INT (_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RWTUN, &log_console_add_linefeed, 0, "log_console() adds extra newlines") | |
SYSCTL_INT (_kern, OID_AUTO, always_console_output, CTLFLAG_RWTUN, &always_console_output, 0, "Always output to console despite TIOCCONS") | |
void | tablefull (const char *tab) |
int | uprintf (const char *fmt,...) |
void | tprintf (struct proc *p, int pri, const char *fmt,...) |
void | vtprintf (struct proc *p, int pri, const char *fmt, va_list ap) |
static int | _vprintf (int level, int flags, const char *fmt, va_list ap) |
void | log (int level, const char *fmt,...) |
void | vlog (int level, const char *fmt, va_list ap) |
void | log_console (struct uio *uio) |
int | printf (const char *fmt,...) |
int | vprintf (const char *fmt, va_list ap) |
static void | prf_putchar (int c, int flags, int pri) |
static void | putbuf (int c, struct putchar_arg *ap) |
int | sprintf (char *buf, const char *cfmt,...) |
int | vsprintf (char *buf, const char *cfmt, va_list ap) |
int | snprintf (char *str, size_t size, const char *format,...) |
int | vsnprintf (char *str, size_t size, const char *format, va_list ap) |
int | vsnrprintf (char *str, size_t size, int radix, const char *format, va_list ap) |
int | kvprintf (char const *fmt, void(*func)(int, void *), void *arg, int radix, va_list ap) |
void | msgbufinit (void *ptr, int size) |
static int | sysctl_kern_msgbuf (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_kern, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer") | |
static int | sysctl_kern_msgbuf_clear (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_kern, OID_AUTO, msgbuf_clear, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, &msgbuf_clearflag, 0, sysctl_kern_msgbuf_clear, "I", "Clear kernel message buffer") | |
void | hexdump (const void *ptr, int length, const char *hdr, int flags) |
void | sbuf_hexdump (struct sbuf *sb, const void *ptr, int length, const char *hdr, int flags) |
void | counted_warning (unsigned *counter, const char *msg) |
void | sbuf_putbuf (struct sbuf *sb) |
int | sbuf_printf_drain (void *arg, const char *data, int len) |
Variables | |
int | log_open |
static bool | msgbufmapped |
int | msgbuftrigger |
struct msgbuf * | msgbufp |
static char | current_boot_tag [BOOT_TAG_SZ+1] = BOOT_TAG |
static int | log_console_output = 1 |
static int | log_console_add_linefeed |
static int | always_console_output |
static int | msgbuf_clearflag |
#define BOOT_TAG "---<<BOOT>>---" |
Definition at line 135 of file subr_prf.c.
#define BOOT_TAG_SZ 32 |
Definition at line 131 of file subr_prf.c.
#define CONSCHUNK 128 |
Definition at line 331 of file subr_prf.c.
#define MAXNBUF (sizeof(intmax_t) * NBBY + 1) |
Definition at line 100 of file subr_prf.c.
#define PCHAR | ( | c | ) | {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } |
#define TOCONS 0x01 |
Definition at line 95 of file subr_prf.c.
#define TOLOG 0x04 |
Definition at line 97 of file subr_prf.c.
#define TOTTY 0x02 |
Definition at line 96 of file subr_prf.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 273 of file subr_prf.c.
References putchar_arg::flags, flags, kvprintf(), level, putchar_arg::n_bufr, putchar_arg::p_bufr, putchar_arg::p_next, prf_putbuf(), putchar_arg::pri, putchar(), putchar_arg::remain, and putchar_arg::tty.
Referenced by vlog(), and vprintf().
void counted_warning | ( | unsigned * | counter, |
const char * | msg | ||
) |
Definition at line 1261 of file subr_prf.c.
References log().
Referenced by aio_queue_file().
void hexdump | ( | const void * | ptr, |
int | length, | ||
const char * | hdr, | ||
int | flags | ||
) |
Definition at line 1152 of file subr_prf.c.
References flags, and printf().
|
static |
Definition at line 613 of file subr_prf.c.
References nbuf.
Referenced by kvprintf(), and msglogchar().
int kvprintf | ( | char const * | fmt, |
void(*)(int, void *) | func, | ||
void * | arg, | ||
int | radix, | ||
va_list | ap | ||
) |
Definition at line 655 of file subr_prf.c.
References ksprintn(), MAXNBUF, nbuf, PCHAR, and stop.
Referenced by _vprintf(), sbuf_vprintf(), sprintf(), uprintf(), vsnprintf(), vsnrprintf(), vsprintf(), and vtprintf().
void log | ( | int | level, |
const char * | fmt, | ||
... | |||
) |
Definition at line 314 of file subr_prf.c.
Referenced by acct_disable(), acctwatch(), coredump(), corefile_open(), counted_warning(), device_log(), encode_long(), ether_poll_deregister(), ether_poll_register(), kern_abort2(), killproc(), sigexit(), sonewconn(), sys_acct(), syscall_not_present(), tablefull(), tc_setclock(), and vfs_sysctl().
void log_console | ( | struct uio * | uio | ) |
Definition at line 334 of file subr_prf.c.
References cloneuio(), CONSCHUNK, free(), log_console_add_linefeed, log_console_output, malloc(), msgbuftrigger, msglogstr(), putchar_arg::pri, and uiomove().
Referenced by ttyconsdev_write().
void msgbufinit | ( | void * | ptr, |
int | size | ||
) |
Definition at line 1034 of file subr_prf.c.
References current_boot_tag, msgbuf_copy(), msgbuf_reinit(), msgbufmapped, msgbufp, and printf().
|
static |
Definition at line 993 of file subr_prf.c.
References ksprintn(), MAXNBUF, msgbuf_addchar(), msgbufmapped, msgbufp, and nbuf.
Referenced by prf_putchar().
|
static |
Definition at line 1025 of file subr_prf.c.
References msgbuf_addstr(), msgbufmapped, msgbufp, and snprintf_arg::str.
Referenced by log_console(), and prf_putbuf().
|
static |
Definition at line 439 of file subr_prf.c.
References always_console_output, cnputs(), flags, msgbuf_addstr(), msglogstr(), putchar_arg::pri, TOCONS, and TOLOG.
Referenced by _vprintf(), putbuf(), sbuf_printf_drain(), and sbuf_putbuf().
|
static |
Definition at line 423 of file subr_prf.c.
References always_console_output, cnputc(), flags, msgbuf_addchar(), msglogchar(), putchar_arg::pri, TOCONS, and TOLOG.
Referenced by putbuf().
int printf | ( | const char * | fmt, |
... | |||
) |
Definition at line 397 of file subr_prf.c.
References vprintf().
Referenced by _falloc_noinstall(), _gone_in(), _gtaskqueue_start_threads(), _isitmyx(), _mtx_lock_indefinite_check(), _taskqueue_start_threads(), acl_posix1e_mode_to_entry(), acl_posix1e_mode_to_perm(), adopt(), blist_create(), boottrace_display(), buf_daemon_shutdown(), bufshutdown(), bufspace_daemon_shutdown(), bus_print_child_domain(), bus_print_child_footer(), bus_print_child_header(), calcru1(), cf_get_method(), chglimit(), clock_bcd_to_ts(), clock_ct_to_ts(), clock_dbgprint_bcd(), clock_dbgprint_ct(), clock_dbgprint_err(), clock_dbgprint_hdr(), clock_dbgprint_ts(), clock_print_bcd(), clock_print_ct(), clock_ts_to_ct(), clockcalib(), clone_create(), cluster_rbuild(), cnadd(), config_intrhook_establish(), cpu_tick_calibrate(), cpufreq_curr_sysctl(), cpufreq_levels_sysctl(), destroy_devl(), devclass_alloc_unit(), device_attach(), device_print_prettyname(), device_probe(), device_probe_child(), device_set_devclass(), devmap_print_table(), devstat_add_entry(), disk_err(), domain_add(), dump_check_bounds(), dumpsys_cb_dumpdata(), dumpsys_generic(), encode_long(), encode_timeval(), et_register(), exit1(), fail_point_eval_nontrivial(), fail_point_set(), firmware_get_flags(), firmware_modevent(), firmware_mountroot(), firmware_register(), fork1(), fork_exit(), getenv_bool(), getnewvnode(), graph_add_edge(), graph_remove_edge(), hexdump(), hhook_vnet_uninit(), in_epoch_verbose_preempt(), init_dynamic_kenv_from(), init_hwpmc(), inittimecounter(), inittodr(), insert_brand_entry(), ithread_execute_handlers(), kcov_init(), kcsan_enable(), kdb_backtrace(), kdb_backtrace_thread(), kdb_enter(), kdb_init(), kdb_panic(), kdb_reboot(), kdb_reenter(), kdb_trap(), kern_kldunload(), kern_vfs_bio_buffer_alloc(), khelp_modevent(), khelp_new_hhook_registered(), kproc_shutdown(), kqueue_add_filteropts(), kthread_shutdown(), ktls_alloc_thread(), ktls_init(), ktls_work_thread(), ktr_tracepoint(), lf_activate_lock(), lf_advlockasync(), lf_alloc_lock(), lf_findoverlap(), lf_free_lock(), link_elf_ctf_get(), link_elf_error(), link_elf_link_preload(), link_elf_load_file(), link_elf_lookup_symbol1(), link_elf_preload_parse_symbols(), linker_addmodules(), linker_file_register_modules(), linker_hints_lookup(), linker_load_dependencies(), linker_load_file(), linker_preload(), loadimage(), lockmgr_printinfo(), logopen(), logtimeout(), m_print(), m_pulldown(), make_device(), malloc_uninit(), maxbcachebuf_adjust(), mi_startup(), module_register(), module_register_init(), msgbuf_reinit(), msgbufinit(), mtx_pool_create(), nosys(), parse_dir_ask(), parse_dir_ask_printenv(), parse_dir_md(), parse_dir_onfail(), parse_directive(), parse_dpcpu(), parse_mount(), physio(), physmem_print_tables(), pipespace_new(), pmc_soft_ev_register(), power_profile_set_state(), prep_cdevsw(), print_caddr_t(), print_uptime(), print_version(), printf_uuid(), prison0_init(), propagate_priority(), register_posix_clock(), relocate_file1(), reroot_conf(), res_find(), resource_list_print_type(), root_print_child(), run_interrupt_driven_config_hooks_warning(), runq_print(), sbuf_printf_drain(), sched_sync(), sdt_probe_stub(), settime(), shminit(), shutdown_halt(), shutdown_panic(), shutdown_reset(), sigprocess(), socket_hhook_deregister(), socket_hhook_register(), softclock_call_cc(), stack_print(), stack_print_ddb(), stack_print_short(), start_init(), start_softclock(), stats_v1_vsd_tdgst_add(), suspend_all_fs(), sys_ioctl(), sysctl_clock_do_io(), sysctl_kern_callout_stat(), sysctl_load_tunable_by_oid_locked(), sysctl_register_oid(), sysctl_remove_oid_locked(), sysctl_unregister_oid(), taskqgroup_attach(), taskqgroup_attach_cpu(), taskqgroup_binder(), tc_init(), tdq_print(), tdq_setup(), thread_count_inc(), ttcompatgetflags(), tty_ioctl_compat(), tvtohz(), uifree(), uiomove_object_page(), unmount_or_warn(), vaccess_acl_posix1e(), vfs_deferred_unmount(), vfs_domount_first(), vfs_donmount(), vfs_filteropt(), vfs_lookup(), vfs_mountroot_devfs(), vfs_mountroot_parse(), vfs_mountroot_shuffle(), vfs_mountroot_wait(), vfs_mountroot_wait_if_neccessary(), vfs_register(), vfs_relookup(), vn_printf(), vntblinit(), vop_nostrategy(), vpanic(), watchdog_fire(), witness_get(), witness_lock_list_get(), and witness_warn().
|
static |
Definition at line 456 of file subr_prf.c.
References putchar_arg::flags, putchar_arg::n_bufr, putchar_arg::p_bufr, putchar_arg::p_next, prf_putbuf(), prf_putchar(), putchar_arg::pri, and putchar_arg::remain.
Referenced by putchar().
|
static |
Definition at line 497 of file subr_prf.c.
References cnputc(), putchar_arg::flags, flags, kdb_active, putbuf(), TOCONS, TOLOG, TOTTY, putchar_arg::tty, and tty_putchar().
Referenced by _vprintf(), uprintf(), and vtprintf().
void sbuf_hexdump | ( | struct sbuf * | sb, |
const void * | ptr, | ||
int | length, | ||
const char * | hdr, | ||
int | flags | ||
) |
Definition at line 1206 of file subr_prf.c.
References flags, and sbuf_printf().
int sbuf_printf_drain | ( | void * | arg, |
const char * | data, | ||
int | len | ||
) |
Definition at line 1298 of file subr_prf.c.
References data, prf_putbuf(), printf(), TOCONS, and TOLOG.
Referenced by device_printf(), preload_dump(), and sysctl_warn_reuse().
void sbuf_putbuf | ( | struct sbuf * | sb | ) |
Definition at line 1283 of file subr_prf.c.
References prf_putbuf(), sbuf_data(), TOCONS, and TOLOG.
int snprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
... | |||
) |
Definition at line 550 of file subr_prf.c.
References vsnprintf().
Referenced by _gtaskqueue_create(), _taskqueue_create(), alloc_bounce_zone(), bitset_strprint(), boottrace_reset(), busdma_bufalloc_create(), callout_cpu_init(), corefile_open_last(), DeserializeLocation(), DeserializeNumberSigned(), DeserializeNumberUnsigned(), devclass_add_device(), intrcnt_setname(), isrc_update_name(), kern_jail_set(), ktls_alloc_thread(), link_elf_lookup_set(), linker_hints_lookup(), linker_lookup_file(), load_interp(), mqfs_read(), msgbuf_addstr(), qc_init(), sched_tdname(), shm_init(), snprintf_uuid(), sysctl_build_id(), sysctl_debug_witness_channel(), sysctl_jail_param(), sysctl_kern_eventtimer_timer(), sysctl_rman(), sysctl_sysctl_name(), taskqgroup_attach(), taskqgroup_attach_cpu(), tdq_setup(), vfs_filteropt(), and vn_printf().
|
static |
Definition at line 596 of file subr_prf.c.
References snprintf_arg::remain, and snprintf_arg::str.
Referenced by vsnprintf(), and vsnrprintf().
int sprintf | ( | char * | buf, |
const char * | cfmt, | ||
... | |||
) |
Definition at line 521 of file subr_prf.c.
References buf, and kvprintf().
Referenced by kern_setenv(), linker_find_file_by_name(), make_dev_physpath_alias(), msgbuf_addstr(), setenv_static(), stats_tpl_sample_rates(), sysctl_handle_domainset(), and termcn_cnregister().
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
always_console_output | , | ||
CTLFLAG_RWTUN | , | ||
& | always_console_output, | ||
0 | , | ||
"Always output to console despite TIOCCONS" | |||
) |
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
log_console_add_linefeed | , | ||
CTLFLAG_RWTUN | , | ||
& | log_console_add_linefeed, | ||
0 | , | ||
"log_console() adds extra newlines" | |||
) |
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
log_console_output | , | ||
CTLFLAG_RWTUN | , | ||
& | log_console_output, | ||
0 | , | ||
"Duplicate console output to the syslog" | |||
) |
|
static |
Definition at line 1059 of file subr_prf.c.
References buf, msgbuf_lock, msgbuf_peekbytes(), msgbufp, priv_check(), and sysctl_handle_opaque().
|
static |
Definition at line 1110 of file subr_prf.c.
References msgbuf_clear(), msgbuf_clearflag, msgbuf_lock, msgbufp, and sysctl_handle_int().
SYSCTL_PROC | ( | _kern | , |
OID_AUTO | , | ||
msgbuf | , | ||
CTLTYPE_STRING|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
sysctl_kern_msgbuf | , | ||
"A" | , | ||
"Contents of kernel message buffer" | |||
) |
SYSCTL_PROC | ( | _kern | , |
OID_AUTO | , | ||
msgbuf_clear | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
& | msgbuf_clearflag, | ||
0 | , | ||
sysctl_kern_msgbuf_clear | , | ||
"I" | , | ||
"Clear kernel message buffer" | |||
) |
SYSCTL_STRING | ( | _kern | , |
OID_AUTO | , | ||
boot_tag | , | ||
CTLFLAG_RDTUN| | CTLFLAG_NOFETCH, | ||
current_boot_tag | , | ||
0 | , | ||
"Tag added to dmesg at start of boot" | |||
) |
void tablefull | ( | const char * | tab | ) |
Definition at line 161 of file subr_prf.c.
References log().
void tprintf | ( | struct proc * | p, |
int | pri, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 223 of file subr_prf.c.
References vtprintf().
int uprintf | ( | const char * | fmt, |
... | |||
) |
Definition at line 171 of file subr_prf.c.
References putchar_arg::flags, initproc, kvprintf(), putchar_arg::p_bufr, proctree_lock, putchar(), TOTTY, putchar_arg::tty, and vprintf().
Referenced by __CONCAT(), do_execve(), enforce_limits(), exec_map_stack(), get_interp(), load_interp(), load_section(), nosys(), parse_dpcpu(), parse_notes(), physio(), and umtx_cleanup_rb_list().
void vlog | ( | int | level, |
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 324 of file subr_prf.c.
References _vprintf(), level, log_open, msgbuftrigger, TOCONS, and TOLOG.
Referenced by log(), and witness_voutput().
int vprintf | ( | const char * | fmt, |
va_list | ap | ||
) |
Definition at line 410 of file subr_prf.c.
References _vprintf(), msgbuftrigger, TOCONS, and TOLOG.
Referenced by printf(), Report(), uprintf(), vn_printf(), vpanic(), witness_voutput(), and witness_warn().
int vsnprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
va_list | ap | ||
) |
Definition at line 565 of file subr_prf.c.
References kvprintf(), snprintf_arg::remain, snprintf_func(), and snprintf_arg::str.
Referenced by _gtaskqueue_start_threads(), _taskqueue_start_threads(), boottrace(), bus_describe_intr(), fail_point_init(), intr_event_create(), intr_isrc_register(), kproc_create(), kproc_kthread_add(), kthread_add(), snprintf(), vfs_mount_error(), vfs_opterror(), and vpanic().
int vsnrprintf | ( | char * | str, |
size_t | size, | ||
int | radix, | ||
const char * | format, | ||
va_list | ap | ||
) |
Definition at line 582 of file subr_prf.c.
References kvprintf(), snprintf_arg::remain, snprintf_func(), and snprintf_arg::str.
Referenced by prep_devname(), terminal_maketty(), and tty_makedevf().
int vsprintf | ( | char * | buf, |
const char * | cfmt, | ||
va_list | ap | ||
) |
Definition at line 537 of file subr_prf.c.
References buf, and kvprintf().
void vtprintf | ( | struct proc * | p, |
int | pri, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
Definition at line 233 of file subr_prf.c.
References putchar_arg::flags, flags, kvprintf(), msgbuftrigger, putchar_arg::p_bufr, putchar_arg::pri, proctree_lock, putchar(), sess_hold(), sess_release(), TOLOG, TOTTY, putchar_arg::tty, and tty_checkoutq().
Referenced by tprintf().
|
static |
Definition at line 153 of file subr_prf.c.
Referenced by prf_putbuf(), and prf_putchar().
|
static |
Definition at line 138 of file subr_prf.c.
Referenced by msgbufinit().
|
static |
Definition at line 149 of file subr_prf.c.
Referenced by log_console().
|
static |
Definition at line 142 of file subr_prf.c.
Referenced by log_console().
|
extern |
Definition at line 96 of file subr_log.c.
Referenced by logclose(), logopen(), logtimeout(), and vlog().
|
static |
Definition at line 1107 of file subr_prf.c.
Referenced by sysctl_kern_msgbuf_clear().
|
static |
Definition at line 126 of file subr_prf.c.
Referenced by msgbufinit(), msglogchar(), and msglogstr().
struct msgbuf* msgbufp |
Definition at line 128 of file subr_prf.c.
Referenced by logioctl(), logkqread(), logpoll(), logread(), msgbufinit(), msglogchar(), msglogstr(), sysctl_kern_msgbuf(), and sysctl_kern_msgbuf_clear().
int msgbuftrigger |
Definition at line 127 of file subr_prf.c.
Referenced by log_console(), logtimeout(), vlog(), vprintf(), and vtprintf().