37 #include <sys/cdefs.h>
40 #include "opt_capsicum.h"
41 #include "opt_compat.h"
42 #include "opt_ktrace.h"
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/sysproto.h>
47 #include <sys/capability.h>
48 #include <sys/filedesc.h>
49 #include <sys/filio.h>
50 #include <sys/fcntl.h>
53 #include <sys/signalvar.h>
54 #include <sys/socketvar.h>
56 #include <sys/kernel.h>
58 #include <sys/limits.h>
59 #include <sys/malloc.h>
61 #include <sys/resourcevar.h>
62 #include <sys/selinfo.h>
63 #include <sys/sleepqueue.h>
64 #include <sys/syscallsubr.h>
65 #include <sys/sysctl.h>
66 #include <sys/sysent.h>
67 #include <sys/vnode.h>
70 #include <sys/condvar.h>
72 #include <sys/ktrace.h>
75 #include <security/audit/audit.h>
88 #define SYS_IOCTL_SMALL_SIZE 128
89 #define SYS_IOCTL_SMALL_ALIGN 8
103 CTASSERT(
sizeof(register_t) >=
sizeof(
size_t));
105 static MALLOC_DEFINE(M_IOCTLOPS,
"ioctlops",
"ioctl data buffer");
109 static int pollout(
struct thread *,
struct pollfd *,
struct pollfd *,
111 static int pollscan(
struct thread *,
struct pollfd *, u_int);
113 static int selscan(
struct thread *, fd_mask **, fd_mask **,
int);
114 static int selrescan(
struct thread *, fd_mask **, fd_mask **);
115 static void selfdalloc(
struct thread *,
void *);
117 static int dofileread(
struct thread *,
int,
struct file *,
struct uio *,
119 static int dofilewrite(
struct thread *,
int,
struct file *,
struct uio *,
123 static int seltdwait(
struct thread *,
int);
134 struct selfd *st_free1;
135 struct selfd *st_free2;
141 #define SELTD_PENDING 0x0001
142 #define SELTD_RESCAN 0x0002
149 STAILQ_ENTRY(
selfd) sf_link;
150 TAILQ_ENTRY(
selfd) sf_threads;
151 struct selinfo *sf_si;
160 #ifndef _SYS_SYSPROTO_H_
176 if (uap->
nbyte > IOSIZE_MAX)
178 aiov.iov_base = uap->
buf;
179 aiov.iov_len = uap->
nbyte;
180 auio.uio_iov = &aiov;
182 auio.uio_resid = uap->
nbyte;
183 auio.uio_segflg = UIO_USERSPACE;
191 #ifndef _SYS_SYSPROTO_H_
209 if (uap->
nbyte > IOSIZE_MAX)
211 aiov.iov_base = uap->
buf;
212 aiov.iov_len = uap->
nbyte;
213 auio.uio_iov = &aiov;
215 auio.uio_resid = uap->
nbyte;
216 auio.uio_segflg = UIO_USERSPACE;
224 struct freebsd6_pread_args *uap;
229 oargs.
buf = uap->buf;
230 oargs.
nbyte = uap->nbyte;
231 oargs.
offset = uap->offset;
238 #ifndef _SYS_SYSPROTO_H_
265 error =
fget_read(td, fd, CAP_READ | CAP_SEEK, &fp);
268 error =
dofileread(td, fd, fp, auio, (off_t)-1, 0);
276 #ifndef _SYS_SYSPROTO_H_
308 error =
fget_read(td, fd, CAP_READ, &fp);
311 if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE))
313 else if (offset < 0 && fp->f_vnode->v_type != VCHR)
316 error =
dofileread(td, fd, fp, auio, offset, FOF_OFFSET);
337 struct uio *ktruio = NULL;
341 if (auio->uio_resid == 0) {
342 td->td_retval[0] = 0;
345 auio->uio_rw = UIO_READ;
346 auio->uio_offset = offset;
349 if (KTRPOINT(td, KTR_GENIO))
352 cnt = auio->uio_resid;
353 if ((error = fo_read(fp, auio, td->td_ucred, flags, td))) {
354 if (auio->uio_resid != cnt && (error == ERESTART ||
355 error == EINTR || error == EWOULDBLOCK))
358 cnt -= auio->uio_resid;
360 if (ktruio != NULL) {
361 ktruio->uio_resid = cnt;
362 ktrgenio(fd, UIO_READ, ktruio, error);
365 td->td_retval[0] = cnt;
369 #ifndef _SYS_SYSPROTO_H_
385 if (uap->
nbyte > IOSIZE_MAX)
387 aiov.iov_base = (
void *)(uintptr_t)uap->
buf;
388 aiov.iov_len = uap->
nbyte;
389 auio.uio_iov = &aiov;
391 auio.uio_resid = uap->
nbyte;
392 auio.uio_segflg = UIO_USERSPACE;
400 #ifndef _SYS_SYSPROTO_H_
418 if (uap->
nbyte > IOSIZE_MAX)
420 aiov.iov_base = (
void *)(uintptr_t)uap->
buf;
421 aiov.iov_len = uap->
nbyte;
422 auio.uio_iov = &aiov;
424 auio.uio_resid = uap->
nbyte;
425 auio.uio_segflg = UIO_USERSPACE;
433 struct freebsd6_pwrite_args *uap;
438 oargs.
buf = uap->buf;
439 oargs.
nbyte = uap->nbyte;
440 oargs.
offset = uap->offset;
447 #ifndef _SYS_SYSPROTO_H_
474 error =
fget_write(td, fd, CAP_WRITE | CAP_SEEK, &fp);
477 error =
dofilewrite(td, fd, fp, auio, (off_t)-1, 0);
485 #ifndef _SYS_SYSPROTO_H_
520 if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE))
522 else if (offset < 0 && fp->f_vnode->v_type != VCHR)
525 error =
dofilewrite(td, fd, fp, auio, offset, FOF_OFFSET);
546 struct uio *ktruio = NULL;
549 auio->uio_rw = UIO_WRITE;
551 auio->uio_offset = offset;
553 if (KTRPOINT(td, KTR_GENIO))
556 cnt = auio->uio_resid;
557 if (fp->f_type == DTYPE_VNODE &&
558 (fp->f_vnread_flags & FDEVFS_VNODE) == 0)
560 if ((error = fo_write(fp, auio, td->td_ucred, flags, td))) {
561 if (auio->uio_resid != cnt && (error == ERESTART ||
562 error == EINTR || error == EWOULDBLOCK))
565 if (fp->f_type != DTYPE_SOCKET && error == EPIPE) {
566 PROC_LOCK(td->td_proc);
568 PROC_UNLOCK(td->td_proc);
571 cnt -= auio->uio_resid;
573 if (ktruio != NULL) {
574 ktruio->uio_resid = cnt;
575 ktrgenio(fd, UIO_WRITE, ktruio, error);
578 td->td_retval[0] = cnt;
600 error =
fget(td, fd, CAP_FTRUNCATE, &fp);
603 AUDIT_ARG_FILE(td->td_proc, fp);
604 if (!(fp->f_flag & FWRITE)) {
608 error = fo_truncate(fp, length, td->td_ucred, td);
613 #ifndef _SYS_SYSPROTO_H_
629 #if defined(COMPAT_43)
630 #ifndef _SYS_SYSPROTO_H_
631 struct oftruncate_args {
639 struct oftruncate_args *uap;
646 #ifndef _SYS_SYSPROTO_H_
663 if (uap->
com > 0xffffffff) {
665 "WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
666 td->td_proc->p_pid, td->td_name, uap->
com);
667 uap->
com &= 0xffffffff;
675 size = IOCPARM_LEN(com);
676 if ((size > IOCPARM_MAX) ||
677 ((com & (IOC_VOID | IOC_IN | IOC_OUT)) == 0) ||
678 #
if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
679 ((com & IOC_OUT) && size == 0) ||
681 ((com & (IOC_IN | IOC_OUT)) && size == 0) ||
683 ((com & IOC_VOID) && size > 0 && size !=
sizeof(
int)))
687 if (com & IOC_VOID) {
689 arg = (intptr_t)uap->
data;
694 data =
malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
699 data = (
void *)&uap->
data;
701 error = copyin(uap->
data, data, (u_int)size);
704 }
else if (com & IOC_OUT) {
714 if (error == 0 && (com & IOC_OUT))
715 error = copyout(data, uap->
data, (u_int)size);
719 free(data, M_IOCTLOPS);
727 struct filedesc *fdp;
733 if ((error =
fget(td, fd, CAP_IOCTL, &fp)) != 0)
735 if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
739 fdp = td->td_proc->p_fd;
743 fdp->fd_ofileflags[
fd] &= ~UF_EXCLOSE;
744 FILEDESC_XUNLOCK(fdp);
748 fdp->fd_ofileflags[
fd] |= UF_EXCLOSE;
749 FILEDESC_XUNLOCK(fdp);
752 if ((tmp = *(
int *)data))
753 atomic_set_int(&fp->f_flag, FNONBLOCK);
755 atomic_clear_int(&fp->f_flag, FNONBLOCK);
759 if ((tmp = *(
int *)data))
760 atomic_set_int(&fp->f_flag, FASYNC);
762 atomic_clear_int(&fp->f_flag, FASYNC);
767 error = fo_ioctl(fp, com, data, td->td_ucred, td);
783 if (events & ~POLLSTANDARD)
786 return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
793 struct timeval tv, *tvp;
797 if (uap->ts != NULL) {
798 error = copyin(uap->ts, &ts,
sizeof(ts));
801 TIMESPEC_TO_TIMEVAL(&tv, &ts);
805 if (uap->sm != NULL) {
806 error = copyin(uap->sm, &set,
sizeof(set));
812 return (
kern_pselect(td, uap->nd, uap->in, uap->ou, uap->ex, tvp,
817 kern_pselect(
struct thread *td,
int nd, fd_set *in, fd_set *ou, fd_set *ex,
818 struct timeval *tvp, sigset_t *uset,
int abi_nfdbits)
824 &td->td_oldsigmask, 0);
827 td->td_pflags |= TDP_OLDMASK;
834 td->td_flags |= TDF_ASTPENDING;
837 error =
kern_select(td, nd, in, ou, ex, tvp, abi_nfdbits);
841 #ifndef _SYS_SYSPROTO_H_
851 struct timeval tv, *tvp;
854 if (uap->
tv != NULL) {
855 error = copyin(uap->
tv, &tv,
sizeof(tv));
882 if (nd >= ndu || fd_in == NULL)
887 for (i = nd; i < ndu; i++) {
889 #if BYTE_ORDER == LITTLE_ENDIAN
890 addr = (
char *)fd_in + b;
892 addr = (
char *)fd_in;
893 if (abi_nfdbits == NFDBITS) {
894 addr += rounddown(b,
sizeof(fd_mask)) +
895 sizeof(fd_mask) - 1 - b %
sizeof(fd_mask);
897 addr += rounddown(b,
sizeof(uint32_t)) +
898 sizeof(uint32_t) - 1 - b %
sizeof(uint32_t);
908 if ((bits & (1 << (i % NBBY))) != 0)
915 kern_select(
struct thread *td,
int nd, fd_set *fd_in, fd_set *fd_ou,
916 fd_set *fd_ex,
struct timeval *tvp,
int abi_nfdbits)
918 struct filedesc *fdp;
925 fd_mask s_selbits[howmany(2048, NFDBITS)];
926 fd_mask *ibits[3], *obits[3], *selbits, *sbp;
927 struct timeval atv, rtv, ttv;
928 int error, lf, ndu, timo;
929 u_int nbufbytes, ncpbytes, ncpubytes, nfdbits;
933 fdp = td->td_proc->p_fd;
935 lf = fdp->fd_lastfile;
953 nfdbits = roundup(nd, NFDBITS);
954 ncpbytes = nfdbits / NBBY;
955 ncpubytes = roundup(nd, abi_nfdbits) / NBBY;
958 nbufbytes += 2 * ncpbytes;
960 nbufbytes += 2 * ncpbytes;
962 nbufbytes += 2 * ncpbytes;
963 if (nbufbytes <=
sizeof s_selbits)
964 selbits = &s_selbits[0];
966 selbits =
malloc(nbufbytes, M_SELECT, M_WAITOK);
974 #define getbits(name, x) \
976 if (name == NULL) { \
980 ibits[x] = sbp + nbufbytes / 2 / sizeof *sbp; \
982 sbp += ncpbytes / sizeof *sbp; \
983 error = copyin(name, ibits[x], ncpubytes); \
986 bzero((char *)ibits[x] + ncpubytes, \
987 ncpbytes - ncpubytes); \
995 #if BYTE_ORDER == BIG_ENDIAN && defined(__LP64__)
1001 #define swizzle_fdset(bits) \
1002 if (abi_nfdbits != NFDBITS && bits != NULL) { \
1004 for (i = 0; i < ncpbytes / sizeof *sbp; i++) \
1005 bits[i] = (bits[i] >> 32) | (bits[i] << 32); \
1008 #define swizzle_fdset(bits)
1017 bzero(selbits, nbufbytes / 2);
1035 error =
selscan(td, ibits, obits, nd);
1036 if (error || td->td_retval[0] != 0)
1038 if (atv.tv_sec || atv.tv_usec) {
1040 if (timevalcmp(&rtv, &atv, >=))
1044 timo = ttv.tv_sec > 24 * 60 * 60 ?
1051 if (error || td->td_retval[0] != 0)
1058 if (error == ERESTART)
1060 if (error == EWOULDBLOCK)
1067 #undef swizzle_fdset
1069 #define putbits(name, x) \
1070 if (name && (error2 = copyout(obits[x], name, ncpubytes))) \
1080 if (selbits != &s_selbits[0])
1081 free(selbits, M_SELECT);
1092 POLLRDNORM | POLLHUP | POLLERR,
1093 POLLWRNORM | POLLHUP | POLLERR,
1094 POLLRDBAND | POLLERR
1108 for (msk = 0; msk < 3; msk++) {
1109 if (ibits[msk] == NULL)
1111 if ((ibits[msk][idx] & bit) == 0)
1113 flags |= select_flags[msk];
1123 selsetbits(fd_mask **ibits, fd_mask **obits,
int idx, fd_mask bit,
int events)
1129 for (msk = 0; msk < 3; msk++) {
1130 if ((events & select_flags[msk]) == 0)
1132 if (ibits[msk] == NULL)
1134 if ((ibits[msk][idx] & bit) == 0)
1142 if ((obits[msk][idx] & bit) != 0)
1144 obits[msk][idx] |= bit;
1156 struct file *fp_fromcap;
1167 error =
cap_funwrap(fp, CAP_POLL_EVENT, &fp_fromcap);
1169 fdrop(fp, curthread);
1172 if (fp != fp_fromcap) {
1174 fdrop(fp, curthread);
1187 selrescan(
struct thread *td, fd_mask **ibits, fd_mask **obits)
1189 struct filedesc *fdp;
1199 fdp = td->td_proc->p_fd;
1202 STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
1203 fd = (int)(uintptr_t)sfp->sf_cookie;
1213 bit = (fd_mask)1 << (fd % NFDBITS);
1214 ev = fo_poll(fp,
selflags(ibits, idx, bit), td->td_ucred, td);
1220 td->td_retval[0] = n;
1231 fd_mask **ibits, **obits;
1234 struct filedesc *fdp;
1237 int ev, flags, end,
fd;
1241 fdp = td->td_proc->p_fd;
1243 for (idx = 0, fd = 0; fd < nfd; idx++) {
1244 end = imin(fd + NFDBITS, nfd);
1245 for (bit = 1; fd < end; bit <<= 1, fd++) {
1254 ev = fo_poll(fp, flags, td->td_ucred, td);
1261 td->td_retval[0] = n;
1265 #ifndef _SYS_SYSPROTO_H_
1277 struct pollfd *bits;
1278 struct pollfd smallbits[32];
1279 struct timeval atv, rtv, ttv;
1287 ni = nfds *
sizeof(
struct pollfd);
1288 if (ni >
sizeof(smallbits))
1289 bits =
malloc(ni, M_TEMP, M_WAITOK);
1292 error = copyin(uap->
fds, bits, ni);
1296 atv.tv_sec = uap->
timeout / 1000;
1297 atv.tv_usec = (uap->
timeout % 1000) * 1000;
1313 if (error || td->td_retval[0] != 0)
1315 if (atv.tv_sec || atv.tv_usec) {
1317 if (timevalcmp(&rtv, &atv, >=))
1321 timo = ttv.tv_sec > 24 * 60 * 60 ?
1328 if (error || td->td_retval[0] != 0)
1335 if (error == ERESTART)
1337 if (error == EWOULDBLOCK)
1345 if (ni >
sizeof(smallbits))
1357 struct filedesc *fdp;
1363 fdp = td->td_proc->p_fd;
1365 FILEDESC_SLOCK(fdp);
1366 STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
1367 fd = (
struct pollfd *)sfp->sf_cookie;
1373 fp = fdp->fd_ofiles[fd->fd];
1380 fd->revents = POLLNVAL;
1389 fd->revents = fo_poll(fp, fd->events, td->td_ucred, td);
1390 if (fd->revents != 0)
1393 FILEDESC_SUNLOCK(fdp);
1395 td->td_retval[0] = n;
1404 struct pollfd *ufds;
1411 for (i = 0; i < nfd; i++) {
1412 error = copyout(&fds->revents, &ufds->revents,
1413 sizeof(ufds->revents));
1416 if (fds->revents != 0)
1421 td->td_retval[0] = n;
1431 struct filedesc *fdp = td->td_proc->p_fd;
1436 FILEDESC_SLOCK(fdp);
1437 for (i = 0; i < nfd; i++, fds++) {
1438 if (fds->fd >= fdp->fd_nfiles) {
1439 fds->revents = POLLNVAL;
1441 }
else if (fds->fd < 0) {
1444 fp = fdp->fd_ofiles[fds->fd];
1451 fds->revents = POLLNVAL;
1459 fds->revents = fo_poll(fp, fds->events,
1465 if ((fds->revents & POLLHUP) != 0)
1466 fds->revents &= ~POLLOUT;
1468 if (fds->revents != 0)
1473 FILEDESC_SUNLOCK(fdp);
1474 td->td_retval[0] = n;
1483 #ifndef _SYS_SYSPROTO_H_
1492 register struct thread *td;
1505 selsocket(
struct socket *so,
int events,
struct timeval *tvp,
struct thread *td)
1507 struct timeval atv, rtv, ttv;
1528 error =
sopoll(so, events, NULL, td);
1532 if (atv.tv_sec || atv.tv_usec) {
1534 if (timevalcmp(&rtv, &atv, >=)) {
1536 return (EWOULDBLOCK);
1540 timo = ttv.tv_sec > 24 * 60 * 60 ?
1549 if (error == ERESTART)
1564 if (stp->st_free1 == NULL)
1565 stp->st_free1 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO);
1566 stp->st_free1->sf_td = stp;
1567 stp->st_free1->sf_cookie = cookie;
1568 if (stp->st_free2 == NULL)
1569 stp->st_free2 = uma_zalloc(selfd_zone, M_WAITOK|M_ZERO);
1570 stp->st_free2->sf_td = stp;
1571 stp->st_free2->sf_cookie = cookie;
1577 STAILQ_REMOVE(&stp->st_selq, sfp,
selfd, sf_link);
1578 mtx_lock(sfp->sf_mtx);
1580 TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads);
1581 mtx_unlock(sfp->sf_mtx);
1582 uma_zfree(selfd_zone, sfp);
1588 struct selinfo *sip;
1607 struct thread *selector;
1608 struct selinfo *sip;
1614 stp = selector->td_sel;
1624 if ((sfp = stp->st_free1) != NULL)
1625 stp->st_free1 = NULL;
1626 else if ((sfp = stp->st_free2) != NULL)
1627 stp->st_free2 = NULL;
1629 panic(
"selrecord: No free selfd on selq");
1638 STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link);
1643 if (sip->si_mtx == NULL) {
1645 TAILQ_INIT(&sip->si_tdlist);
1650 TAILQ_INSERT_TAIL(&sip->si_tdlist, sfp, sf_threads);
1651 mtx_unlock(sip->si_mtx);
1657 struct selinfo *sip;
1665 struct selinfo *sip;
1676 struct selinfo *sip;
1684 if (sip->si_mtx == NULL)
1689 mtx_lock(sip->si_mtx);
1690 TAILQ_FOREACH_SAFE(sfp, &sip->si_tdlist, sf_threads, sfn) {
1695 TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads);
1698 mtx_lock(&stp->st_mtx);
1701 mtx_unlock(&stp->st_mtx);
1703 mtx_unlock(sip->si_mtx);
1711 if ((stp = td->td_sel) != NULL)
1713 td->td_sel = stp =
malloc(
sizeof(*stp), M_SELECT, M_WAITOK|M_ZERO);
1714 mtx_init(&stp->st_mtx,
"sellck", NULL, MTX_DEF);
1715 cv_init(&stp->st_wait,
"select");
1718 STAILQ_INIT(&stp->st_selq);
1732 mtx_lock(&stp->st_mtx);
1738 mtx_unlock(&stp->st_mtx);
1742 error = cv_timedwait_sig(&stp->st_wait, &stp->st_mtx, timo);
1744 error = cv_wait_sig(&stp->st_wait, &stp->st_mtx);
1745 mtx_unlock(&stp->st_mtx);
1759 uma_zfree(selfd_zone, stp->st_free1);
1761 uma_zfree(selfd_zone, stp->st_free2);
1763 free(stp, M_SELECT);
1778 STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn)
1789 selfd_zone = uma_zcreate(
"selfd",
sizeof(
struct selfd), NULL, NULL,
1790 NULL, NULL, UMA_ALIGN_PTR, 0);
CTASSERT(sizeof(register_t) >=sizeof(size_t))
int tvtohz(struct timeval *tv)
static int select_check_badfd(fd_set *fd_in, int nd, int ndu, int abi_nfdbits)
struct uio * cloneuio(struct uio *uiop)
#define SYS_IOCTL_SMALL_SIZE
int kern_ftruncate(struct thread *td, int fd, off_t length)
static struct mtx_pool * mtxpool_select
void selwakeup(struct selinfo *sip)
struct file * fget_unlocked(struct filedesc *fdp, int fd)
static void selectinit(void *)
static void selfdfree(struct seltd *, struct selfd *)
#define SYS_IOCTL_SMALL_ALIGN
int freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap)
int sys_ftruncate(struct thread *td, struct ftruncate_args *uap)
void selrecord(struct thread *selector, struct selinfo *sip)
void * malloc(unsigned long size, struct malloc_type *mtp, int flags)
int cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp)
void panic(const char *fmt,...)
int kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tvp, sigset_t *uset, int abi_nfdbits)
int sys_pwritev(struct thread *td, struct pwritev_args *uap)
int devfs_iosize_max_clamp
int sys_pread(struct thread *td, struct pread_args *uap)
void selwakeuppri(struct selinfo *sip, int pri)
static int seltdwait(struct thread *, int)
static void selfdalloc(struct thread *, void *)
static int pollscan(struct thread *, struct pollfd *, u_int)
static __inline int getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp)
int sys_ioctl(struct thread *td, struct ioctl_args *uap)
int sys_openbsd_poll(struct thread *td, struct openbsd_poll_args *uap)
SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,&iosize_max_clamp, 0,"Clamp max i/o size to INT_MAX")
struct mtx * mtx_pool_find(struct mtx_pool *pool, void *ptr)
int fget(struct thread *td, int fd, cap_rights_t rights, struct file **fpp)
int kern_sigprocmask(struct thread *td, int how, sigset_t *set, sigset_t *oset, int flags)
static STAILQ_HEAD(cn_device)
void getmicrouptime(struct timeval *tvp)
void timevalsub(struct timeval *t1, const struct timeval *t2)
static __inline int selflags(fd_mask **ibits, int idx, fd_mask bit)
int sys_read(struct thread *td, struct read_args *uap)
int sys_poll(struct thread *td, struct poll_args *uap)
static int dofilewrite(struct thread *, int, struct file *, struct uio *, off_t, int)
int sopoll(struct socket *so, int events, struct ucred *active_cred, struct thread *td)
int sys_preadv(struct thread *td, struct preadv_args *uap)
void tdsignal(struct thread *td, int sig)
void seldrain(struct selinfo *sip)
int poll_no_poll(int events)
int kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset)
SYSINIT(select, SI_SUB_SYSCALLS, SI_ORDER_ANY, selectinit, NULL)
static uma_zone_t selfd_zone
void cv_broadcastpri(struct cv *cvp, int pri)
int freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap)
void timevaladd(struct timeval *t1, const struct timeval *t2)
int kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data)
static int pollout(struct thread *, struct pollfd *, struct pollfd *, u_int)
int selsocket(struct socket *so, int events, struct timeval *tvp, struct thread *td)
struct mtx_pool * mtx_pool_create(const char *mtx_name, int pool_size, int opts)
static int selscan(struct thread *, fd_mask **, fd_mask **, int)
int sys_write(struct thread *td, struct write_args *uap)
void cv_init(struct cv *cvp, const char *desc)
static __inline int selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events)
void free(void *addr, struct malloc_type *mtp)
static void doselwakeup(struct selinfo *, int)
int sys_readv(struct thread *td, struct readv_args *uap)
int printf(const char *fmt,...)
int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou, fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits)
int copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop)
int kern_readv(struct thread *td, int fd, struct uio *auio)
static int dofileread(struct thread *, int, struct file *, struct uio *, off_t, int)
static void seltdclear(struct thread *)
void mtx_init(struct mtx *m, const char *name, const char *type, int opts)
int kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset)
static MALLOC_DEFINE(M_IOCTLOPS,"ioctlops","ioctl data buffer")
int fget_read(struct thread *td, int fd, cap_rights_t rights, struct file **fpp)
int kern_writev(struct thread *td, int fd, struct uio *auio)
int itimerfix(struct timeval *tv)
#define swizzle_fdset(bits)
void seltdfini(struct thread *td)
int sys_writev(struct thread *td, struct writev_args *uap)
int fget_write(struct thread *td, int fd, cap_rights_t rights, struct file **fpp)
struct thread thread0 __aligned(16)
int sys_select(struct thread *td, struct select_args *uap)
static int selrescan(struct thread *, fd_mask **, fd_mask **)
int sys_pselect(struct thread *td, struct pselect_args *uap)
static int pollrescan(struct thread *)
int sys_pwrite(struct thread *td, struct pwrite_args *uap)
static void seltdinit(struct thread *)
static int select_flags[3]