subr_log.c (24206) | subr_log.c (29357) |
---|---|
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 | 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.21 1997/03/23 03:36:22 bde Exp $ | 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> | 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> |
|
52#ifdef DEVFS 53#include <sys/devfsext.h> 54#endif /*DEVFS*/ 55 56#define LOG_RDPRI (PZERO + 1) 57 58#define LOG_ASYNC 0x04 59#define LOG_RDWAIT 0x08 60 61static d_open_t logopen; 62static d_close_t logclose; 63static d_read_t logread; 64static d_ioctl_t logioctl; | 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; |
65static d_select_t logselect; | 66static d_poll_t logpoll; |
66 67#define CDEV_MAJOR 7 68static struct cdevsw log_cdevsw = 69 { logopen, logclose, logread, nowrite, /*7*/ 70 logioctl, nostop, nullreset, nodevtotty,/* klog */ | 67 68#define CDEV_MAJOR 7 69static struct cdevsw log_cdevsw = 70 { logopen, logclose, logread, nowrite, /*7*/ 71 logioctl, nostop, nullreset, nodevtotty,/* klog */ |
71 logselect, nommap, NULL, "log", NULL, -1 }; | 72 logpoll, nommap, NULL, "log", NULL, -1 }; |
72 73static struct logsoftc { 74 int sc_state; /* see above for possibilities */ 75 struct selinfo sc_selp; /* process waiting on select call */ 76 int sc_pgid; /* process/group for async I/O */ 77} logsoftc; 78 79int log_open; /* also used in log() */ --- 68 unchanged lines hidden (view full) --- 148 if (mbp->msg_bufr >= MSG_BSIZE) 149 mbp->msg_bufr = 0; 150 } 151 return (error); 152} 153 154/*ARGSUSED*/ 155static int | 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 |
156logselect(dev, rw, p) | 157logpoll(dev, events, p) |
157 dev_t dev; | 158 dev_t dev; |
158 int rw; | 159 int events; |
159 struct proc *p; 160{ | 160 struct proc *p; 161{ |
161 int s = splhigh(); | 162 int s; 163 int revents = 0; |
162 | 164 |
163 switch (rw) { | 165 s = splhigh(); |
164 | 166 |
165 case FREAD: 166 if (msgbufp->msg_bufr != msgbufp->msg_bufx) { 167 splx(s); 168 return (1); 169 } 170 selrecord(p, &logsoftc.sc_selp); 171 break; 172 } | 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); | 173 splx(s); |
174 return (0); | 174 return (revents); |
175} 176 177void 178logwakeup() 179{ 180 struct proc *p; 181 182 if (!log_open) --- 87 unchanged lines hidden --- | 175} 176 177void 178logwakeup() 179{ 180 struct proc *p; 181 182 if (!log_open) --- 87 unchanged lines hidden --- |