FreeBSD kernel kern code
subr_log.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/filio.h>
#include <sys/ttycom.h>
#include <sys/msgbuf.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/poll.h>
#include <sys/filedesc.h>
#include <sys/sysctl.h>
Include dependency graph for subr_log.c:

Go to the source code of this file.

Data Structures

struct  logsoftc
 

Macros

#define LOG_RDPRI   (PZERO + 1)
 
#define LOG_ASYNC   0x04
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void logtimeout (void *arg)
 
static int logkqread (struct knote *note, long hint)
 
static void logkqdetach (struct knote *note)
 
 MTX_SYSINIT (msgbuf_lock, &msgbuf_lock, "msgbuf lock", MTX_DEF)
 
 SYSCTL_INT (_kern, OID_AUTO, log_wakeups_per_second, CTLFLAG_RW, &log_wakeups_per_second, 0, "How often (times per second) to check for /dev/log waiters.")
 
static int logopen (struct cdev *dev, int flags, int mode, struct thread *td)
 
static int logclose (struct cdev *dev, int flag, int mode, struct thread *td)
 
static int logread (struct cdev *dev, struct uio *uio, int flag)
 
static int logpoll (struct cdev *dev, int events, struct thread *td)
 
static int logkqfilter (struct cdev *dev, struct knote *kn)
 
static int logioctl (struct cdev *dev, u_long com, caddr_t data, int flag, struct thread *td)
 
static void log_drvinit (void *unused)
 
 SYSINIT (logdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, log_drvinit, NULL)
 

Variables

static d_open_t logopen
 
static d_close_t logclose
 
static d_read_t logread
 
static d_ioctl_t logioctl
 
static d_poll_t logpoll
 
static d_kqfilter_t logkqfilter
 
static struct cdevsw log_cdevsw
 
static struct filterops log_read_filterops
 
static struct logsoftc logsoftc
 
int log_open
 
static struct cv log_wakeup
 
struct mtx msgbuf_lock
 
static int log_wakeups_per_second = 5
 

Macro Definition Documentation

◆ LOG_ASYNC

#define LOG_ASYNC   0x04

Definition at line 57 of file subr_log.c.

◆ LOG_RDPRI

#define LOG_RDPRI   (PZERO + 1)

Definition at line 55 of file subr_log.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ log_drvinit()

static void log_drvinit ( void *  unused)
static

Definition at line 301 of file subr_log.c.

References cv_init(), knlist_init_mtx(), log_cdevsw, log_wakeup, make_dev_credf(), msgbuf_lock, logsoftc::sc_callout, and logsoftc::sc_selp.

Here is the call graph for this function:

◆ logclose()

static int logclose ( struct cdev *  dev,
int  flag,
int  mode,
struct thread *  td 
)
static

Definition at line 132 of file subr_log.c.

References funsetown(), log_open, msgbuf_lock, logsoftc::sc_callout, logsoftc::sc_sigio, and logsoftc::sc_state.

Here is the call graph for this function:

◆ logioctl()

static int logioctl ( struct cdev *  dev,
u_long  com,
caddr_t  data,
int  flag,
struct thread *  td 
)
static

Definition at line 257 of file subr_log.c.

References data, fgetown(), fsetown(), LOG_ASYNC, msgbuf_getcount(), msgbuf_lock, msgbufp, logsoftc::sc_sigio, and logsoftc::sc_state.

Here is the call graph for this function:

◆ logkqdetach()

static void logkqdetach ( struct knote note)
static

Definition at line 224 of file subr_log.c.

References knlist_remove(), msgbuf_lock, and logsoftc::sc_selp.

Here is the call graph for this function:

◆ logkqfilter()

static int logkqfilter ( struct cdev *  dev,
struct knote kn 
)
static

Definition at line 199 of file subr_log.c.

References knlist_add(), log_read_filterops, msgbuf_lock, and logsoftc::sc_selp.

Here is the call graph for this function:

◆ logkqread()

static int logkqread ( struct knote note,
long  hint 
)
static

Definition at line 215 of file subr_log.c.

References msgbuf_getcount(), msgbuf_lock, and msgbufp.

Here is the call graph for this function:

◆ logopen()

static int logopen ( struct cdev *  dev,
int  flags,
int  mode,
struct thread *  td 
)
static

Definition at line 108 of file subr_log.c.

References fsetown(), log_open, log_wakeups_per_second, logtimeout(), msgbuf_lock, printf(), logsoftc::sc_callout, and logsoftc::sc_sigio.

Here is the call graph for this function:

◆ logpoll()

static int logpoll ( struct cdev *  dev,
int  events,
struct thread *  td 
)
static

Definition at line 183 of file subr_log.c.

References msgbuf_getcount(), msgbuf_lock, msgbufp, logsoftc::sc_selp, and selrecord().

Here is the call graph for this function:

◆ logread()

static int logread ( struct cdev *  dev,
struct uio *  uio,
int  flag 
)
static

Definition at line 148 of file subr_log.c.

References buf, flag, log_wakeup, msgbuf_getbytes(), msgbuf_getcount(), msgbuf_lock, msgbufp, and uiomove().

Here is the call graph for this function:

◆ logtimeout()

static void logtimeout ( void *  arg)
static

Definition at line 233 of file subr_log.c.

References cv_broadcastpri(), LOG_ASYNC, log_open, LOG_RDPRI, log_wakeup, log_wakeups_per_second, logtimeout(), msgbuftrigger, pgsigio(), printf(), logsoftc::sc_callout, logsoftc::sc_selp, logsoftc::sc_sigio, logsoftc::sc_state, and selwakeuppri().

Referenced by logopen(), and logtimeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MTX_SYSINIT()

MTX_SYSINIT ( msgbuf_lock  ,
msgbuf_lock,
"msgbuf lock"  ,
MTX_DEF   
)

◆ SYSCTL_INT()

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
log_wakeups_per_second  ,
CTLFLAG_RW  ,
log_wakeups_per_second,
,
"How often (times per second) to check for /dev/log waiters."   
)

◆ SYSINIT()

SYSINIT ( logdev  ,
SI_SUB_DRIVERS  ,
SI_ORDER_MIDDLE  ,
log_drvinit  ,
NULL   
)

Variable Documentation

◆ log_cdevsw

struct cdevsw log_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_open = logopen,
.d_close = logclose,
.d_read = logread,
.d_ioctl = logioctl,
.d_poll = logpoll,
.d_kqfilter = logkqfilter,
.d_name = "log",
}
static d_read_t logread
Definition: subr_log.c:61
static d_close_t logclose
Definition: subr_log.c:60
static d_poll_t logpoll
Definition: subr_log.c:63
static d_open_t logopen
Definition: subr_log.c:59
static d_ioctl_t logioctl
Definition: subr_log.c:62
static d_kqfilter_t logkqfilter
Definition: subr_log.c:64

Definition at line 68 of file subr_log.c.

Referenced by log_drvinit().

◆ log_open

int log_open

Definition at line 96 of file subr_log.c.

Referenced by logclose(), logopen(), logtimeout(), and vlog().

◆ log_read_filterops

struct filterops log_read_filterops
static
Initial value:
= {
.f_isfd = 1,
.f_attach = NULL,
.f_detach = logkqdetach,
.f_event = logkqread,
}
static void logkqdetach(struct knote *note)
Definition: subr_log.c:224
static int logkqread(struct knote *note, long hint)
Definition: subr_log.c:215

Definition at line 82 of file subr_log.c.

Referenced by logkqfilter().

◆ log_wakeup

struct cv log_wakeup
static

Definition at line 97 of file subr_log.c.

Referenced by log_drvinit(), logread(), and logtimeout().

◆ log_wakeups_per_second

int log_wakeups_per_second = 5
static

Definition at line 101 of file subr_log.c.

Referenced by logopen(), and logtimeout().

◆ logclose

d_close_t logclose
static

Definition at line 60 of file subr_log.c.

◆ logioctl

d_ioctl_t logioctl
static

Definition at line 62 of file subr_log.c.

◆ logkqfilter

d_kqfilter_t logkqfilter
static

Definition at line 64 of file subr_log.c.

◆ logopen

d_open_t logopen
static

Definition at line 59 of file subr_log.c.

◆ logpoll

d_poll_t logpoll
static

Definition at line 63 of file subr_log.c.

◆ logread

d_read_t logread
static

Definition at line 61 of file subr_log.c.

◆ logsoftc

struct logsoftc logsoftc
static

◆ msgbuf_lock