diff options
-rw-r--r-- | sys/conf/files | 1 | ||||
-rw-r--r-- | sys/kern/kern_conf.c | 89 | ||||
-rw-r--r-- | sys/kern/subr_xxx.c | 185 | ||||
-rw-r--r-- | sys/kern/sys_generic.c | 11 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 1 | ||||
-rw-r--r-- | sys/sys/conf.h | 12 | ||||
-rw-r--r-- | sys/sys/linedisc.h | 12 | ||||
-rw-r--r-- | sys/sys/systm.h | 1 |
8 files changed, 76 insertions, 236 deletions
diff --git a/sys/conf/files b/sys/conf/files index b465e44..8adf4dc 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1147,7 +1147,6 @@ kern/subr_smp.c optional smp kern/subr_taskqueue.c standard kern/subr_trap.c standard kern/subr_witness.c optional witness -kern/subr_xxx.c standard kern/sys_generic.c standard kern/sys_pipe.c standard kern/sys_process.c standard diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 56eaf11..d578077 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/conf.h> #include <sys/vnode.h> #include <sys/queue.h> +#include <sys/poll.h> #include <sys/ctype.h> #include <machine/stdarg.h> @@ -68,7 +69,19 @@ static int ready_for_devs; static int free_devt; SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, ""); -/* Define a dead_cdevsw for use when devices leave unexpectedly. */ +int +nullop(void) +{ + + return (0); +} + +int +eopnotsupp(void) +{ + + return (EOPNOTSUPP); +} static int enxio(void) @@ -76,13 +89,21 @@ enxio(void) return (ENXIO); } +static int +enodev(void) +{ + return (ENODEV); +} + +/* Define a dead_cdevsw for use when devices leave unexpectedly. */ + #define dead_open (d_open_t *)enxio #define dead_close (d_close_t *)enxio #define dead_read (d_read_t *)enxio #define dead_write (d_write_t *)enxio #define dead_ioctl (d_ioctl_t *)enxio -#define dead_poll nopoll -#define dead_mmap nommap +#define dead_poll (d_poll_t *)enodev +#define dead_mmap (d_mmap_t *)enodev static void dead_strategy(struct bio *bp) @@ -92,7 +113,6 @@ dead_strategy(struct bio *bp) } #define dead_dump (dumper_t *)enxio - #define dead_kqfilter (d_kqfilter_t *)enxio static struct cdevsw dead_cdevsw = { @@ -110,6 +130,47 @@ static struct cdevsw dead_cdevsw = { .d_kqfilter = dead_kqfilter }; +/* Default methods if driver does not specify method */ + +#define null_open (d_open_t *)nullop +#define null_close (d_close_t *)nullop +#define no_read (d_read_t *)enodev +#define no_write (d_write_t *)enodev +#define no_ioctl (d_ioctl_t *)enodev +#define no_mmap (d_mmap_t *)enodev + +static int +no_kqfilter(dev_t dev __unused, struct knote *kn __unused) +{ + + return (1); +} + +static void +no_strategy(struct bio *bp) +{ + + biofinish(bp, NULL, ENODEV); +} + +static int +no_poll(dev_t dev __unused, int events, struct thread *td __unused) +{ + /* + * Return true for read/write. If the user asked for something + * special, return POLLNVAL, so that clients have a way of + * determining reliably whether or not the extended + * functionality is present without hard-coding knowledge + * of specific filesystem implementations. + * Stay in sync with vop_nopoll(). + */ + if (events & ~POLLSTANDARD) + return (POLLNVAL); + + return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); +} + +#define no_dump (dumper_t *)enodev struct cdevsw * devsw(dev_t dev) @@ -276,16 +337,16 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const KASSERT((minor & ~0xffff00ff) == 0, ("Invalid minor (0x%x) in make_dev", minor)); - if (devsw->d_open == NULL) devsw->d_open = nullopen; - if (devsw->d_close == NULL) devsw->d_close = nullclose; - if (devsw->d_read == NULL) devsw->d_read = noread; - if (devsw->d_write == NULL) devsw->d_write = nowrite; - if (devsw->d_ioctl == NULL) devsw->d_ioctl = noioctl; - if (devsw->d_poll == NULL) devsw->d_poll = nopoll; - if (devsw->d_mmap == NULL) devsw->d_mmap = nommap; - if (devsw->d_strategy == NULL) devsw->d_strategy = nostrategy; - if (devsw->d_dump == NULL) devsw->d_dump = nodump; - if (devsw->d_kqfilter == NULL) devsw->d_kqfilter = nokqfilter; + if (devsw->d_open == NULL) devsw->d_open = null_open; + if (devsw->d_close == NULL) devsw->d_close = null_close; + if (devsw->d_read == NULL) devsw->d_read = no_read; + if (devsw->d_write == NULL) devsw->d_write = no_write; + if (devsw->d_ioctl == NULL) devsw->d_ioctl = no_ioctl; + if (devsw->d_poll == NULL) devsw->d_poll = no_poll; + if (devsw->d_mmap == NULL) devsw->d_mmap = no_mmap; + if (devsw->d_strategy == NULL) devsw->d_strategy = no_strategy; + if (devsw->d_dump == NULL) devsw->d_dump = no_dump; + if (devsw->d_kqfilter == NULL) devsw->d_kqfilter = no_kqfilter; if (devsw->d_maj == MAJOR_AUTO) { for (i = NUMCDEVSW - 1; i > 0; i--) diff --git a/sys/kern/subr_xxx.c b/sys/kern/subr_xxx.c deleted file mode 100644 index 186cc0b..0000000 --- a/sys/kern/subr_xxx.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)subr_xxx.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * Miscellaneous trivial functions. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> - -/* - * Return error for operation not supported - * on a specific object or file type. - */ -int -eopnotsupp() -{ - - return (EOPNOTSUPP); -} - -/* - * Generic null operation, always returns success. - */ -int -nullop() -{ - - return (0); -} - -#include <sys/conf.h> - -/* - * Unsupported devswitch functions (e.g. for writing to read-only device). - * XXX may belong elsewhere. - */ - -int -noopen(dev, flags, fmt, td) - dev_t dev; - int flags; - int fmt; - struct thread *td; -{ - - return (ENODEV); -} - -int -noclose(dev, flags, fmt, td) - dev_t dev; - int flags; - int fmt; - struct thread *td; -{ - - return (ENODEV); -} - -int -noread(dev, uio, ioflag) - dev_t dev; - struct uio *uio; - int ioflag; -{ - - return (ENODEV); -} - -int -nowrite(dev, uio, ioflag) - dev_t dev; - struct uio *uio; - int ioflag; -{ - - return (ENODEV); -} - -int -noioctl(dev, cmd, data, flags, td) - dev_t dev; - u_long cmd; - caddr_t data; - int flags; - struct thread *td; -{ - - return (ENODEV); -} - -int -nokqfilter(dev, kn) - dev_t dev; - struct knote *kn; -{ - - return (1); -} - -int -nommap(dev, offset, paddr, nprot) - dev_t dev; - vm_offset_t offset; - vm_paddr_t *paddr; - int nprot; -{ - - return (ENODEV); -} - -int -nodump(void *arg, void *virtual __unused, vm_offset_t physical __unused, off_t offset __unused, size_t length __unused) -{ - - return (ENODEV); -} - -/* - * Null devswitch functions (for when the operation always succeeds). - * XXX may belong elsewhere. - * XXX not all are here (e.g., seltrue() isn't). - */ - -/* - * XXX this is probably bogus. Any device that uses it isn't checking the - * minor number. - */ -int -nullopen(dev, flags, fmt, td) - dev_t dev; - int flags; - int fmt; - struct thread *td; -{ - - return (0); -} - -int -nullclose(dev, flags, fmt, td) - dev_t dev; - int flags; - int fmt; - struct thread *td; -{ - - return (0); -} diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index eec9c76..221ec00 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1132,17 +1132,6 @@ clear_selinfo_list(td) TAILQ_INIT(&td->td_selq); } -/*ARGSUSED*/ -int -seltrue(dev, events, td) - dev_t dev; - int events; - struct thread *td; -{ - - return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); -} - /* * Record a select request. */ diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 7626228..41c4040 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -343,6 +343,7 @@ vop_nopoll(ap) * determining reliably whether or not the extended * functionality is present without hard-coding knowledge * of specific filesystem implementations. + * Stay in sync with kern_conf.c::no_poll(). */ if (ap->a_events & ~POLLSTANDARD) return (POLLNVAL); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 14facba..c18d5b4 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -258,23 +258,11 @@ void ldisc_deregister(int); #endif /* _KERNEL */ #ifdef _KERNEL -d_read_t noread; -d_write_t nowrite; -d_ioctl_t noioctl; -d_mmap_t nommap; -d_kqfilter_t nokqfilter; -#define nostrategy ((d_strategy_t *)NULL) -#define nopoll seltrue - -dumper_t nodump; #define NUMCDEVSW 256 #define MAJOR_AUTO 0 /* XXX: Not GM */ -d_open_t nullopen; -d_close_t nullclose; - l_ioctl_t l_nullioctl; l_read_t l_noread; l_write_t l_nowrite; diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 14facba..c18d5b4 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -258,23 +258,11 @@ void ldisc_deregister(int); #endif /* _KERNEL */ #ifdef _KERNEL -d_read_t noread; -d_write_t nowrite; -d_ioctl_t noioctl; -d_mmap_t nommap; -d_kqfilter_t nokqfilter; -#define nostrategy ((d_strategy_t *)NULL) -#define nopoll seltrue - -dumper_t nodump; #define NUMCDEVSW 256 #define MAJOR_AUTO 0 /* XXX: Not GM */ -d_open_t nullopen; -d_close_t nullclose; - l_ioctl_t l_nullioctl; l_read_t l_noread; l_write_t l_nowrite; diff --git a/sys/sys/systm.h b/sys/sys/systm.h index e3e8dc4..bd034ea 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -126,7 +126,6 @@ void Debugger(const char *msg) __nonnull(1); int dumpstatus(vm_offset_t addr, off_t count); int nullop(void); int eopnotsupp(void); -int seltrue(dev_t dev, int which, struct thread *td); int ureadc(int, struct uio *); void hashdestroy(void *, struct malloc_type *, u_long); void *hashinit(int count, struct malloc_type *type, u_long *hashmask); |