Deleted Added
sdiff udiff text old ( 216952 ) new ( 230866 )
full compact
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 20 unchanged lines hidden (view full) ---

29 * @(#)subr_log.c 8.1 (Berkeley) 6/10/93
30 */
31
32/*
33 * Error log buffer for kernel printf's.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/kern/subr_log.c 216952 2011-01-04 10:59:38Z kib $");
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/conf.h>
42#include <sys/proc.h>
43#include <sys/vnode.h>
44#include <sys/filio.h>
45#include <sys/ttycom.h>

--- 8 unchanged lines hidden (view full) ---

54
55#define LOG_ASYNC 0x04
56
57static d_open_t logopen;
58static d_close_t logclose;
59static d_read_t logread;
60static d_ioctl_t logioctl;
61static d_poll_t logpoll;
62
63static void logtimeout(void *arg);
64
65static struct cdevsw log_cdevsw = {
66 .d_version = D_VERSION,
67 .d_open = logopen,
68 .d_close = logclose,
69 .d_read = logread,
70 .d_ioctl = logioctl,
71 .d_poll = logpoll,
72 .d_name = "log",
73};
74
75static struct logsoftc {
76 int sc_state; /* see above for possibilities */
77 struct selinfo sc_selp; /* process waiting on select call */
78 struct sigio *sc_sigio; /* information for async I/O */
79 struct callout sc_callout; /* callout to wakeup syslog */
80} logsoftc;
81
82int log_open; /* also used in log() */

--- 93 unchanged lines hidden (view full) ---

176 revents |= events & (POLLIN | POLLRDNORM);
177 else
178 selrecord(td, &logsoftc.sc_selp);
179 mtx_unlock(&msgbuf_lock);
180 }
181 return (revents);
182}
183
184static void
185logtimeout(void *arg)
186{
187
188 if (!log_open)
189 return;
190 if (log_wakeups_per_second < 1) {
191 printf("syslog wakeup is less than one. Adjusting to 1.\n");
192 log_wakeups_per_second = 1;
193 }
194 if (msgbuftrigger == 0) {
195 callout_schedule(&logsoftc.sc_callout,
196 hz / log_wakeups_per_second);
197 return;
198 }
199 msgbuftrigger = 0;
200 selwakeuppri(&logsoftc.sc_selp, LOG_RDPRI);
201 if ((logsoftc.sc_state & LOG_ASYNC) && logsoftc.sc_sigio != NULL)
202 pgsigio(&logsoftc.sc_sigio, SIGIO, 0);
203 cv_broadcastpri(&log_wakeup, LOG_RDPRI);
204 callout_schedule(&logsoftc.sc_callout, hz / log_wakeups_per_second);
205}
206
207/*ARGSUSED*/
208static int

--- 42 unchanged lines hidden (view full) ---

251}
252
253static void
254log_drvinit(void *unused)
255{
256
257 cv_init(&log_wakeup, "klog");
258 callout_init_mtx(&logsoftc.sc_callout, &msgbuf_lock, 0);
259 make_dev_credf(MAKEDEV_ETERNAL, &log_cdevsw, 0, NULL, UID_ROOT,
260 GID_WHEEL, 0600, "klog");
261}
262
263SYSINIT(logdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,log_drvinit,NULL);