FreeBSD kernel kern code
sys_procdesc.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/procdesc.h>
#include <sys/resourcevar.h>
#include <sys/stat.h>
#include <sys/sysproto.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/ucred.h>
#include <sys/user.h>
#include <security/audit/audit.h>
#include <vm/uma.h>
Include dependency graph for sys_procdesc.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
 FEATURE (process_descriptors, "Process Descriptors")
 
 MALLOC_DEFINE (M_PROCDESC, "procdesc", "process descriptors")
 
int procdesc_find (struct thread *td, int fd, cap_rights_t *rightsp, struct proc **p)
 
pid_t procdesc_pid (struct file *fp_procdesc)
 
int kern_pdgetpid (struct thread *td, int fd, cap_rights_t *rightsp, pid_t *pidp)
 
int sys_pdgetpid (struct thread *td, struct pdgetpid_args *uap)
 
void procdesc_new (struct proc *p, int flags)
 
int procdesc_falloc (struct thread *td, struct file **resultfp, int *resultfd, int flags, struct filecaps *fcaps)
 
void procdesc_finit (struct procdesc *pdp, struct file *fp)
 
static void procdesc_free (struct procdesc *pd)
 
int procdesc_exit (struct proc *p)
 
void procdesc_reap (struct proc *p)
 
static int procdesc_close (struct file *fp, struct thread *td)
 
static int procdesc_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static void procdesc_kqops_detach (struct knote *kn)
 
static int procdesc_kqops_event (struct knote *kn, long hint)
 
static int procdesc_kqfilter (struct file *fp, struct knote *kn)
 
static int procdesc_stat (struct file *fp, struct stat *sb, struct ucred *active_cred)
 
static int procdesc_fill_kinfo (struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 

Variables

static fo_poll_t procdesc_poll
 
static fo_kqfilter_t procdesc_kqfilter
 
static fo_stat_t procdesc_stat
 
static fo_close_t procdesc_close
 
static fo_fill_kinfo_t procdesc_fill_kinfo
 
static struct fileops procdesc_ops
 
static struct filterops procdesc_kqops
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ FEATURE()

FEATURE ( process_descriptors  ,
"Process Descriptors"   
)

◆ kern_pdgetpid()

int kern_pdgetpid ( struct thread *  td,
int  fd,
cap_rights_t *  rightsp,
pid_t *  pidp 
)

Definition at line 171 of file sys_procdesc.c.

References fd, fget(), and procdesc_pid().

Referenced by sys_pdgetpid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_PROCDESC  ,
"procdesc"  ,
"process descriptors"   
)

◆ procdesc_close()

static int procdesc_close ( struct file *  fp,
struct thread *  td 
)
static

Definition at line 351 of file sys_procdesc.c.

References badfileops, kern_psignal(), proc_add_orphan(), proc_clear_orphan(), proc_reap(), proc_reparent(), procdesc_free(), and proctree_lock.

Here is the call graph for this function:

◆ procdesc_exit()

int procdesc_exit ( struct proc *  p)

Definition at line 287 of file sys_procdesc.c.

References procdesc_free(), proctree_lock, and selwakeup().

Referenced by exit1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_falloc()

int procdesc_falloc ( struct thread *  td,
struct file **  resultfp,
int *  resultfd,
int  flags,
struct filecaps *  fcaps 
)

Definition at line 237 of file sys_procdesc.c.

References falloc_caps(), and flags.

Referenced by fork1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_fill_kinfo()

static int procdesc_fill_kinfo ( struct file *  fp,
struct kinfo_file *  kif,
struct filedesc *  fdp 
)
static

Definition at line 550 of file sys_procdesc.c.

◆ procdesc_find()

int procdesc_find ( struct thread *  td,
int  fd,
cap_rights_t *  rightsp,
struct proc **  p 
)

Definition at line 124 of file sys_procdesc.c.

References fd, fget(), and proctree_lock.

Referenced by sys_pdkill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_finit()

void procdesc_finit ( struct procdesc *  pdp,
struct file *  fp 
)

Definition at line 253 of file sys_procdesc.c.

References finit(), and procdesc_ops.

Referenced by do_fork().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_free()

static void procdesc_free ( struct procdesc *  pd)
static

Definition at line 260 of file sys_procdesc.c.

References free(), and knlist_destroy().

Referenced by procdesc_close(), procdesc_exit(), and procdesc_reap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_kqfilter()

static int procdesc_kqfilter ( struct file *  fp,
struct knote kn 
)
static

Definition at line 494 of file sys_procdesc.c.

References knlist_add(), and procdesc_kqops.

Here is the call graph for this function:

◆ procdesc_kqops_detach()

static void procdesc_kqops_detach ( struct knote kn)
static

Definition at line 444 of file sys_procdesc.c.

References knlist_remove().

Here is the call graph for this function:

◆ procdesc_kqops_event()

static int procdesc_kqops_event ( struct knote kn,
long  hint 
)
static

Definition at line 453 of file sys_procdesc.c.

◆ procdesc_new()

void procdesc_new ( struct proc *  p,
int  flags 
)

Definition at line 212 of file sys_procdesc.c.

References flags, knlist_init_mtx(), and malloc().

Referenced by do_fork().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_pid()

pid_t procdesc_pid ( struct file *  fp_procdesc)

Definition at line 156 of file sys_procdesc.c.

Referenced by kern_pdgetpid().

Here is the caller graph for this function:

◆ procdesc_poll()

static int procdesc_poll ( struct file *  fp,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 424 of file sys_procdesc.c.

References selrecord().

Here is the call graph for this function:

◆ procdesc_reap()

void procdesc_reap ( struct proc *  p)

Definition at line 331 of file sys_procdesc.c.

References procdesc_free(), and proctree_lock.

Referenced by proc_reap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ procdesc_stat()

static int procdesc_stat ( struct file *  fp,
struct stat *  sb,
struct ucred *  active_cred 
)
static

Definition at line 511 of file sys_procdesc.c.

References getboottime(), proctree_lock, and timevaladd().

Here is the call graph for this function:

◆ sys_pdgetpid()

int sys_pdgetpid ( struct thread *  td,
struct pdgetpid_args *  uap 
)

Definition at line 193 of file sys_procdesc.c.

References cap_pdgetpid_rights, and kern_pdgetpid().

Here is the call graph for this function:

Variable Documentation

◆ procdesc_close

fo_close_t procdesc_close
static

Definition at line 100 of file sys_procdesc.c.

◆ procdesc_fill_kinfo

fo_fill_kinfo_t procdesc_fill_kinfo
static

Definition at line 101 of file sys_procdesc.c.

◆ procdesc_kqfilter

fo_kqfilter_t procdesc_kqfilter
static

Definition at line 98 of file sys_procdesc.c.

◆ procdesc_kqops

struct filterops procdesc_kqops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = procdesc_kqops_detach,
}
static int procdesc_kqops_event(struct knote *kn, long hint)
Definition: sys_procdesc.c:453
static void procdesc_kqops_detach(struct knote *kn)
Definition: sys_procdesc.c:444

Definition at line 487 of file sys_procdesc.c.

Referenced by procdesc_kqfilter().

◆ procdesc_ops

struct fileops procdesc_ops
static
Initial value:
= {
.fo_read = invfo_rdwr,
.fo_write = invfo_rdwr,
.fo_truncate = invfo_truncate,
.fo_ioctl = invfo_ioctl,
.fo_poll = procdesc_poll,
.fo_kqfilter = procdesc_kqfilter,
.fo_stat = procdesc_stat,
.fo_close = procdesc_close,
.fo_chmod = invfo_chmod,
.fo_chown = invfo_chown,
.fo_sendfile = invfo_sendfile,
.fo_fill_kinfo = procdesc_fill_kinfo,
.fo_flags = DFLAG_PASSABLE,
}
int invfo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td)
int invfo_truncate(struct file *fp, off_t length, 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)
int invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags, struct thread *td)
int invfo_rdwr(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
int invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
static fo_stat_t procdesc_stat
Definition: sys_procdesc.c:99
static fo_kqfilter_t procdesc_kqfilter
Definition: sys_procdesc.c:98
static fo_poll_t procdesc_poll
Definition: sys_procdesc.c:97
static fo_fill_kinfo_t procdesc_fill_kinfo
Definition: sys_procdesc.c:101
static fo_close_t procdesc_close
Definition: sys_procdesc.c:100

Definition at line 103 of file sys_procdesc.c.

Referenced by procdesc_finit().

◆ procdesc_poll

fo_poll_t procdesc_poll
static

Definition at line 97 of file sys_procdesc.c.

◆ procdesc_stat

fo_stat_t procdesc_stat
static

Definition at line 99 of file sys_procdesc.c.