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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)subr_log.c 8.1 (Berkeley) 6/10/93 |
34 * $Id: subr_log.c,v 1.22 1997/03/24 11:52:25 bde Exp $ |
35 */ 36 37/* 38 * Error log buffer for kernel printf's. 39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/conf.h> 44#include <sys/proc.h> 45#include <sys/vnode.h> 46#include <sys/filio.h> 47#include <sys/ttycom.h> 48#include <sys/msgbuf.h> 49#include <sys/fcntl.h> 50#include <sys/signalvar.h> 51#include <sys/kernel.h> |
52#include <sys/poll.h> |
53#ifdef DEVFS 54#include <sys/devfsext.h> 55#endif /*DEVFS*/ 56 57#define LOG_RDPRI (PZERO + 1) 58 59#define LOG_ASYNC 0x04 60#define LOG_RDWAIT 0x08 61 62static d_open_t logopen; 63static d_close_t logclose; 64static d_read_t logread; 65static d_ioctl_t logioctl; |
66static d_poll_t logpoll; |
67 68#define CDEV_MAJOR 7 69static struct cdevsw log_cdevsw = 70 { logopen, logclose, logread, nowrite, /*7*/ 71 logioctl, nostop, nullreset, nodevtotty,/* klog */ |
72 logpoll, nommap, NULL, "log", NULL, -1 }; |
73 74static struct logsoftc { 75 int sc_state; /* see above for possibilities */ 76 struct selinfo sc_selp; /* process waiting on select call */ 77 int sc_pgid; /* process/group for async I/O */ 78} logsoftc; 79 80int log_open; /* also used in log() */ --- 68 unchanged lines hidden (view full) --- 149 if (mbp->msg_bufr >= MSG_BSIZE) 150 mbp->msg_bufr = 0; 151 } 152 return (error); 153} 154 155/*ARGSUSED*/ 156static int |
157logpoll(dev, events, p) |
158 dev_t dev; |
159 int events; |
160 struct proc *p; 161{ |
162 int s; 163 int revents = 0; |
164 |
165 s = splhigh(); |
166 |
167 if (events & (POLLIN | POLLRDNORM)) 168 if (msgbufp->msg_bufr != msgbufp->msg_bufx) 169 revents |= events & (POLLIN | POLLRDNORM); 170 else 171 selrecord(p, &logsoftc.sc_selp); 172 |
173 splx(s); |
174 return (revents); |
175} 176 177void 178logwakeup() 179{ 180 struct proc *p; 181 182 if (!log_open) --- 87 unchanged lines hidden --- |