|
FreeBSD kernel kern code
|
#include <sys/cdefs.h>#include "opt_capsicum.h"#include "opt_compat.h"#include "opt_ktrace.h"#include <sys/param.h>#include <sys/systm.h>#include <sys/sysproto.h>#include <sys/capability.h>#include <sys/filedesc.h>#include <sys/filio.h>#include <sys/fcntl.h>#include <sys/file.h>#include <sys/proc.h>#include <sys/signalvar.h>#include <sys/socketvar.h>#include <sys/uio.h>#include <sys/kernel.h>#include <sys/ktr.h>#include <sys/limits.h>#include <sys/malloc.h>#include <sys/poll.h>#include <sys/resourcevar.h>#include <sys/selinfo.h>#include <sys/sleepqueue.h>#include <sys/syscallsubr.h>#include <sys/sysctl.h>#include <sys/sysent.h>#include <sys/vnode.h>#include <sys/bio.h>#include <sys/buf.h>#include <sys/condvar.h>#include <security/audit/audit.h>
Go to the source code of this file.
Data Structures | |
| struct | seltd |
| struct | selfd |
| struct | read_args |
| struct | pread_args |
| struct | readv_args |
| struct | preadv_args |
| struct | write_args |
| struct | pwrite_args |
| struct | writev_args |
| struct | pwritev_args |
| struct | ftruncate_args |
| struct | ioctl_args |
| struct | select_args |
| struct | poll_args |
| struct | openbsd_poll_args |
Macros | |
| #define | SYS_IOCTL_SMALL_SIZE 128 /* bytes */ |
| #define | SYS_IOCTL_SMALL_ALIGN 8 /* bytes */ |
| #define | SELTD_PENDING 0x0001 /* We have pending events. */ |
| #define | SELTD_RESCAN 0x0002 /* Doing a rescan. */ |
| #define | getbits(name, x) |
| #define | swizzle_fdset(bits) |
| #define | putbits(name, x) |
Functions | |
| __FBSDID ("$BSDSUniX$") | |
| SYSCTL_INT (_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,&iosize_max_clamp, 0,"Clamp max i/o size to INT_MAX") | |
| SYSCTL_INT (_debug, OID_AUTO, devfs_iosize_max_clamp, CTLFLAG_RW,&devfs_iosize_max_clamp, 0,"Clamp max i/o size to INT_MAX for devices") | |
| CTASSERT (sizeof(register_t) >=sizeof(size_t)) | |
| static | MALLOC_DEFINE (M_IOCTLOPS,"ioctlops","ioctl data buffer") |
| static | MALLOC_DEFINE (M_SELECT,"select","select() buffer") |
| MALLOC_DEFINE (M_IOV,"iov","large iov's") | |
| static int | pollout (struct thread *, struct pollfd *, struct pollfd *, u_int) |
| static int | pollscan (struct thread *, struct pollfd *, u_int) |
| static int | pollrescan (struct thread *) |
| static int | selscan (struct thread *, fd_mask **, fd_mask **, int) |
| static int | selrescan (struct thread *, fd_mask **, fd_mask **) |
| static void | selfdalloc (struct thread *, void *) |
| static void | selfdfree (struct seltd *, struct selfd *) |
| static int | dofileread (struct thread *, int, struct file *, struct uio *, off_t, int) |
| static int | dofilewrite (struct thread *, int, struct file *, struct uio *, off_t, int) |
| static void | doselwakeup (struct selinfo *, int) |
| static void | seltdinit (struct thread *) |
| static int | seltdwait (struct thread *, int) |
| static void | seltdclear (struct thread *) |
| int | sys_read (struct thread *td, struct read_args *uap) |
| int | sys_pread (struct thread *td, struct pread_args *uap) |
| int | freebsd6_pread (struct thread *td, struct freebsd6_pread_args *uap) |
| int | sys_readv (struct thread *td, struct readv_args *uap) |
| int | kern_readv (struct thread *td, int fd, struct uio *auio) |
| int | sys_preadv (struct thread *td, struct preadv_args *uap) |
| int | kern_preadv (struct thread *td, int fd, struct uio *auio, off_t offset) |
| int | sys_write (struct thread *td, struct write_args *uap) |
| int | sys_pwrite (struct thread *td, struct pwrite_args *uap) |
| int | freebsd6_pwrite (struct thread *td, struct freebsd6_pwrite_args *uap) |
| int | sys_writev (struct thread *td, struct writev_args *uap) |
| int | kern_writev (struct thread *td, int fd, struct uio *auio) |
| int | sys_pwritev (struct thread *td, struct pwritev_args *uap) |
| int | kern_pwritev (struct thread *td, int fd, struct uio *auio, off_t offset) |
| int | kern_ftruncate (struct thread *td, int fd, off_t length) |
| int | sys_ftruncate (struct thread *td, struct ftruncate_args *uap) |
| int | sys_ioctl (struct thread *td, struct ioctl_args *uap) |
| int | kern_ioctl (struct thread *td, int fd, u_long com, caddr_t data) |
| int | poll_no_poll (int events) |
| int | sys_pselect (struct thread *td, struct pselect_args *uap) |
| 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_select (struct thread *td, struct select_args *uap) |
| static int | select_check_badfd (fd_set *fd_in, int nd, int ndu, int abi_nfdbits) |
| 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) |
| static __inline int | selflags (fd_mask **ibits, int idx, fd_mask bit) |
| static __inline int | selsetbits (fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events) |
| static __inline int | getselfd_cap (struct filedesc *fdp, int fd, struct file **fpp) |
| int | sys_poll (struct thread *td, struct poll_args *uap) |
| int | sys_openbsd_poll (struct thread *td, struct openbsd_poll_args *uap) |
| int | selsocket (struct socket *so, int events, struct timeval *tvp, struct thread *td) |
| void | seldrain (struct selinfo *sip) |
| void | selrecord (struct thread *selector, struct selinfo *sip) |
| void | selwakeup (struct selinfo *sip) |
| void | selwakeuppri (struct selinfo *sip, int pri) |
| void | seltdfini (struct thread *td) |
| static void | selectinit (void *) |
| SYSINIT (select, SI_SUB_SYSCALLS, SI_ORDER_ANY, selectinit, NULL) | |
| static void | selectinit (void *dummy __unused) |
Variables | |
| int | iosize_max_clamp = 1 |
| int | devfs_iosize_max_clamp = 1 |
| static uma_zone_t | selfd_zone |
| static struct mtx_pool * | mtxpool_select |
| static int | select_flags [3] |
| #define getbits | ( | name, | |
| x | |||
| ) |
Referenced by kern_select().
| #define putbits | ( | name, | |
| x | |||
| ) |
Referenced by kern_select().
| #define SELTD_PENDING 0x0001 /* We have pending events. */ |
Definition at line 141 of file sys_generic.c.
Referenced by doselwakeup(), and seltdwait().
| #define SELTD_RESCAN 0x0002 /* Doing a rescan. */ |
Definition at line 142 of file sys_generic.c.
Referenced by selrecord(), and seltdwait().
| #define swizzle_fdset | ( | bits | ) |
Referenced by kern_select().
| #define SYS_IOCTL_SMALL_ALIGN 8 /* bytes */ |
Definition at line 89 of file sys_generic.c.
Referenced by sys_ioctl().
| #define SYS_IOCTL_SMALL_SIZE 128 /* bytes */ |
Definition at line 88 of file sys_generic.c.
Referenced by sys_ioctl().
| __FBSDID | ( | "$BSDSUniX$" | ) |
| CTASSERT | ( | sizeof(register_t) >=sizeof(size_t) | ) |
|
static |
Definition at line 326 of file sys_generic.c.
References cloneuio().
Referenced by kern_preadv(), and kern_readv().


|
static |
Definition at line 535 of file sys_generic.c.
References bwillwrite(), cloneuio(), and tdsignal().
Referenced by kern_pwritev(), and kern_writev().


|
static |
Definition at line 1675 of file sys_generic.c.
References cv_broadcastpri(), and SELTD_PENDING.
Referenced by seldrain(), selwakeup(), and selwakeuppri().


| int freebsd6_pread | ( | struct thread * | td, |
| struct freebsd6_pread_args * | uap | ||
| ) |
Definition at line 222 of file sys_generic.c.
References pread_args::buf, pread_args::fd, pread_args::nbyte, pread_args::offset, and sys_pread().

| int freebsd6_pwrite | ( | struct thread * | td, |
| struct freebsd6_pwrite_args * | uap | ||
| ) |
Definition at line 431 of file sys_generic.c.
References pwrite_args::buf, pwrite_args::fd, pwrite_args::nbyte, pwrite_args::offset, and sys_pwrite().

|
static |
Definition at line 1152 of file sys_generic.c.
References cap_funwrap(), and fget_unlocked().
Referenced by selrescan(), and selscan().


| int kern_ftruncate | ( | struct thread * | td, |
| int | fd, | ||
| off_t | length | ||
| ) |
Definition at line 589 of file sys_generic.c.
References fget().
Referenced by sys_ftruncate().


| int kern_ioctl | ( | struct thread * | td, |
| int | fd, | ||
| u_long | com, | ||
| caddr_t | data | ||
| ) |
Definition at line 724 of file sys_generic.c.
Referenced by parse_dir_md(), and sys_ioctl().


| int kern_preadv | ( | struct thread * | td, |
| int | fd, | ||
| struct uio * | auio, | ||
| off_t | offset | ||
| ) |
Definition at line 299 of file sys_generic.c.
References dofileread(), and fget_read().
Referenced by sys_pread(), and sys_preadv().


| 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 | ||
| ) |
Definition at line 817 of file sys_generic.c.
References kern_select(), and kern_sigprocmask().
Referenced by sys_pselect().


| int kern_pwritev | ( | struct thread * | td, |
| int | fd, | ||
| struct uio * | auio, | ||
| off_t | offset | ||
| ) |
Definition at line 508 of file sys_generic.c.
References dofilewrite(), and fget_write().
Referenced by sys_pwrite(), and sys_pwritev().


| int kern_readv | ( | struct thread * | td, |
| int | fd, | ||
| struct uio * | auio | ||
| ) |
Definition at line 260 of file sys_generic.c.
References dofileread(), and fget_read().
Referenced by sys_read(), and sys_readv().


| 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 | ||
| ) |
Definition at line 915 of file sys_generic.c.
References free(), getbits, getmicrouptime(), hz, itimerfix(), malloc(), putbits, select_check_badfd(), selrescan(), selscan(), seltdclear(), seltdinit(), seltdwait(), swizzle_fdset, timevaladd(), timevalsub(), and tvtohz().
Referenced by kern_pselect(), and sys_select().


| int kern_writev | ( | struct thread * | td, |
| int | fd, | ||
| struct uio * | auio | ||
| ) |
Definition at line 469 of file sys_generic.c.
References dofilewrite(), and fget_write().
Referenced by kern_sendfile(), sys_write(), and sys_writev().


|
static |
|
static |
| MALLOC_DEFINE | ( | M_IOV | , |
| "iov" | , | ||
| "large iov's" | |||
| ) |
| int poll_no_poll | ( | int | events | ) |
Definition at line 774 of file sys_generic.c.
Referenced by no_poll(), and vop_nopoll().

|
static |
Definition at line 1401 of file sys_generic.c.
Referenced by sys_poll().

|
static |
Definition at line 1351 of file sys_generic.c.
References cap_funwrap(), fd, and selfdfree().
Referenced by sys_poll().


|
static |
Definition at line 1426 of file sys_generic.c.
References cap_funwrap(), and selfdalloc().
Referenced by sys_poll().


| void seldrain | ( | struct selinfo * | sip | ) |
Definition at line 1587 of file sys_generic.c.
References doselwakeup().
Referenced by destroy_vpollinfo(), kqueue_close(), mqueue_free(), pipeclose(), ptsdrv_free(), sofree(), and tty_dealloc().


|
static |
Definition at line 876 of file sys_generic.c.
Referenced by kern_select().

|
static |
|
static |
Definition at line 1786 of file sys_generic.c.
References mtx_pool_create().

|
static |
Definition at line 1559 of file sys_generic.c.
Referenced by pollscan(), selscan(), and selsocket().

Definition at line 1575 of file sys_generic.c.
Referenced by pollrescan(), selrescan(), and seltdclear().

|
static |
Definition at line 1102 of file sys_generic.c.
Referenced by selrescan(), and selscan().

| void selrecord | ( | struct thread * | selector, |
| struct selinfo * | sip | ||
| ) |
Definition at line 1606 of file sys_generic.c.
References mtx_pool_find(), panic(), and SELTD_RESCAN.
Referenced by devpoll(), kqueue_poll(), logpoll(), mqf_poll(), pipe_poll(), ptsdev_poll(), sopoll_generic(), ttydev_poll(), and vn_pollrecord().


|
static |
Definition at line 1187 of file sys_generic.c.
References fd, getselfd_cap(), selfdfree(), selflags(), and selsetbits().
Referenced by kern_select().


|
static |
Definition at line 1229 of file sys_generic.c.
References fd, getselfd_cap(), selfdalloc(), selflags(), and selsetbits().
Referenced by kern_select().


|
static |
Definition at line 1123 of file sys_generic.c.
Referenced by selrescan(), and selscan().

| int selsocket | ( | struct socket * | so, |
| int | events, | ||
| struct timeval * | tvp, | ||
| struct thread * | td | ||
| ) |
Definition at line 1505 of file sys_generic.c.
References getmicrouptime(), hz, itimerfix(), selfdalloc(), seltdclear(), seltdinit(), seltdwait(), sopoll(), timevaladd(), timevalsub(), and tvtohz().

|
static |
Definition at line 1771 of file sys_generic.c.
References selfdfree().
Referenced by kern_select(), selsocket(), and sys_poll().


| void seltdfini | ( | struct thread * | td | ) |
Definition at line 1751 of file sys_generic.c.
References free().
Referenced by thread_fini().


|
static |
Definition at line 1707 of file sys_generic.c.
References cv_init(), malloc(), and mtx_init().
Referenced by kern_select(), selsocket(), and sys_poll().


|
static |
Definition at line 1722 of file sys_generic.c.
References SELTD_PENDING, and SELTD_RESCAN.
Referenced by kern_select(), selsocket(), and sys_poll().

| void selwakeup | ( | struct selinfo * | sip | ) |
Definition at line 1656 of file sys_generic.c.
References doselwakeup().
Referenced by _mqueue_recv(), _mqueue_send(), devctl_queue_data_f(), mqueue_fdclose(), ptsdrv_inwakeup(), ptsdrv_outwakeup(), and tty_wakeup().


| void selwakeuppri | ( | struct selinfo * | sip, |
| int | pri | ||
| ) |
Definition at line 1664 of file sys_generic.c.
References doselwakeup().
Referenced by kqueue_close(), kqueue_wakeup(), logtimeout(), pipeselwakeup(), sohasoutofband(), and sowakeup().


| int sys_ftruncate | ( | struct thread * | td, |
| struct ftruncate_args * | uap | ||
| ) |
Definition at line 621 of file sys_generic.c.
References ftruncate_args::fd, kern_ftruncate(), and ftruncate_args::length.
Referenced by freebsd6_ftruncate().


| int sys_ioctl | ( | struct thread * | td, |
| struct ioctl_args * | uap | ||
| ) |
Definition at line 655 of file sys_generic.c.
References __aligned(), ioctl_args::com, ioctl_args::data, ioctl_args::fd, free(), kern_ioctl(), malloc(), printf(), SYS_IOCTL_SMALL_ALIGN, and SYS_IOCTL_SMALL_SIZE.

| int sys_openbsd_poll | ( | struct thread * | td, |
| struct openbsd_poll_args * | uap | ||
| ) |
Definition at line 1491 of file sys_generic.c.
References sys_poll().

| int sys_poll | ( | struct thread * | td, |
| struct poll_args * | uap | ||
| ) |
Definition at line 1273 of file sys_generic.c.
References poll_args::fds, free(), getmicrouptime(), hz, itimerfix(), malloc(), maxfilesperproc, poll_args::nfds, pollout(), pollrescan(), pollscan(), seltdclear(), seltdinit(), seltdwait(), poll_args::timeout, timevaladd(), timevalsub(), and tvtohz().
Referenced by sys_openbsd_poll().


| int sys_pread | ( | struct thread * | td, |
| struct pread_args * | uap | ||
| ) |
Definition at line 201 of file sys_generic.c.
References pread_args::buf, pread_args::fd, kern_preadv(), pread_args::nbyte, and pread_args::offset.
Referenced by freebsd6_pread().


| int sys_preadv | ( | struct thread * | td, |
| struct preadv_args * | uap | ||
| ) |
Definition at line 285 of file sys_generic.c.
References copyinuio(), preadv_args::fd, free(), preadv_args::iovcnt, preadv_args::iovp, kern_preadv(), and preadv_args::offset.

| int sys_pselect | ( | struct thread * | td, |
| struct pselect_args * | uap | ||
| ) |
Definition at line 790 of file sys_generic.c.
References kern_pselect(), and set.

| int sys_pwrite | ( | struct thread * | td, |
| struct pwrite_args * | uap | ||
| ) |
Definition at line 410 of file sys_generic.c.
References pwrite_args::buf, pwrite_args::fd, kern_pwritev(), pwrite_args::nbyte, and pwrite_args::offset.
Referenced by freebsd6_pwrite().


| int sys_pwritev | ( | struct thread * | td, |
| struct pwritev_args * | uap | ||
| ) |
Definition at line 494 of file sys_generic.c.
References copyinuio(), pwritev_args::fd, free(), pwritev_args::iovcnt, pwritev_args::iovp, kern_pwritev(), and pwritev_args::offset.

| int sys_read | ( | struct thread * | td, |
| struct read_args * | uap | ||
| ) |
Definition at line 168 of file sys_generic.c.
References read_args::buf, read_args::fd, kern_readv(), and read_args::nbyte.

| int sys_readv | ( | struct thread * | td, |
| struct readv_args * | uap | ||
| ) |
Definition at line 246 of file sys_generic.c.
References copyinuio(), readv_args::fd, free(), readv_args::iovcnt, readv_args::iovp, and kern_readv().

| int sys_select | ( | struct thread * | td, |
| struct select_args * | uap | ||
| ) |
Definition at line 849 of file sys_generic.c.
References select_args::ex, select_args::in, kern_select(), select_args::nd, select_args::ou, and select_args::tv.

| int sys_write | ( | struct thread * | td, |
| struct write_args * | uap | ||
| ) |
Definition at line 377 of file sys_generic.c.
References write_args::buf, write_args::fd, kern_writev(), and write_args::nbyte.

| int sys_writev | ( | struct thread * | td, |
| struct writev_args * | uap | ||
| ) |
Definition at line 455 of file sys_generic.c.
References copyinuio(), writev_args::fd, free(), writev_args::iovcnt, writev_args::iovp, and kern_writev().

| SYSCTL_INT | ( | _debug | , |
| OID_AUTO | , | ||
| iosize_max_clamp | , | ||
| CTLFLAG_RW | , | ||
| & | iosize_max_clamp, | ||
| 0 | , | ||
| "Clamp max i/o size to INT_MAX" | |||
| ) |
| SYSCTL_INT | ( | _debug | , |
| OID_AUTO | , | ||
| devfs_iosize_max_clamp | , | ||
| CTLFLAG_RW | , | ||
| & | devfs_iosize_max_clamp, | ||
| 0 | , | ||
| "Clamp max i/o size to INT_MAX for devices" | |||
| ) |
| SYSINIT | ( | select | , |
| SI_SUB_SYSCALLS | , | ||
| SI_ORDER_ANY | , | ||
| selectinit | , | ||
| NULL | |||
| ) |
| int devfs_iosize_max_clamp = 1 |
Definition at line 94 of file sys_generic.c.
| int iosize_max_clamp = 1 |
Definition at line 91 of file sys_generic.c.
|
static |
Definition at line 158 of file sys_generic.c.
|
static |
Definition at line 1091 of file sys_generic.c.
|
static |
Definition at line 157 of file sys_generic.c.