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 ("$BSDSUniX$")
 
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,"")
 
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

#define LOG_ASYNC   0x04

Definition at line 55 of file subr_log.c.

Referenced by logioctl(), and logtimeout().

#define LOG_RDPRI   (PZERO + 1)

Definition at line 53 of file subr_log.c.

Referenced by logtimeout().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
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:

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

Definition at line 130 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:

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

Definition at line 256 of file subr_log.c.

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

Here is the call graph for this function:

static void logkqdetach ( struct knote note)
static

Definition at line 222 of file subr_log.c.

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

Here is the call graph for this function:

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

Definition at line 197 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:

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

Definition at line 213 of file subr_log.c.

References msgbuf_getcount(), and msgbuf_lock.

Here is the call graph for this function:

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

Definition at line 106 of file subr_log.c.

References fsetown(), hz, 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:

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

Definition at line 181 of file subr_log.c.

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

Here is the call graph for this function:

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

Definition at line 146 of file subr_log.c.

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

Here is the call graph for this function:

static void logtimeout ( void *  arg)
static

Definition at line 231 of file subr_log.c.

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

Referenced by logopen().

Here is the call graph for this function:

Here is the caller graph for this function:

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,
,
""   
)
SYSINIT ( logdev  ,
SI_SUB_DRIVERS  ,
SI_ORDER_MIDDLE  ,
log_drvinit  ,
NULL   
)

Variable Documentation

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:59
static d_ioctl_t logioctl
Definition: subr_log.c:60
static d_close_t logclose
Definition: subr_log.c:58
static d_open_t logopen
Definition: subr_log.c:57
static d_poll_t logpoll
Definition: subr_log.c:61
static d_kqfilter_t logkqfilter
Definition: subr_log.c:62

Definition at line 66 of file subr_log.c.

Referenced by log_drvinit().

int log_open

Definition at line 94 of file subr_log.c.

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

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:222
static int logkqread(struct knote *note, long hint)
Definition: subr_log.c:213

Definition at line 80 of file subr_log.c.

Referenced by logkqfilter().

struct cv log_wakeup
static

Definition at line 95 of file subr_log.c.

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

int log_wakeups_per_second = 5
static

Definition at line 100 of file subr_log.c.

Referenced by logopen(), and logtimeout().

d_close_t logclose
static

Definition at line 58 of file subr_log.c.

d_ioctl_t logioctl
static

Definition at line 60 of file subr_log.c.

d_kqfilter_t logkqfilter
static

Definition at line 62 of file subr_log.c.

d_open_t logopen
static

Definition at line 57 of file subr_log.c.

d_poll_t logpoll
static

Definition at line 61 of file subr_log.c.

d_read_t logread
static

Definition at line 59 of file subr_log.c.

struct logsoftc logsoftc
static