2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
40 #include "opt_compat.h"
41 #include "opt_ktrace.h"
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/sysproto.h>
46 #include <sys/filedesc.h>
47 #include <sys/filio.h>
48 #include <sys/fcntl.h>
51 #include <sys/signalvar.h>
52 #include <sys/socketvar.h>
54 #include <sys/kernel.h>
55 #include <sys/limits.h>
56 #include <sys/malloc.h>
58 #include <sys/resourcevar.h>
59 #include <sys/selinfo.h>
60 #include <sys/sleepqueue.h>
61 #include <sys/syscallsubr.h>
62 #include <sys/sysctl.h>
63 #include <sys/sysent.h>
64 #include <sys/vnode.h>
67 #include <sys/condvar.h>
69 #include <sys/ktrace.h>
72 static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer");
73 static MALLOC_DEFINE(M_SELECT, "select", "select() buffer");
74 MALLOC_DEFINE(M_IOV, "iov", "large iov's");
76 static int pollout(struct pollfd *, struct pollfd *, u_int);
77 static int pollscan(struct thread *, struct pollfd *, u_int);
78 static int selscan(struct thread *, fd_mask **, fd_mask **, int);
79 static int dofileread(struct thread *, int, struct file *, struct uio *,
81 static int dofilewrite(struct thread *, int, struct file *, struct uio *,
83 static void doselwakeup(struct selinfo *, int);
85 #ifndef _SYS_SYSPROTO_H_
95 struct read_args *uap;
101 if (uap->nbyte > INT_MAX)
103 aiov.iov_base = uap->buf;
104 aiov.iov_len = uap->nbyte;
105 auio.uio_iov = &aiov;
107 auio.uio_resid = uap->nbyte;
108 auio.uio_segflg = UIO_USERSPACE;
109 error = kern_readv(td, uap->fd, &auio);
114 * Positioned read system call
116 #ifndef _SYS_SYSPROTO_H_
128 struct pread_args *uap;
134 if (uap->nbyte > INT_MAX)
136 aiov.iov_base = uap->buf;
137 aiov.iov_len = uap->nbyte;
138 auio.uio_iov = &aiov;
140 auio.uio_resid = uap->nbyte;
141 auio.uio_segflg = UIO_USERSPACE;
142 error = kern_preadv(td, uap->fd, &auio, uap->offset);
147 freebsd6_pread(td, uap)
149 struct freebsd6_pread_args *uap;
151 struct pread_args oargs;
154 oargs.buf = uap->buf;
155 oargs.nbyte = uap->nbyte;
156 oargs.offset = uap->offset;
157 return (pread(td, &oargs));
161 * Scatter read system call.
163 #ifndef _SYS_SYSPROTO_H_
171 readv(struct thread *td, struct readv_args *uap)
176 error = copyinuio(uap->iovp, uap->iovcnt, &auio);
179 error = kern_readv(td, uap->fd, auio);
185 kern_readv(struct thread *td, int fd, struct uio *auio)
190 error = fget_read(td, fd, &fp);
193 error = dofileread(td, fd, fp, auio, (off_t)-1, 0);
199 * Scatter positioned read system call.
201 #ifndef _SYS_SYSPROTO_H_
210 preadv(struct thread *td, struct preadv_args *uap)
215 error = copyinuio(uap->iovp, uap->iovcnt, &auio);
218 error = kern_preadv(td, uap->fd, auio, uap->offset);
224 kern_preadv(td, fd, auio, offset)
233 error = fget_read(td, fd, &fp);
236 if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE))
238 else if (offset < 0 && fp->f_vnode->v_type != VCHR)
241 error = dofileread(td, fd, fp, auio, offset, FOF_OFFSET);
247 * Common code for readv and preadv that reads data in
248 * from a file using the passed in uio, offset, and flags.
251 dofileread(td, fd, fp, auio, offset, flags)
262 struct uio *ktruio = NULL;
265 /* Finish zero length reads right here */
266 if (auio->uio_resid == 0) {
267 td->td_retval[0] = 0;
270 auio->uio_rw = UIO_READ;
271 auio->uio_offset = offset;
274 if (KTRPOINT(td, KTR_GENIO))
275 ktruio = cloneuio(auio);
277 cnt = auio->uio_resid;
278 if ((error = fo_read(fp, auio, td->td_ucred, flags, td))) {
279 if (auio->uio_resid != cnt && (error == ERESTART ||
280 error == EINTR || error == EWOULDBLOCK))
283 cnt -= auio->uio_resid;
285 if (ktruio != NULL) {
286 ktruio->uio_resid = cnt;
287 ktrgenio(fd, UIO_READ, ktruio, error);
290 td->td_retval[0] = cnt;
294 #ifndef _SYS_SYSPROTO_H_
304 struct write_args *uap;
310 if (uap->nbyte > INT_MAX)
312 aiov.iov_base = (void *)(uintptr_t)uap->buf;
313 aiov.iov_len = uap->nbyte;
314 auio.uio_iov = &aiov;
316 auio.uio_resid = uap->nbyte;
317 auio.uio_segflg = UIO_USERSPACE;
318 error = kern_writev(td, uap->fd, &auio);
323 * Positioned write system call.
325 #ifndef _SYS_SYSPROTO_H_
337 struct pwrite_args *uap;
343 if (uap->nbyte > INT_MAX)
345 aiov.iov_base = (void *)(uintptr_t)uap->buf;
346 aiov.iov_len = uap->nbyte;
347 auio.uio_iov = &aiov;
349 auio.uio_resid = uap->nbyte;
350 auio.uio_segflg = UIO_USERSPACE;
351 error = kern_pwritev(td, uap->fd, &auio, uap->offset);
356 freebsd6_pwrite(td, uap)
358 struct freebsd6_pwrite_args *uap;
360 struct pwrite_args oargs;
363 oargs.buf = uap->buf;
364 oargs.nbyte = uap->nbyte;
365 oargs.offset = uap->offset;
366 return (pwrite(td, &oargs));
370 * Gather write system call.
372 #ifndef _SYS_SYSPROTO_H_
380 writev(struct thread *td, struct writev_args *uap)
385 error = copyinuio(uap->iovp, uap->iovcnt, &auio);
388 error = kern_writev(td, uap->fd, auio);
394 kern_writev(struct thread *td, int fd, struct uio *auio)
399 error = fget_write(td, fd, &fp);
402 error = dofilewrite(td, fd, fp, auio, (off_t)-1, 0);
408 * Gather positioned write system call.
410 #ifndef _SYS_SYSPROTO_H_
411 struct pwritev_args {
419 pwritev(struct thread *td, struct pwritev_args *uap)
424 error = copyinuio(uap->iovp, uap->iovcnt, &auio);
427 error = kern_pwritev(td, uap->fd, auio, uap->offset);
433 kern_pwritev(td, fd, auio, offset)
442 error = fget_write(td, fd, &fp);
445 if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE))
447 else if (offset < 0 && fp->f_vnode->v_type != VCHR)
450 error = dofilewrite(td, fd, fp, auio, offset, FOF_OFFSET);
456 * Common code for writev and pwritev that writes data to
457 * a file using the passed in uio, offset, and flags.
460 dofilewrite(td, fd, fp, auio, offset, flags)
471 struct uio *ktruio = NULL;
474 auio->uio_rw = UIO_WRITE;
476 auio->uio_offset = offset;
478 if (KTRPOINT(td, KTR_GENIO))
479 ktruio = cloneuio(auio);
481 cnt = auio->uio_resid;
482 if (fp->f_type == DTYPE_VNODE)
484 if ((error = fo_write(fp, auio, td->td_ucred, flags, td))) {
485 if (auio->uio_resid != cnt && (error == ERESTART ||
486 error == EINTR || error == EWOULDBLOCK))
488 /* Socket layer is responsible for issuing SIGPIPE. */
489 if (fp->f_type != DTYPE_SOCKET && error == EPIPE) {
490 PROC_LOCK(td->td_proc);
491 psignal(td->td_proc, SIGPIPE);
492 PROC_UNLOCK(td->td_proc);
495 cnt -= auio->uio_resid;
497 if (ktruio != NULL) {
498 ktruio->uio_resid = cnt;
499 ktrgenio(fd, UIO_WRITE, ktruio, error);
502 td->td_retval[0] = cnt;
506 #ifndef _SYS_SYSPROTO_H_
515 ioctl(struct thread *td, struct ioctl_args *uap)
522 if (uap->com > 0xffffffff) {
524 "WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
525 td->td_proc->p_pid, td->td_proc->p_comm, uap->com);
526 uap->com &= 0xffffffff;
531 * Interpret high order word to find amount of data to be
532 * copied to/from the user's address space.
534 size = IOCPARM_LEN(com);
535 if ((size > IOCPARM_MAX) ||
536 ((com & (IOC_VOID | IOC_IN | IOC_OUT)) == 0) ||
537 #if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
538 ((com & IOC_OUT) && size == 0) ||
540 ((com & (IOC_IN | IOC_OUT)) && size == 0) ||
542 ((com & IOC_VOID) && size > 0 && size != sizeof(int)))
546 if (!(com & IOC_VOID))
547 data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
549 /* Integer argument. */
550 arg = (intptr_t)uap->data;
555 data = (void *)&uap->data;
557 error = copyin(uap->data, data, (u_int)size);
560 free(data, M_IOCTLOPS);
563 } else if (com & IOC_OUT) {
565 * Zero the buffer so the user always
566 * gets back something deterministic.
571 error = kern_ioctl(td, uap->fd, com, data);
573 if (error == 0 && (com & IOC_OUT))
574 error = copyout(data, uap->data, (u_int)size);
577 free(data, M_IOCTLOPS);
582 kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data)
585 struct filedesc *fdp;
589 if ((error = fget(td, fd, &fp)) != 0)
591 if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
595 fdp = td->td_proc->p_fd;
599 fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
600 FILEDESC_XUNLOCK(fdp);
604 fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
605 FILEDESC_XUNLOCK(fdp);
609 if ((tmp = *(int *)data))
610 fp->f_flag |= FNONBLOCK;
612 fp->f_flag &= ~FNONBLOCK;
618 if ((tmp = *(int *)data))
619 fp->f_flag |= FASYNC;
621 fp->f_flag &= ~FASYNC;
627 error = fo_ioctl(fp, com, data, td->td_ucred, td);
634 * sellock and selwait are initialized in selectinit() via SYSINIT.
638 u_int nselcoll; /* Select collisions since boot */
639 SYSCTL_UINT(_kern, OID_AUTO, nselcoll, CTLFLAG_RD, &nselcoll, 0, "");
642 poll_no_poll(int events)
645 * Return true for read/write. If the user asked for something
646 * special, return POLLNVAL, so that clients have a way of
647 * determining reliably whether or not the extended
648 * functionality is present without hard-coding knowledge
649 * of specific filesystem implementations.
651 if (events & ~POLLSTANDARD)
654 return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
657 #ifndef _SYS_SYSPROTO_H_
660 fd_set *in, *ou, *ex;
666 register struct thread *td;
667 register struct select_args *uap;
669 struct timeval tv, *tvp;
672 if (uap->tv != NULL) {
673 error = copyin(uap->tv, &tv, sizeof(tv));
680 return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp));
684 kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
685 fd_set *fd_ex, struct timeval *tvp)
687 struct filedesc *fdp;
689 * The magic 2048 here is chosen to be just enough for FD_SETSIZE
690 * infds with the new FD_SETSIZE of 1024, and more than enough for
691 * FD_SETSIZE infds, outfds and exceptfds with the old FD_SETSIZE
694 fd_mask s_selbits[howmany(2048, NFDBITS)];
695 fd_mask *ibits[3], *obits[3], *selbits, *sbp;
696 struct timeval atv, rtv, ttv;
698 u_int ncoll, nbufbytes, ncpbytes, nfdbits;
702 fdp = td->td_proc->p_fd;
705 if (nd > td->td_proc->p_fd->fd_nfiles)
706 nd = td->td_proc->p_fd->fd_nfiles; /* forgiving; slightly wrong */
707 FILEDESC_SUNLOCK(fdp);
710 * Allocate just enough bits for the non-null fd_sets. Use the
711 * preallocated auto buffer if possible.
713 nfdbits = roundup(nd, NFDBITS);
714 ncpbytes = nfdbits / NBBY;
717 nbufbytes += 2 * ncpbytes;
719 nbufbytes += 2 * ncpbytes;
721 nbufbytes += 2 * ncpbytes;
722 if (nbufbytes <= sizeof s_selbits)
723 selbits = &s_selbits[0];
725 selbits = malloc(nbufbytes, M_SELECT, M_WAITOK);
728 * Assign pointers into the bit buffers and fetch the input bits.
729 * Put the output buffers together so that they can be bzeroed
733 #define getbits(name, x) \
738 ibits[x] = sbp + nbufbytes / 2 / sizeof *sbp; \
740 sbp += ncpbytes / sizeof *sbp; \
741 error = copyin(name, ibits[x], ncpbytes); \
743 goto done_nosellock; \
751 bzero(selbits, nbufbytes / 2);
755 if (itimerfix(&atv)) {
759 getmicrouptime(&rtv);
760 timevaladd(&atv, &rtv);
766 TAILQ_INIT(&td->td_selq);
771 td->td_flags |= TDF_SELECT;
773 mtx_unlock(&sellock);
775 error = selscan(td, ibits, obits, nd);
777 if (error || td->td_retval[0])
779 if (atv.tv_sec || atv.tv_usec) {
780 getmicrouptime(&rtv);
781 if (timevalcmp(&rtv, &atv, >=))
784 timevalsub(&ttv, &rtv);
785 timo = ttv.tv_sec > 24 * 60 * 60 ?
786 24 * 60 * 60 * hz : tvtohz(&ttv);
790 * An event of interest may occur while we do not hold
791 * sellock, so check TDF_SELECT and the number of
792 * collisions and rescan the file descriptors if
796 if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) {
803 error = cv_timedwait_sig(&selwait, &sellock, timo);
805 error = cv_wait_sig(&selwait, &sellock);
811 clear_selinfo_list(td);
813 td->td_flags &= ~TDF_SELECT;
815 mtx_unlock(&sellock);
818 /* select is not restarted after signals... */
819 if (error == ERESTART)
821 if (error == EWOULDBLOCK)
823 #define putbits(name, x) \
824 if (name && (error2 = copyout(obits[x], name, ncpbytes))) \
834 if (selbits != &s_selbits[0])
835 free(selbits, M_SELECT);
841 selscan(td, ibits, obits, nfd)
843 fd_mask **ibits, **obits;
850 /* Note: backend also returns POLLHUP/POLLERR if appropriate. */
851 static int flag[3] = { POLLRDNORM, POLLWRNORM, POLLRDBAND };
852 struct filedesc *fdp = td->td_proc->p_fd;
855 for (msk = 0; msk < 3; msk++) {
856 if (ibits[msk] == NULL)
858 for (i = 0; i < nfd; i += NFDBITS) {
859 bits = ibits[msk][i/NFDBITS];
860 /* ffs(int mask) not portable, fd_mask is long */
861 for (fd = i; bits && fd < nfd; fd++, bits >>= 1) {
864 if ((fp = fget_locked(fdp, fd)) == NULL) {
865 FILEDESC_SUNLOCK(fdp);
868 if (fo_poll(fp, flag[msk], td->td_ucred,
870 obits[msk][(fd)/NFDBITS] |=
871 ((fd_mask)1 << ((fd) % NFDBITS));
877 FILEDESC_SUNLOCK(fdp);
878 td->td_retval[0] = n;
882 #ifndef _SYS_SYSPROTO_H_
892 struct poll_args *uap;
895 struct pollfd smallbits[32];
896 struct timeval atv, rtv, ttv;
904 * This is kinda bogus. We have fd limits, but that is not
905 * really related to the size of the pollfd array. Make sure
906 * we let the process use at least FD_SETSIZE entries and at
907 * least enough for the current limits. We want to be reasonably
908 * safe, but not overly restrictive.
910 PROC_LOCK(td->td_proc);
911 if ((nfds > lim_cur(td->td_proc, RLIMIT_NOFILE)) &&
912 (nfds > FD_SETSIZE)) {
913 PROC_UNLOCK(td->td_proc);
917 PROC_UNLOCK(td->td_proc);
918 ni = nfds * sizeof(struct pollfd);
919 if (ni > sizeof(smallbits))
920 bits = malloc(ni, M_TEMP, M_WAITOK);
923 error = copyin(uap->fds, bits, ni);
926 if (uap->timeout != INFTIM) {
927 atv.tv_sec = uap->timeout / 1000;
928 atv.tv_usec = (uap->timeout % 1000) * 1000;
929 if (itimerfix(&atv)) {
933 getmicrouptime(&rtv);
934 timevaladd(&atv, &rtv);
940 TAILQ_INIT(&td->td_selq);
945 td->td_flags |= TDF_SELECT;
947 mtx_unlock(&sellock);
949 error = pollscan(td, bits, nfds);
951 if (error || td->td_retval[0])
953 if (atv.tv_sec || atv.tv_usec) {
954 getmicrouptime(&rtv);
955 if (timevalcmp(&rtv, &atv, >=))
958 timevalsub(&ttv, &rtv);
959 timo = ttv.tv_sec > 24 * 60 * 60 ?
960 24 * 60 * 60 * hz : tvtohz(&ttv);
963 * An event of interest may occur while we do not hold
964 * sellock, so check TDF_SELECT and the number of collisions
965 * and rescan the file descriptors if necessary.
968 if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) {
975 error = cv_timedwait_sig(&selwait, &sellock, timo);
977 error = cv_wait_sig(&selwait, &sellock);
983 clear_selinfo_list(td);
985 td->td_flags &= ~TDF_SELECT;
987 mtx_unlock(&sellock);
990 /* poll is not restarted after signals... */
991 if (error == ERESTART)
993 if (error == EWOULDBLOCK)
996 error = pollout(bits, uap->fds, nfds);
1001 if (ni > sizeof(smallbits))
1008 pollout(fds, ufds, nfd)
1010 struct pollfd *ufds;
1016 for (i = 0; i < nfd; i++) {
1017 error = copyout(&fds->revents, &ufds->revents,
1018 sizeof(ufds->revents));
1028 pollscan(td, fds, nfd)
1033 register struct filedesc *fdp = td->td_proc->p_fd;
1038 FILEDESC_SLOCK(fdp);
1039 for (i = 0; i < nfd; i++, fds++) {
1040 if (fds->fd >= fdp->fd_nfiles) {
1041 fds->revents = POLLNVAL;
1043 } else if (fds->fd < 0) {
1046 fp = fdp->fd_ofiles[fds->fd];
1048 fds->revents = POLLNVAL;
1052 * Note: backend also returns POLLHUP and
1053 * POLLERR if appropriate.
1055 fds->revents = fo_poll(fp, fds->events,
1057 if (fds->revents != 0)
1062 FILEDESC_SUNLOCK(fdp);
1063 td->td_retval[0] = n;
1068 * OpenBSD poll system call.
1070 * XXX this isn't quite a true representation.. OpenBSD uses select ops.
1072 #ifndef _SYS_SYSPROTO_H_
1073 struct openbsd_poll_args {
1080 openbsd_poll(td, uap)
1081 register struct thread *td;
1082 register struct openbsd_poll_args *uap;
1084 return (poll(td, (struct poll_args *)uap));
1088 * Remove the references to the thread from all of the objects we were
1091 * This code assumes that the underlying owner of the selinfo structure will
1092 * hold sellock before it changes it, and that it will unlink itself from our
1093 * list if it goes away.
1096 clear_selinfo_list(td)
1101 mtx_assert(&sellock, MA_OWNED);
1102 TAILQ_FOREACH(si, &td->td_selq, si_thrlist)
1103 si->si_thread = NULL;
1104 TAILQ_INIT(&td->td_selq);
1108 * Record a select request.
1111 selrecord(selector, sip)
1112 struct thread *selector;
1113 struct selinfo *sip;
1118 * If the selinfo's thread pointer is NULL then take ownership of it.
1120 * If the thread pointer is not NULL and it points to another
1121 * thread, then we have a collision.
1123 * If the thread pointer is not NULL and points back to us then leave
1124 * it alone as we've already added pointed it at us and added it to
1127 if (sip->si_thread == NULL) {
1128 sip->si_thread = selector;
1129 TAILQ_INSERT_TAIL(&selector->td_selq, sip, si_thrlist);
1130 } else if (sip->si_thread != selector) {
1131 sip->si_flags |= SI_COLL;
1134 mtx_unlock(&sellock);
1137 /* Wake up a selecting thread. */
1140 struct selinfo *sip;
1142 doselwakeup(sip, -1);
1145 /* Wake up a selecting thread, and set its priority. */
1147 selwakeuppri(sip, pri)
1148 struct selinfo *sip;
1151 doselwakeup(sip, pri);
1155 * Do a wakeup when a selectable event occurs.
1158 doselwakeup(sip, pri)
1159 struct selinfo *sip;
1165 td = sip->si_thread;
1166 if ((sip->si_flags & SI_COLL) != 0) {
1168 sip->si_flags &= ~SI_COLL;
1169 cv_broadcastpri(&selwait, pri);
1172 mtx_unlock(&sellock);
1175 TAILQ_REMOVE(&td->td_selq, sip, si_thrlist);
1176 sip->si_thread = NULL;
1178 td->td_flags &= ~TDF_SELECT;
1180 sleepq_remove(td, &selwait);
1181 mtx_unlock(&sellock);
1184 static void selectinit(void *);
1185 SYSINIT(select, SI_SUB_LOCK, SI_ORDER_FIRST, selectinit, NULL)
1192 cv_init(&selwait, "select");
1193 mtx_init(&sellock, "sellck", NULL, MTX_DEF);