FreeBSD kernel kern code
sys_eventfd.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/filio.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <sys/event.h>
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/selinfo.h>
#include <sys/eventfd.h>
#include <security/audit/audit.h>
Include dependency graph for sys_eventfd.c:

Go to the source code of this file.

Data Structures

struct  eventfd
 

Functions

 __FBSDID ("$FreeBSD$")
 
 _Static_assert (EFD_CLOEXEC==O_CLOEXEC, "Mismatched EFD_CLOEXEC")
 
 _Static_assert (EFD_NONBLOCK==O_NONBLOCK, "Mismatched EFD_NONBLOCK")
 
 MALLOC_DEFINE (M_EVENTFD, "eventfd", "eventfd structures")
 
static void filt_eventfddetach (struct knote *kn)
 
static int filt_eventfdread (struct knote *kn, long hint)
 
static int filt_eventfdwrite (struct knote *kn, long hint)
 
int eventfd_create_file (struct thread *td, struct file *fp, uint32_t initval, int flags)
 
static int eventfd_close (struct file *fp, struct thread *td)
 
static int eventfd_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int eventfd_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int eventfd_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static int eventfd_kqfilter (struct file *fp, struct knote *kn)
 
static int eventfd_ioctl (struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
 
static int eventfd_stat (struct file *fp, struct stat *st, struct ucred *active_cred)
 
static int eventfd_fill_kinfo (struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 

Variables

static fo_rdwr_t eventfd_read
 
static fo_rdwr_t eventfd_write
 
static fo_ioctl_t eventfd_ioctl
 
static fo_poll_t eventfd_poll
 
static fo_kqfilter_t eventfd_kqfilter
 
static fo_stat_t eventfd_stat
 
static fo_close_t eventfd_close
 
static fo_fill_kinfo_t eventfd_fill_kinfo
 
static struct fileops eventfdops
 
static struct filterops eventfd_rfiltops
 
static struct filterops eventfd_wfiltops
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _Static_assert() [1/2]

_Static_assert ( EFD_CLOEXEC  = =O_CLOEXEC,
"Mismatched EFD_CLOEXEC"   
)

◆ _Static_assert() [2/2]

_Static_assert ( EFD_NONBLOCK  = =O_NONBLOCK,
"Mismatched EFD_NONBLOCK"   
)

◆ eventfd_close()

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

Definition at line 133 of file sys_eventfd.c.

References eventfd::efd_lock, eventfd::efd_sel, free(), knlist_destroy(), and seldrain().

Here is the call graph for this function:

◆ eventfd_create_file()

int eventfd_create_file ( struct thread *  td,
struct file *  fp,
uint32_t  initval,
int  flags 
)

Definition at line 109 of file sys_eventfd.c.

References eventfd::efd_count, eventfd::efd_flags, eventfd::efd_lock, eventfd::efd_sel, eventfdops, finit(), flags, knlist_init_mtx(), and malloc().

Referenced by kern_specialfd().

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

◆ eventfd_fill_kinfo()

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

Definition at line 336 of file sys_eventfd.c.

References eventfd::efd_count, eventfd::efd_flags, and eventfd::efd_lock.

◆ eventfd_ioctl()

static int eventfd_ioctl ( struct file *  fp,
u_long  cmd,
void *  data,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 315 of file sys_eventfd.c.

◆ eventfd_kqfilter()

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

Definition at line 254 of file sys_eventfd.c.

References eventfd::efd_lock, eventfd::efd_sel, eventfd_rfiltops, eventfd_wfiltops, and knlist_add().

Here is the call graph for this function:

◆ eventfd_poll()

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

Definition at line 232 of file sys_eventfd.c.

References eventfd::efd_count, eventfd::efd_lock, eventfd::efd_sel, and selrecord().

Here is the call graph for this function:

◆ eventfd_read()

static int eventfd_read ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 146 of file sys_eventfd.c.

References count, eventfd::efd_count, eventfd::efd_flags, eventfd::efd_lock, eventfd::efd_sel, selwakeup(), uiomove(), and wakeup().

Here is the call graph for this function:

◆ eventfd_stat()

static int eventfd_stat ( struct file *  fp,
struct stat *  st,
struct ucred *  active_cred 
)
static

Definition at line 328 of file sys_eventfd.c.

References st.

◆ eventfd_write()

static int eventfd_write ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 188 of file sys_eventfd.c.

References count, eventfd::efd_count, eventfd::efd_lock, eventfd::efd_sel, selwakeup(), uiomove(), and wakeup().

Here is the call graph for this function:

◆ filt_eventfddetach()

static void filt_eventfddetach ( struct knote kn)
static

Definition at line 279 of file sys_eventfd.c.

References eventfd::efd_lock, eventfd::efd_sel, and knlist_remove().

Here is the call graph for this function:

◆ filt_eventfdread()

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

Definition at line 289 of file sys_eventfd.c.

References eventfd::efd_count, and eventfd::efd_lock.

◆ filt_eventfdwrite()

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

Definition at line 302 of file sys_eventfd.c.

References eventfd::efd_count, and eventfd::efd_lock.

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_EVENTFD  ,
"eventfd"  ,
"eventfd structures"   
)

Variable Documentation

◆ eventfd_close

fo_close_t eventfd_close
static

Definition at line 66 of file sys_eventfd.c.

◆ eventfd_fill_kinfo

fo_fill_kinfo_t eventfd_fill_kinfo
static

Definition at line 67 of file sys_eventfd.c.

◆ eventfd_ioctl

fo_ioctl_t eventfd_ioctl
static

Definition at line 62 of file sys_eventfd.c.

◆ eventfd_kqfilter

fo_kqfilter_t eventfd_kqfilter
static

Definition at line 64 of file sys_eventfd.c.

◆ eventfd_poll

fo_poll_t eventfd_poll
static

Definition at line 63 of file sys_eventfd.c.

◆ eventfd_read

fo_rdwr_t eventfd_read
static

Definition at line 60 of file sys_eventfd.c.

◆ eventfd_rfiltops

struct filterops eventfd_rfiltops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_eventfddetach,
.f_event = filt_eventfdread
}
static void filt_eventfddetach(struct knote *kn)
Definition: sys_eventfd.c:279
static int filt_eventfdread(struct knote *kn, long hint)
Definition: sys_eventfd.c:289

Definition at line 89 of file sys_eventfd.c.

Referenced by eventfd_kqfilter().

◆ eventfd_stat

fo_stat_t eventfd_stat
static

Definition at line 65 of file sys_eventfd.c.

◆ eventfd_wfiltops

struct filterops eventfd_wfiltops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_eventfddetach,
.f_event = filt_eventfdwrite
}
static int filt_eventfdwrite(struct knote *kn, long hint)
Definition: sys_eventfd.c:302

Definition at line 95 of file sys_eventfd.c.

Referenced by eventfd_kqfilter().

◆ eventfd_write

fo_rdwr_t eventfd_write
static

Definition at line 61 of file sys_eventfd.c.

◆ eventfdops

struct fileops eventfdops
static
Initial value:
= {
.fo_read = eventfd_read,
.fo_write = eventfd_write,
.fo_truncate = invfo_truncate,
.fo_ioctl = eventfd_ioctl,
.fo_poll = eventfd_poll,
.fo_kqfilter = eventfd_kqfilter,
.fo_stat = eventfd_stat,
.fo_close = eventfd_close,
.fo_chmod = invfo_chmod,
.fo_chown = invfo_chown,
.fo_sendfile = invfo_sendfile,
.fo_fill_kinfo = eventfd_fill_kinfo,
.fo_flags = DFLAG_PASSABLE
}
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_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
static fo_close_t eventfd_close
Definition: sys_eventfd.c:66
static fo_rdwr_t eventfd_read
Definition: sys_eventfd.c:60
static fo_fill_kinfo_t eventfd_fill_kinfo
Definition: sys_eventfd.c:67
static fo_stat_t eventfd_stat
Definition: sys_eventfd.c:65
static fo_poll_t eventfd_poll
Definition: sys_eventfd.c:63
static fo_ioctl_t eventfd_ioctl
Definition: sys_eventfd.c:62
static fo_kqfilter_t eventfd_kqfilter
Definition: sys_eventfd.c:64
static fo_rdwr_t eventfd_write
Definition: sys_eventfd.c:61

Definition at line 69 of file sys_eventfd.c.

Referenced by eventfd_create_file().