FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_compat.h"
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include "opt_procdesc.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/capability.h>
#include <sys/conf.h>
#include <sys/domain.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/filio.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/ksem.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/mqueue.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/selinfo.h>
#include <sys/pipe.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/procdesc.h>
#include <sys/protosw.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/signalvar.h>
#include <sys/socketvar.h>
#include <sys/stat.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/tty.h>
#include <sys/unistd.h>
#include <sys/un.h>
#include <sys/unpcb.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <security/audit/audit.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <ddb/ddb.h>
Go to the source code of this file.
Data Structures | |
struct | freetable |
struct | filedesc0 |
struct | getdtablesize_args |
struct | dup2_args |
struct | dup_args |
struct | fcntl_args |
struct | close_args |
struct | closefrom_args |
struct | fstat_args |
struct | nfstat_args |
struct | fpathconf_args |
struct | flock_args |
struct | export_fd_buf |
Macros | |
#define | DUP_FIXED 0x1 /* Force fixed allocation */ |
#define | DUP_FCNTL 0x2 /* fcntl()-style errors */ |
#define | DUP_CLOEXEC 0x4 /* Atomically set FD_CLOEXEC. */ |
#define | NDFILE 20 |
#define | NDSLOTSIZE sizeof(NDSLOTTYPE) |
#define | NDENTRIES (NDSLOTSIZE * __CHAR_BIT) |
#define | NDSLOT(x) ((x) / NDENTRIES) |
#define | NDBIT(x) ((NDSLOTTYPE)1 << ((x) % NDENTRIES)) |
#define | NDSLOTS(x) (((x) + NDENTRIES - 1) / NDENTRIES) |
#define | OFILESIZE (sizeof(struct file *) + sizeof(char)) |
#define | FGET_GETCAP 0x00000001 |
#define | NFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table)) |
#define | FILEDESC_SBUF_SIZE (sizeof(struct kinfo_file) * 5) |
#define | NVTYPES (sizeof(vtypes_table) / sizeof(*vtypes_table)) |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_FILEDESC,"filedesc","Open file descriptor table") |
static | MALLOC_DEFINE (M_FILEDESC_TO_LEADER,"filedesc_to_leader","file desc to leader structures") |
static | MALLOC_DEFINE (M_SIGIO,"sigio","sigio structures") |
MALLOC_DECLARE (M_FADVISE) | |
static int | do_dup (struct thread *td, int flags, int old, int new, register_t *retval) |
static int | fd_first_free (struct filedesc *, int, int) |
static int | fd_last_used (struct filedesc *, int, int) |
static void | fdgrowtable (struct filedesc *, int) |
static void | fdunused (struct filedesc *fdp, int fd) |
static void | fdused (struct filedesc *fdp, int fd) |
static int | fill_vnode_info (struct vnode *vp, struct kinfo_file *kif) |
static int | fill_socket_info (struct socket *so, struct kinfo_file *kif) |
static int | fill_pts_info (struct tty *tp, struct kinfo_file *kif) |
static int | fill_pipe_info (struct pipe *pi, struct kinfo_file *kif) |
static int | fill_procdesc_info (struct procdesc *pdp, struct kinfo_file *kif) |
static int | fill_sem_info (struct file *fp, struct kinfo_file *kif) |
static int | fill_shm_info (struct file *fp, struct kinfo_file *kif) |
static int | getmaxfd (struct proc *p) |
static int | fdisused (struct filedesc *fdp, int fd) |
int | sys_getdtablesize (struct thread *td, struct getdtablesize_args *uap) |
int | sys_dup2 (struct thread *td, struct dup2_args *uap) |
int | sys_dup (struct thread *td, struct dup_args *uap) |
int | sys_fcntl (struct thread *td, struct fcntl_args *uap) |
static struct file * | fdtofp (int fd, struct filedesc *fdp) |
static int | fdunwrap (int fd, cap_rights_t rights, struct filedesc *fdp, struct file **fpp) |
int | kern_fcntl (struct thread *td, int fd, int cmd, intptr_t arg) |
void | funsetown (struct sigio **sigiop) |
void | funsetownlst (struct sigiolst *sigiolst) |
int | fsetown (pid_t pgid, struct sigio **sigiop) |
pid_t | fgetown (struct sigio **sigiop) |
int | sys_close (struct thread *td, struct close_args *uap) |
int | kern_close (struct thread *td, int fd) |
int | sys_closefrom (struct thread *td, struct closefrom_args *uap) |
int | sys_fstat (struct thread *td, struct fstat_args *uap) |
int | kern_fstat (struct thread *td, int fd, struct stat *sbp) |
int | sys_nfstat (struct thread *td, struct nfstat_args *uap) |
int | sys_fpathconf (struct thread *td, struct fpathconf_args *uap) |
int | fdalloc (struct thread *td, int minfd, int *result) |
int | fdallocn (struct thread *td, int minfd, int *fds, int n) |
int | fdavail (struct thread *td, int n) |
int | falloc (struct thread *td, struct file **resultfp, int *resultfd, int flags) |
int | falloc_noinstall (struct thread *td, struct file **resultfp) |
int | finstall (struct thread *td, struct file *fp, int *fd, int flags) |
struct filedesc * | fdinit (struct filedesc *fdp) |
static struct filedesc * | fdhold (struct proc *p) |
static void | fddrop (struct filedesc *fdp) |
struct filedesc * | fdshare (struct filedesc *fdp) |
void | fdunshare (struct proc *p, struct thread *td) |
struct filedesc * | fdcopy (struct filedesc *fdp) |
void | fdfree (struct thread *td) |
static int | is_unsafe (struct file *fp) |
void | setugidsafety (struct thread *td) |
void | fdclose (struct filedesc *fdp, struct file *fp, int idx, struct thread *td) |
void | fdcloseexec (struct thread *td) |
int | fdcheckstd (struct thread *td) |
int | closef (struct file *fp, struct thread *td) |
void | finit (struct file *fp, u_int flag, short type, void *data, struct fileops *ops) |
struct file * | fget_unlocked (struct filedesc *fdp, int fd) |
static __inline int | _fget (struct thread *td, int fd, struct file **fpp, int flags, cap_rights_t needrights, cap_rights_t *haverightsp, u_char *maxprotp, int fget_flags) |
int | fget (struct thread *td, int fd, cap_rights_t rights, struct file **fpp) |
int | fget_mmap (struct thread *td, int fd, cap_rights_t rights, u_char *maxprotp, struct file **fpp) |
int | fget_read (struct thread *td, int fd, cap_rights_t rights, struct file **fpp) |
int | fget_write (struct thread *td, int fd, cap_rights_t rights, struct file **fpp) |
int | fgetcap (struct thread *td, int fd, struct file **fpp) |
static __inline int | _fgetvp (struct thread *td, int fd, int flags, cap_rights_t needrights, cap_rights_t *haverightsp, struct vnode **vpp) |
int | fgetvp (struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp) |
int | fgetvp_rights (struct thread *td, int fd, cap_rights_t need, cap_rights_t *have, struct vnode **vpp) |
int | fgetvp_read (struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp) |
int | fgetvp_exec (struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp) |
int | fgetsock (struct thread *td, int fd, cap_rights_t rights, struct socket **spp, u_int *fflagp) |
void | fputsock (struct socket *so) |
int | _fdrop (struct file *fp, struct thread *td) |
int | sys_flock (struct thread *td, struct flock_args *uap) |
int | dupfdopen (struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error) |
void | mountcheckdirs (struct vnode *olddp, struct vnode *newdp) |
struct filedesc_to_leader * | filedesc_to_leader_alloc (struct filedesc_to_leader *old, struct filedesc *fdp, struct proc *leader) |
static int | sysctl_kern_file (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD, 0, 0, sysctl_kern_file,"S,xfile","Entire file table") | |
static int | export_fd_to_sb (void *data, int type, int fd, int fflags, int refcnt, int64_t offset, int fd_is_cap, cap_rights_t fd_cap_rights, struct export_fd_buf *efbuf) |
int | kern_proc_filedesc_out (struct proc *p, struct sbuf *sb, ssize_t maxlen) |
static int | sysctl_kern_proc_filedesc (SYSCTL_HANDLER_ARGS) |
int | vntype_to_kinfo (int vtype) |
static | SYSCTL_NODE (_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD, sysctl_kern_proc_filedesc,"Process filedesc entries") |
SYSCTL_INT (_kern, KERN_MAXFILESPERPROC, maxfilesperproc, CTLFLAG_RW,&maxfilesperproc, 0,"Maximum files allowed open per process") | |
SYSCTL_INT (_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,&maxfiles, 0,"Maximum number of files") | |
SYSCTL_INT (_kern, OID_AUTO, openfiles, CTLFLAG_RD, __DEVOLATILE(int *,&openfiles), 0,"System-wide number of open files") | |
static void | filelistinit (void *dummy) |
SYSINIT (select, SI_SUB_LOCK, SI_ORDER_FIRST, filelistinit, NULL) | |
static int | badfo_readwrite (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td) |
static int | badfo_truncate (struct file *fp, off_t length, struct ucred *active_cred, struct thread *td) |
static int | badfo_ioctl (struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td) |
static int | badfo_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td) |
static int | badfo_kqfilter (struct file *fp, struct knote *kn) |
static int | badfo_stat (struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) |
static int | badfo_close (struct file *fp, struct thread *td) |
static int | badfo_chmod (struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td) |
static int | badfo_chown (struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td) |
int | invfo_chmod (struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td) |
int | invfo_chown (struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td) |
static int | fdopen (struct cdev *dev, int mode, int type, struct thread *td) |
static void | fildesc_drvinit (void *unused) |
SYSINIT (fildescdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, fildesc_drvinit, NULL) | |
Variables | |
static uma_zone_t | file_zone |
void(* | ksem_info )(struct ksem *ks, char *path, size_t size, uint32_t *value) |
volatile int | openfiles |
struct mtx | sigio_lock |
void(* | mq_fdclose )(struct thread *td, int fd, struct file *fp) |
static struct mtx | fdesc_mtx |
struct fileops | badfileops |
static struct cdevsw | fildesc_cdevsw |
#define DUP_CLOEXEC 0x4 /* Atomically set FD_CLOEXEC. */ |
Definition at line 119 of file kern_descrip.c.
Referenced by do_dup(), and kern_fcntl().
#define DUP_FCNTL 0x2 /* fcntl()-style errors */ |
Definition at line 118 of file kern_descrip.c.
Referenced by do_dup(), and kern_fcntl().
#define DUP_FIXED 0x1 /* Force fixed allocation */ |
Definition at line 117 of file kern_descrip.c.
Referenced by do_dup(), fdcheckstd(), kern_fcntl(), and sys_dup2().
#define FGET_GETCAP 0x00000001 |
Definition at line 2382 of file kern_descrip.c.
#define FILEDESC_SBUF_SIZE (sizeof(struct kinfo_file) * 5) |
Definition at line 3569 of file kern_descrip.c.
Referenced by sysctl_kern_proc_filedesc().
#define NDBIT | ( | x | ) | ((NDSLOTTYPE)1 << ((x) % NDENTRIES)) |
Definition at line 150 of file kern_descrip.c.
Referenced by fdisused(), fdunused(), and fdused().
#define NDENTRIES (NDSLOTSIZE * __CHAR_BIT) |
Definition at line 148 of file kern_descrip.c.
Referenced by fd_first_free(), fd_last_used(), and fdgrowtable().
#define NDFILE 20 |
Definition at line 146 of file kern_descrip.c.
Referenced by fdfree(), fdgrowtable(), and fdinit().
#define NDSLOT | ( | x | ) | ((x) / NDENTRIES) |
Definition at line 149 of file kern_descrip.c.
Referenced by fd_first_free(), fd_last_used(), fdisused(), fdunused(), and fdused().
Definition at line 151 of file kern_descrip.c.
Referenced by fd_first_free(), fdfree(), and fdgrowtable().
#define NDSLOTSIZE sizeof(NDSLOTTYPE) |
Definition at line 147 of file kern_descrip.c.
Referenced by fdgrowtable().
#define NFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table)) |
Referenced by export_fd_to_sb().
#define NVTYPES (sizeof(vtypes_table) / sizeof(*vtypes_table)) |
Referenced by vntype_to_kinfo().
#define OFILESIZE (sizeof(struct file *) + sizeof(char)) |
Definition at line 156 of file kern_descrip.c.
Referenced by fdgrowtable().
__FBSDID | ( | "$BSDSUniX$" | ) |
int _fdrop | ( | struct file * | fp, |
struct thread * | td | ||
) |
Definition at line 2656 of file kern_descrip.c.
References badfileops, crfree(), file_zone, free(), openfiles, and panic().
|
static |
Definition at line 2384 of file kern_descrip.c.
References badfileops, cap_funwrap(), cap_funwrap_mmap(), FGET_GETCAP, and fget_unlocked().
Referenced by _fgetvp(), fget(), fget_mmap(), fget_read(), fget_write(), fgetcap(), and fgetsock().
|
static |
Definition at line 2535 of file kern_descrip.c.
References _fget(), and vref().
Referenced by fgetvp(), fgetvp_exec(), fgetvp_read(), and fgetvp_rights().
|
static |
Definition at line 3989 of file kern_descrip.c.
|
static |
Definition at line 3997 of file kern_descrip.c.
|
static |
Definition at line 3982 of file kern_descrip.c.
|
static |
Definition at line 3951 of file kern_descrip.c.
|
static |
Definition at line 3967 of file kern_descrip.c.
|
static |
Definition at line 3959 of file kern_descrip.c.
|
static |
Definition at line 3935 of file kern_descrip.c.
|
static |
Definition at line 3974 of file kern_descrip.c.
|
static |
Definition at line 3943 of file kern_descrip.c.
int closef | ( | struct file * | fp, |
struct thread * | td | ||
) |
Definition at line 2237 of file kern_descrip.c.
References cap_funwrap(), and wakeup().
Referenced by do_dup(), fdcloseexec(), fdfree(), kern_close(), setugidsafety(), unp_discard(), and unp_process_defers().
|
static |
Definition at line 828 of file kern_descrip.c.
References closef(), DUP_CLOEXEC, DUP_FCNTL, DUP_FIXED, fdalloc(), fdgrowtable(), fdunused(), fdused(), getmaxfd(), knote_fdclose(), mq_fdclose, racct_set(), and wakeup().
Referenced by fdcheckstd(), kern_fcntl(), sys_dup(), and sys_dup2().
int dupfdopen | ( | struct thread * | td, |
struct filedesc * | fdp, | ||
int | indx, | ||
int | dfd, | ||
int | mode, | ||
int | error | ||
) |
Definition at line 2733 of file kern_descrip.c.
References fdunused(), and fdused().
Referenced by kern_openat().
|
static |
Definition at line 3280 of file kern_descrip.c.
References fd, export_fd_buf::fdp, fill_pipe_info(), fill_procdesc_info(), fill_pts_info(), fill_sem_info(), fill_shm_info(), fill_socket_info(), fill_vnode_info(), export_fd_buf::kif, NFFLAGS, export_fd_buf::remainder, export_fd_buf::sb, sbuf_bcat(), type, and vrele().
Referenced by kern_proc_filedesc_out().
int falloc | ( | struct thread * | td, |
struct file ** | resultfp, | ||
int * | resultfd, | ||
int | flags | ||
) |
Definition at line 1666 of file kern_descrip.c.
References falloc_noinstall(), fd, and finstall().
Referenced by do_pipe(), fork1(), kern_accept(), kern_kmq_open(), kern_socketpair(), ksem_create(), sys_fhopen(), sys_kqueue(), sys_posix_openpt(), sys_sctp_peeloff(), sys_shm_open(), and sys_socket().
int falloc_noinstall | ( | struct thread * | td, |
struct file ** | resultfp | ||
) |
Definition at line 1696 of file kern_descrip.c.
References badfileops, crhold(), file_zone, maxfiles, openfiles, ppsratecheck(), printf(), and priv_check().
Referenced by falloc(), and kern_openat().
|
static |
|
static |
Definition at line 227 of file kern_descrip.c.
References mask, NDENTRIES, and NDSLOT.
Referenced by fdunused().
int fdalloc | ( | struct thread * | td, |
int | minfd, | ||
int * | result | ||
) |
Definition at line 1547 of file kern_descrip.c.
References fd, fd_first_free(), fdgrowtable(), fdisused(), fdused(), getmaxfd(), and racct_set().
Referenced by do_dup(), fdallocn(), and finstall().
int fdallocn | ( | struct thread * | td, |
int | minfd, | ||
int * | fds, | ||
int | n | ||
) |
Definition at line 1603 of file kern_descrip.c.
References fdalloc(), fdavail(), and fdunused().
Referenced by unp_externalize().
int fdavail | ( | struct thread * | td, |
int | n | ||
) |
Definition at line 1632 of file kern_descrip.c.
References getmaxfd().
Referenced by fdallocn().
int fdcheckstd | ( | struct thread * | td | ) |
Definition at line 2195 of file kern_descrip.c.
References do_dup(), DUP_FIXED, and kern_open().
Referenced by do_execve().
void fdclose | ( | struct filedesc * | fdp, |
struct file * | fp, | ||
int | idx, | ||
struct thread * | td | ||
) |
Definition at line 2129 of file kern_descrip.c.
References fdunused().
Referenced by accept1(), do_pipe(), kern_accept(), kern_kmq_open(), kern_openat(), kern_socketpair(), ksem_create(), sys_fhopen(), sys_posix_openpt(), sys_sctp_peeloff(), sys_shm_open(), and sys_socket().
void fdcloseexec | ( | struct thread * | td | ) |
Definition at line 2146 of file kern_descrip.c.
References closef(), fdunused(), knote_fdclose(), and mq_fdclose.
Referenced by do_execve().
struct filedesc* fdcopy | ( | struct filedesc * | fdp | ) |
Definition at line 1859 of file kern_descrip.c.
References badfileops, fdgrowtable(), fdinit(), fdisused(), and fdused().
Referenced by do_fork(), and fdunshare().
|
static |
Definition at line 1801 of file kern_descrip.c.
References fdesc_mtx, free(), and freetable::ft_table.
Referenced by fdfree(), kern_proc_filedesc_out(), mountcheckdirs(), and sysctl_kern_file().
void fdfree | ( | struct thread * | td | ) |
Definition at line 1908 of file kern_descrip.c.
References closef(), fddrop(), fdesc_mtx, free(), NDFILE, NDSLOTS, racct_set(), and vrele().
Referenced by exit1(), fdunshare(), and fork_norfproc().
|
static |
Definition at line 1472 of file kern_descrip.c.
References free(), freetable::ft_table, malloc(), NDENTRIES, NDFILE, NDSLOTS, NDSLOTSIZE, and OFILESIZE.
Referenced by do_dup(), fdalloc(), and fdcopy().
|
static |
Definition at line 1788 of file kern_descrip.c.
References fdesc_mtx.
Referenced by kern_proc_filedesc_out(), mountcheckdirs(), and sysctl_kern_file().
struct filedesc* fdinit | ( | struct filedesc * | fdp | ) |
Definition at line 1755 of file kern_descrip.c.
References filedesc0::fd_fd, malloc(), and NDFILE.
Referenced by do_fork(), fdcopy(), fork_norfproc(), and proc0_init().
|
static |
Definition at line 250 of file kern_descrip.c.
Referenced by fdalloc(), fdcopy(), fdunused(), and fdused().
|
static |
Definition at line 4048 of file kern_descrip.c.
struct filedesc* fdshare | ( | struct filedesc * | fdp | ) |
Definition at line 1826 of file kern_descrip.c.
Referenced by do_fork().
|
static |
Definition at line 437 of file kern_descrip.c.
Referenced by fdunwrap(), and kern_fcntl().
void fdunshare | ( | struct proc * | p, |
struct thread * | td | ||
) |
Definition at line 1839 of file kern_descrip.c.
References fdcopy(), and fdfree().
Referenced by do_execve(), and fork_norfproc().
|
static |
Definition at line 279 of file kern_descrip.c.
References fd, fd_last_used(), fdisused(), NDBIT, and NDSLOT.
Referenced by do_dup(), dupfdopen(), fdallocn(), fdclose(), fdcloseexec(), kern_close(), and setugidsafety().
|
inlinestatic |
Definition at line 449 of file kern_descrip.c.
References cap_funwrap(), and fdtofp().
Referenced by kern_fcntl().
|
static |
Definition at line 261 of file kern_descrip.c.
References fd, fd_first_free(), fdisused(), NDBIT, and NDSLOT.
Referenced by do_dup(), dupfdopen(), fdalloc(), and fdcopy().
int fget | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct file ** | fpp | ||
) |
Definition at line 2486 of file kern_descrip.c.
References _fget().
Referenced by aio_aqueue(), getmq(), kern_fstat(), kern_ftruncate(), kern_ioctl(), kern_kevent(), kern_posix_fadvise(), kern_posix_fallocate(), kqfd_register(), kqueue_register(), ksem_get(), sys_aio_cancel(), sys_fchmod(), sys_fchown(), sys_flock(), sys_fpathconf(), and sys_lseek().
int fget_mmap | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
u_char * | maxprotp, | ||
struct file ** | fpp | ||
) |
Definition at line 2493 of file kern_descrip.c.
References _fget().
int fget_read | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct file ** | fpp | ||
) |
Definition at line 2501 of file kern_descrip.c.
References _fget().
Referenced by aio_aqueue(), getmq_read(), kern_preadv(), and kern_readv().
struct file* fget_unlocked | ( | struct filedesc * | fdp, |
int | fd | ||
) |
Definition at line 2330 of file kern_descrip.c.
Referenced by _fget(), getselfd_cap(), getsock_cap(), getvnode(), and ttyhook_register().
int fget_write | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct file ** | fpp | ||
) |
Definition at line 2508 of file kern_descrip.c.
References _fget().
Referenced by aio_aqueue(), getmq_write(), kern_pwritev(), and kern_writev().
int fgetcap | ( | struct thread * | td, |
int | fd, | ||
struct file ** | fpp | ||
) |
Definition at line 2520 of file kern_descrip.c.
References _fget(), and FGET_GETCAP.
pid_t fgetown | ( | struct sigio ** | sigiop | ) |
Definition at line 1192 of file kern_descrip.c.
Referenced by kern_accept(), kqueue_ioctl(), logioctl(), pipe_ioctl(), soo_ioctl(), sys_sctp_peeloff(), and tty_generic_ioctl().
int fgetsock | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct socket ** | spp, | ||
u_int * | fflagp | ||
) |
Definition at line 2606 of file kern_descrip.c.
References _fget().
Referenced by sys_sctp_peeloff().
int fgetvp | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct vnode ** | vpp | ||
) |
Definition at line 2557 of file kern_descrip.c.
References _fgetvp().
int fgetvp_exec | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct vnode ** | vpp | ||
) |
Definition at line 2578 of file kern_descrip.c.
References _fgetvp().
Referenced by do_execve().
int fgetvp_read | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | rights, | ||
struct vnode ** | vpp | ||
) |
Definition at line 2571 of file kern_descrip.c.
References _fgetvp().
Referenced by kern_sendfile().
int fgetvp_rights | ( | struct thread * | td, |
int | fd, | ||
cap_rights_t | need, | ||
cap_rights_t * | have, | ||
struct vnode ** | vpp | ||
) |
Definition at line 2564 of file kern_descrip.c.
References _fgetvp().
Referenced by namei().
|
static |
Definition at line 4070 of file kern_descrip.c.
References make_dev_alias(), and make_dev_credf().
struct filedesc_to_leader* filedesc_to_leader_alloc | ( | struct filedesc_to_leader * | old, |
struct filedesc * | fdp, | ||
struct proc * | leader | ||
) |
Definition at line 2882 of file kern_descrip.c.
References malloc().
Referenced by do_fork().
|
static |
Definition at line 3922 of file kern_descrip.c.
References fdesc_mtx, file_zone, mtx_init(), and sigio_lock.
|
static |
Definition at line 3738 of file kern_descrip.c.
Referenced by export_fd_to_sb().
|
static |
Definition at line 3750 of file kern_descrip.c.
Referenced by export_fd_to_sb().
|
static |
Definition at line 3727 of file kern_descrip.c.
References tty_udev().
Referenced by export_fd_to_sb().
|
static |
Definition at line 3760 of file kern_descrip.c.
References ksem_info.
Referenced by export_fd_to_sb().
|
static |
Definition at line 3779 of file kern_descrip.c.
References shm_path().
Referenced by export_fd_to_sb().
|
static |
Definition at line 3673 of file kern_descrip.c.
References free().
Referenced by export_fd_to_sb().
|
static |
Definition at line 3630 of file kern_descrip.c.
References free(), vn_fullpath(), and vntype_to_kinfo().
Referenced by export_fd_to_sb().
void finit | ( | struct file * | fp, |
u_int | flag, | ||
short | type, | ||
void * | data, | ||
struct fileops * | ops | ||
) |
Definition at line 2321 of file kern_descrip.c.
Referenced by do_pipe(), kern_accept(), kern_kmq_open(), kern_openat(), kern_socketpair(), ksem_create(), pts_alloc(), pts_alloc_external(), sys_fhopen(), sys_kqueue(), sys_sctp_peeloff(), sys_shm_open(), and sys_socket().
int finstall | ( | struct thread * | td, |
struct file * | fp, | ||
int * | fd, | ||
int | flags | ||
) |
Definition at line 1729 of file kern_descrip.c.
Referenced by falloc(), and kern_openat().
void fputsock | ( | struct socket * | so | ) |
Definition at line 2639 of file kern_descrip.c.
Referenced by sys_sctp_peeloff().
int fsetown | ( | pid_t | pgid, |
struct sigio ** | sigiop | ||
) |
Definition at line 1087 of file kern_descrip.c.
References crfree(), crhold(), free(), funsetown(), malloc(), pfind(), pgfind(), and proctree_lock.
Referenced by kern_accept(), kqueue_ioctl(), logioctl(), logopen(), pipe_ioctl(), soo_ioctl(), sys_sctp_peeloff(), and tty_generic_ioctl().
void funsetown | ( | struct sigio ** | sigiop | ) |
Definition at line 990 of file kern_descrip.c.
References crfree(), and free().
Referenced by fsetown(), kqueue_close(), logclose(), pipe_close(), soclose(), and ttydev_leave().
void funsetownlst | ( | struct sigiolst * | sigiolst | ) |
Definition at line 1026 of file kern_descrip.c.
References crfree(), and free().
Referenced by exit1(), and pgdelete().
|
static |
Definition at line 813 of file kern_descrip.c.
References lim_cur(), and maxfilesperproc.
Referenced by do_dup(), fdalloc(), and fdavail().
int invfo_chmod | ( | struct file * | fp, |
mode_t | mode, | ||
struct ucred * | active_cred, | ||
struct thread * | td | ||
) |
Definition at line 4018 of file kern_descrip.c.
int invfo_chown | ( | struct file * | fp, |
uid_t | uid, | ||
gid_t | gid, | ||
struct ucred * | active_cred, | ||
struct thread * | td | ||
) |
Definition at line 4026 of file kern_descrip.c.
|
static |
Definition at line 2068 of file kern_descrip.c.
Referenced by setugidsafety().
int kern_close | ( | struct thread * | td, |
int | fd | ||
) |
Definition at line 1222 of file kern_descrip.c.
References cap_funwrap(), closef(), fd, fdunused(), knote_fdclose(), mq_fdclose, and wakeup().
Referenced by parse_dir_md(), sys_close(), sys_closefrom(), sys_ksem_close(), sys_ksem_destroy(), and sys_socketpair().
int kern_fcntl | ( | struct thread * | td, |
int | fd, | ||
int | cmd, | ||
intptr_t | arg | ||
) |
Definition at line 469 of file kern_descrip.c.
References do_dup(), DUP_CLOEXEC, DUP_FCNTL, DUP_FIXED, fd, fdtofp(), fdunwrap(), and priv_check().
Referenced by sys_fcntl().
int kern_fstat | ( | struct thread * | td, |
int | fd, | ||
struct stat * | sbp | ||
) |
Definition at line 1372 of file kern_descrip.c.
References fget().
Referenced by sys_fstat(), and sys_nfstat().
int kern_proc_filedesc_out | ( | struct proc * | p, |
struct sbuf * | sb, | ||
ssize_t | maxlen | ||
) |
Definition at line 3394 of file kern_descrip.c.
References cap_funwrap(), export_fd_to_sb(), fddrop(), fdhold(), export_fd_buf::fdp, free(), malloc(), export_fd_buf::remainder, export_fd_buf::sb, type, and vref().
Referenced by note_procstat_files(), and sysctl_kern_proc_filedesc().
MALLOC_DECLARE | ( | M_FADVISE | ) |
|
static |
|
static |
|
static |
void mountcheckdirs | ( | struct vnode * | olddp, |
struct vnode * | newdp | ||
) |
Definition at line 2819 of file kern_descrip.c.
References allprison, allprison_lock, allproc_lock, fddrop(), fdhold(), pr, prison0, rootvnode, vref(), vrefcnt(), and vrele().
Referenced by dounmount(), and vfs_domount_first().
void setugidsafety | ( | struct thread * | td | ) |
Definition at line 2083 of file kern_descrip.c.
References closef(), fdunused(), is_unsafe(), and knote_fdclose().
Referenced by do_execve().
int sys_close | ( | struct thread * | td, |
struct close_args * | uap | ||
) |
Definition at line 1213 of file kern_descrip.c.
References close_args::fd, and kern_close().
int sys_closefrom | ( | struct thread * | td, |
struct closefrom_args * | uap | ||
) |
Definition at line 1296 of file kern_descrip.c.
References fd, kern_close(), and closefrom_args::lowfd.
int sys_dup | ( | struct thread * | td, |
struct dup_args * | uap | ||
) |
Definition at line 351 of file kern_descrip.c.
References do_dup(), and dup_args::fd.
int sys_dup2 | ( | struct thread * | td, |
struct dup2_args * | uap | ||
) |
Definition at line 334 of file kern_descrip.c.
References do_dup(), DUP_FIXED, dup2_args::from, and dup2_args::to.
int sys_fcntl | ( | struct thread * | td, |
struct fcntl_args * | uap | ||
) |
Definition at line 369 of file kern_descrip.c.
References fcntl_args::arg, fcntl_args::cmd, fcntl_args::fd, and kern_fcntl().
int sys_flock | ( | struct thread * | td, |
struct flock_args * | uap | ||
) |
Definition at line 2687 of file kern_descrip.c.
References flock_args::fd, fget(), and flock_args::how.
int sys_fpathconf | ( | struct thread * | td, |
struct fpathconf_args * | uap | ||
) |
Definition at line 1429 of file kern_descrip.c.
References async_io_version, fpathconf_args::fd, fget(), and fpathconf_args::name.
int sys_fstat | ( | struct thread * | td, |
struct fstat_args * | uap | ||
) |
Definition at line 1360 of file kern_descrip.c.
References fstat_args::fd, kern_fstat(), and fstat_args::sb.
int sys_getdtablesize | ( | struct thread * | td, |
struct getdtablesize_args * | uap | ||
) |
Definition at line 305 of file kern_descrip.c.
References lim_cur(), maxfilesperproc, and racct_get_limit().
int sys_nfstat | ( | struct thread * | td, |
struct nfstat_args * | uap | ||
) |
Definition at line 1404 of file kern_descrip.c.
References cvtnstat(), nfstat_args::fd, kern_fstat(), and nfstat_args::sb.
SYSCTL_INT | ( | _kern | , |
KERN_MAXFILESPERPROC | , | ||
maxfilesperproc | , | ||
CTLFLAG_RW | , | ||
& | maxfilesperproc, | ||
0 | , | ||
"Maximum files allowed open per process" | |||
) |
SYSCTL_INT | ( | _kern | , |
KERN_MAXFILES | , | ||
maxfiles | , | ||
CTLFLAG_RW | , | ||
& | maxfiles, | ||
0 | , | ||
"Maximum number of files" | |||
) |
SYSCTL_INT | ( | _kern | , |
OID_AUTO | , | ||
openfiles | , | ||
CTLFLAG_RD | , | ||
__DEVOLATILE(int *,&openfiles) | , | ||
0 | , | ||
"System-wide number of open files" | |||
) |
|
static |
Definition at line 2911 of file kern_descrip.c.
References allproc_lock, fddrop(), fdhold(), p_cansee(), and sysctl_wire_old_buffer().
|
static |
Definition at line 3575 of file kern_descrip.c.
References FILEDESC_SBUF_SIZE, kern_proc_filedesc_out(), name, pget(), sbuf_delete(), sbuf_finish(), and sbuf_new_for_sysctl().
|
static |
SYSCTL_PROC | ( | _kern | , |
KERN_FILE | , | ||
file | , | ||
CTLTYPE_OPAQUE| | CTLFLAG_RD, | ||
0 | , | ||
0 | , | ||
sysctl_kern_file | , | ||
" | S, | ||
xfile" | , | ||
"Entire file table" | |||
) |
SYSINIT | ( | select | , |
SI_SUB_LOCK | , | ||
SI_ORDER_FIRST | , | ||
filelistinit | , | ||
NULL | |||
) |
SYSINIT | ( | fildescdev | , |
SI_SUB_DRIVERS | , | ||
SI_ORDER_MIDDLE | , | ||
fildesc_drvinit | , | ||
NULL | |||
) |
int vntype_to_kinfo | ( | int | vtype | ) |
Definition at line 3598 of file kern_descrip.c.
References NVTYPES.
Referenced by fill_vnode_info(), and kern_proc_vmmap_out().
struct fileops badfileops |
Definition at line 4004 of file kern_descrip.c.
Referenced by _fdrop(), _fget(), falloc_noinstall(), fdcopy(), getvnode(), kern_openat(), mqf_close(), pipe_close(), soo_close(), ttyhook_register(), and vn_closefile().
|
static |
Definition at line 193 of file kern_descrip.c.
Referenced by fddrop(), fdfree(), fdhold(), and filelistinit().
|
static |
Definition at line 4063 of file kern_descrip.c.
|
static |
Definition at line 112 of file kern_descrip.c.
Referenced by _fdrop(), falloc_noinstall(), and filelistinit().
Definition at line 114 of file kern_descrip.c.
Referenced by fill_sem_info(), ksem_module_destroy(), and ksem_module_init().
void(* mq_fdclose) (struct thread *td, int fd, struct file *fp) |
Definition at line 190 of file kern_descrip.c.
Referenced by do_dup(), fdcloseexec(), kern_close(), and mqfs_init().
volatile int openfiles |
Definition at line 188 of file kern_descrip.c.
Referenced by _fdrop(), and falloc_noinstall().
struct mtx sigio_lock |
Definition at line 189 of file kern_descrip.c.
Referenced by filelistinit().