FreeBSD kernel kern code
uipc_mqueue.c File Reference
#include <sys/cdefs.h>
#include "opt_compat.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/limits.h>
#include <sys/buf.h>
#include <sys/capability.h>
#include <sys/dirent.h>
#include <sys/event.h>
#include <sys/eventhandler.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/mqueue.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/posix4.h>
#include <sys/poll.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/sysproto.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
#include <machine/atomic.h>
Include dependency graph for uipc_mqueue.c:

Go to the source code of this file.

Data Structures

struct  mqfs_info
 
struct  mqfs_vdata
 
struct  mqfs_node
 
struct  mqueue_notifier
 
struct  mqueue
 
struct  mqueue_msg
 

Macros

#define MQFS_NAMELEN   NAME_MAX
 
#define MQFS_DELEN   (8 + MQFS_NAMELEN)
 
#define VTON(vp)   (((struct mqfs_vdata *)((vp)->v_data))->mv_node)
 
#define VTOMQ(vp)   ((struct mqueue *)(VTON(vp)->mn_data))
 
#define VFSTOMQFS(m)   ((struct mqfs_info *)((m)->mnt_data))
 
#define FPTOMQ(fp)
 
#define MQ_RSEL   0x01
 
#define MQ_WSEL   0x02
 

Typedefs

typedef int(* _fgetf) (struct thread *, int, cap_rights_t, struct file **)
 

Enumerations

enum  mqfs_type_t {
  mqfstype_none = 0, mqfstype_root, mqfstype_dir, mqfstype_this,
  mqfstype_parent, mqfstype_file, mqfstype_symlink
}
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 FEATURE (p1003_1b_mqueue,"POSIX P1003.1B message queues support")
 
 TAILQ_HEAD (msgq, mqueue_msg)
 
static SYSCTL_NODE (_kern, OID_AUTO, mqueue, CTLFLAG_RW, 0,"POSIX real time message queue")
 
 SYSCTL_INT (_kern_mqueue, OID_AUTO, maxmsg, CTLFLAG_RW,&maxmsg, 0,"Default maximum messages in queue")
 
 SYSCTL_INT (_kern_mqueue, OID_AUTO, maxmsgsize, CTLFLAG_RW,&maxmsgsize, 0,"Default maximum message size")
 
 SYSCTL_INT (_kern_mqueue, OID_AUTO, maxmq, CTLFLAG_RW,&maxmq, 0,"maximum message queues")
 
 SYSCTL_INT (_kern_mqueue, OID_AUTO, curmq, CTLFLAG_RW,&curmq, 0,"current message queue number")
 
static MALLOC_DEFINE (M_MQUEUEDATA,"mqdata","mqueue data")
 
static struct mqfs_nodemqfs_create_file (struct mqfs_node *parent, const char *name, int namelen, struct ucred *cred, int mode)
 
static int mqfs_destroy (struct mqfs_node *mn)
 
static void mqfs_fileno_alloc (struct mqfs_info *mi, struct mqfs_node *mn)
 
static void mqfs_fileno_free (struct mqfs_info *mi, struct mqfs_node *mn)
 
static int mqfs_allocv (struct mount *mp, struct vnode **vpp, struct mqfs_node *pn)
 
static struct mqueuemqueue_alloc (const struct mq_attr *attr)
 
static void mqueue_free (struct mqueue *mq)
 
static int mqueue_send (struct mqueue *mq, const char *msg_ptr, size_t msg_len, unsigned msg_prio, int waitok, const struct timespec *abs_timeout)
 
static int mqueue_receive (struct mqueue *mq, char *msg_ptr, size_t msg_len, unsigned *msg_prio, int waitok, const struct timespec *abs_timeout)
 
static int _mqueue_send (struct mqueue *mq, struct mqueue_msg *msg, int timo)
 
static int _mqueue_recv (struct mqueue *mq, struct mqueue_msg **msg, int timo)
 
static void mqueue_send_notification (struct mqueue *mq)
 
static void mqueue_fdclose (struct thread *td, int fd, struct file *fp)
 
static void mq_proc_exit (void *arg, struct proc *p)
 
static void filt_mqdetach (struct knote *kn)
 
static int filt_mqread (struct knote *kn, long hint)
 
static int filt_mqwrite (struct knote *kn, long hint)
 
static void mqfs_fileno_init (struct mqfs_info *mi)
 
static void mqfs_fileno_uninit (struct mqfs_info *mi)
 
static __inline struct mqfs_nodemqnode_alloc (void)
 
static __inline void mqnode_free (struct mqfs_node *node)
 
static __inline void mqnode_addref (struct mqfs_node *node)
 
static __inline void mqnode_release (struct mqfs_node *node)
 
static int mqfs_add_node (struct mqfs_node *parent, struct mqfs_node *node)
 
static struct mqfs_nodemqfs_create_node (const char *name, int namelen, struct ucred *cred, int mode, int nodetype)
 
static int mqfs_fixup_dir (struct mqfs_node *parent)
 
static int mqfs_mount (struct mount *mp)
 
static int mqfs_unmount (struct mount *mp, int mntflags)
 
static int mqfs_root (struct mount *mp, int flags, struct vnode **vpp)
 
static int mqfs_statfs (struct mount *mp, struct statfs *sbp)
 
static int mqfs_init (struct vfsconf *vfc)
 
static int mqfs_uninit (struct vfsconf *vfc)
 
static void do_recycle (void *context, int pending __unused)
 
static struct mqfs_nodemqfs_search (struct mqfs_node *pd, const char *name, int len)
 
static int mqfs_lookupx (struct vop_cachedlookup_args *ap)
 
static int mqfs_lookup (struct vop_cachedlookup_args *ap)
 
static int mqfs_create (struct vop_create_args *ap)
 
static int do_unlink (struct mqfs_node *pn, struct ucred *ucred)
 
static int mqfs_remove (struct vop_remove_args *ap)
 
static int mqfs_inactive (struct vop_inactive_args *ap)
 
static int mqfs_reclaim (struct vop_reclaim_args *ap)
 
static int mqfs_open (struct vop_open_args *ap)
 
static int mqfs_close (struct vop_close_args *ap)
 
static int mqfs_access (struct vop_access_args *ap)
 
static int mqfs_getattr (struct vop_getattr_args *ap)
 
static int mqfs_setattr (struct vop_setattr_args *ap)
 
static int mqfs_read (struct vop_read_args *ap)
 
static int mqfs_readdir (struct vop_readdir_args *ap)
 
static struct mqueue_msgmqueue_loadmsg (const char *msg_ptr, size_t msg_size, int msg_prio)
 
static int mqueue_savemsg (struct mqueue_msg *msg, char *msg_ptr, int *msg_prio)
 
static __inline void mqueue_freemsg (struct mqueue_msg *msg)
 
static __inline struct mqueue_notifiernotifier_alloc (void)
 
static __inline void notifier_free (struct mqueue_notifier *p)
 
static struct mqueue_notifiernotifier_search (struct proc *p, int fd)
 
static __inline void notifier_insert (struct proc *p, struct mqueue_notifier *nt)
 
static __inline void notifier_delete (struct proc *p, struct mqueue_notifier *nt)
 
static void notifier_remove (struct proc *p, struct mqueue *mq, int fd)
 
static int kern_kmq_open (struct thread *td, const char *upath, int flags, mode_t mode, const struct mq_attr *attr)
 
int sys_kmq_open (struct thread *td, struct kmq_open_args *uap)
 
int sys_kmq_unlink (struct thread *td, struct kmq_unlink_args *uap)
 
static int _getmq (struct thread *td, int fd, cap_rights_t rights, _fgetf func, struct file **fpp, struct mqfs_node **ppn, struct mqueue **pmq)
 
static __inline int getmq (struct thread *td, int fd, struct file **fpp, struct mqfs_node **ppn, struct mqueue **pmq)
 
static __inline int getmq_read (struct thread *td, int fd, struct file **fpp, struct mqfs_node **ppn, struct mqueue **pmq)
 
static __inline int getmq_write (struct thread *td, int fd, struct file **fpp, struct mqfs_node **ppn, struct mqueue **pmq)
 
static int kern_kmq_setattr (struct thread *td, int mqd, const struct mq_attr *attr, struct mq_attr *oattr)
 
int sys_kmq_setattr (struct thread *td, struct kmq_setattr_args *uap)
 
int sys_kmq_timedreceive (struct thread *td, struct kmq_timedreceive_args *uap)
 
int sys_kmq_timedsend (struct thread *td, struct kmq_timedsend_args *uap)
 
static int kern_kmq_notify (struct thread *td, int mqd, struct sigevent *sigev)
 
int sys_kmq_notify (struct thread *td, struct kmq_notify_args *uap)
 
static void mq_proc_exit (void *arg __unused, struct proc *p)
 
static int mqf_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int mqf_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int mqf_truncate (struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
 
static int mqf_ioctl (struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
 
static int mqf_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static int mqf_close (struct file *fp, struct thread *td)
 
static int mqf_stat (struct file *fp, struct stat *st, struct ucred *active_cred, struct thread *td)
 
static int mqf_chmod (struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
 
static int mqf_chown (struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
 
static int mqf_kqfilter (struct file *fp, struct knote *kn)
 
static int mqinit (void)
 
static int mqunload (void)
 
static int mq_modload (struct module *module, int cmd, void *arg)
 
 DECLARE_MODULE (mqueuefs, mqueuefs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
 
 MODULE_VERSION (mqueuefs, 1)
 

Variables

static int default_maxmsg = 10
 
static int default_msgsize = 1024
 
static int maxmsg = 100
 
static int maxmsgsize = 16384
 
static int maxmq = 100
 
static int curmq = 0
 
static int unloadable = 0
 
static eventhandler_tag exit_tag
 
static struct mqfs_info mqfs_data
 
static uma_zone_t mqnode_zone
 
static uma_zone_t mqueue_zone
 
static uma_zone_t mvdata_zone
 
static uma_zone_t mqnoti_zone
 
static struct vop_vector mqfs_vnodeops
 
static struct fileops mqueueops
 
struct filterops mq_rfiltops
 
struct filterops mq_wfiltops
 
static struct vfsops mqfs_vfsops
 
static struct vfsconf mqueuefs_vfsconf
 
static struct syscall_helper_data mq_syscalls []
 
static moduledata_t mqueuefs_mod
 

Macro Definition Documentation

#define FPTOMQ (   fp)
Value:
((struct mqueue *)(((struct mqfs_node *) \
(fp)->f_data)->mn_data))

Definition at line 150 of file uipc_mqueue.c.

Referenced by filt_mqdetach(), filt_mqread(), filt_mqwrite(), mq_proc_exit(), mqf_kqfilter(), mqf_poll(), and mqueue_fdclose().

#define MQ_RSEL   0x01

Definition at line 179 of file uipc_mqueue.c.

Referenced by _mqueue_send(), mqf_poll(), and mqueue_fdclose().

#define MQ_WSEL   0x02

Definition at line 180 of file uipc_mqueue.c.

Referenced by _mqueue_recv(), mqf_poll(), and mqueue_fdclose().

#define MQFS_DELEN   (8 + MQFS_NAMELEN)

Definition at line 92 of file uipc_mqueue.c.

#define MQFS_NAMELEN   NAME_MAX

Definition at line 91 of file uipc_mqueue.c.

Referenced by kern_kmq_open(), mqfs_lookupx(), mqfs_readdir(), and sys_kmq_unlink().

#define VFSTOMQFS (   m)    ((struct mqfs_info *)((m)->mnt_data))

Definition at line 149 of file uipc_mqueue.c.

Referenced by mqfs_create(), mqfs_readdir(), mqfs_reclaim(), mqfs_remove(), and mqfs_root().

#define VTOMQ (   vp)    ((struct mqueue *)(VTON(vp)->mn_data))

Definition at line 148 of file uipc_mqueue.c.

Referenced by mqfs_read().

#define VTON (   vp)    (((struct mqfs_vdata *)((vp)->v_data))->mv_node)

Typedef Documentation

typedef int(* _fgetf) (struct thread *, int, cap_rights_t, struct file **)

Definition at line 2089 of file uipc_mqueue.c.

Enumeration Type Documentation

Enumerator
mqfstype_none 
mqfstype_root 
mqfstype_dir 
mqfstype_this 
mqfstype_parent 
mqfstype_file 
mqfstype_symlink 

Definition at line 95 of file uipc_mqueue.c.

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int _getmq ( struct thread *  td,
int  fd,
cap_rights_t  rights,
_fgetf  func,
struct file **  fpp,
struct mqfs_node **  ppn,
struct mqueue **  pmq 
)
static

Definition at line 2095 of file uipc_mqueue.c.

References mqueueops.

Referenced by getmq(), getmq_read(), and getmq_write().

Here is the caller graph for this function:

static int _mqueue_recv ( struct mqueue mq,
struct mqueue_msg **  msg,
int  timo 
)
static

Definition at line 1854 of file uipc_mqueue.c.

References mqueue::mq_curmsgs, mqueue::mq_flags, mqueue::mq_msgq, mqueue::mq_mutex, mqueue::mq_notifier, mqueue::mq_receivers, mqueue::mq_senders, mqueue::mq_totalbytes, mqueue::mq_wsel, MQ_WSEL, mqueue_send_notification(), selwakeup(), and wakeup_one().

Referenced by mqueue_receive().

Here is the call graph for this function:

Here is the caller graph for this function:

static int _mqueue_send ( struct mqueue mq,
struct mqueue_msg msg,
int  timo 
)
static

Definition at line 1696 of file uipc_mqueue.c.

References mqueue::mq_curmsgs, mqueue::mq_flags, mqueue::mq_maxmsg, mqueue::mq_msgq, mqueue::mq_mutex, mqueue::mq_notifier, mqueue::mq_receivers, mqueue::mq_rsel, MQ_RSEL, mqueue::mq_senders, mqueue::mq_totalbytes, mqueue_send_notification(), selwakeup(), and wakeup_one().

Referenced by mqueue_send().

Here is the call graph for this function:

Here is the caller graph for this function:

DECLARE_MODULE ( mqueuefs  ,
mqueuefs_mod  ,
SI_SUB_VFS  ,
SI_ORDER_MIDDLE   
)
static void do_recycle ( void *  context,
int pending  __unused 
)
static

Definition at line 702 of file uipc_mqueue.c.

References vdrop(), and vrecycle().

Referenced by mqfs_allocv().

Here is the call graph for this function:

Here is the caller graph for this function:

static int do_unlink ( struct mqfs_node pn,
struct ucred *  ucred 
)
static

Definition at line 1000 of file uipc_mqueue.c.

References cache_purge(), mqfs_info::mi_lock, mqfs_node::mn_info, mqfs_node::mn_parent, mqnode_release(), parent, priv_check_cred(), taskqueue_enqueue(), and vhold().

Referenced by mqfs_remove(), and sys_kmq_unlink().

Here is the call graph for this function:

Here is the caller graph for this function:

FEATURE ( p1003_1b_mqueue  ,
"POSIX P1003.1B message queues support"   
)
static void filt_mqdetach ( struct knote kn)
static

Definition at line 2558 of file uipc_mqueue.c.

References FPTOMQ, knlist_remove(), mqueue::mq_rsel, mqueue::mq_wsel, and panic().

Here is the call graph for this function:

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

Definition at line 2571 of file uipc_mqueue.c.

References FPTOMQ, mqueue::mq_curmsgs, and mqueue::mq_mutex.

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

Definition at line 2580 of file uipc_mqueue.c.

References FPTOMQ, mqueue::mq_curmsgs, mqueue::mq_maxmsg, and mqueue::mq_mutex.

static __inline int getmq ( struct thread *  td,
int  fd,
struct file **  fpp,
struct mqfs_node **  ppn,
struct mqueue **  pmq 
)
static

Definition at line 2117 of file uipc_mqueue.c.

References _getmq(), and fget().

Referenced by kern_kmq_notify(), and kern_kmq_setattr().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline int getmq_read ( struct thread *  td,
int  fd,
struct file **  fpp,
struct mqfs_node **  ppn,
struct mqueue **  pmq 
)
static

Definition at line 2124 of file uipc_mqueue.c.

References _getmq(), and fget_read().

Referenced by sys_kmq_timedreceive().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline int getmq_write ( struct thread *  td,
int  fd,
struct file **  fpp,
struct mqfs_node **  ppn,
struct mqueue **  pmq 
)
static

Definition at line 2131 of file uipc_mqueue.c.

References _getmq(), and fget_write().

Referenced by sys_kmq_timedsend().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kern_kmq_notify ( struct thread *  td,
int  mqd,
struct sigevent *  sigev 
)
static

Definition at line 2239 of file uipc_mqueue.c.

References cap_funwrap(), getmq(), mqueue::mq_msgq, mqueue::mq_mutex, mqueue::mq_notifier, mqueue::mq_receivers, mqueue_send_notification(), notifier_alloc(), notifier_free(), notifier_insert(), notifier_remove(), notifier_search(), and sigqueue_take().

Referenced by sys_kmq_notify().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kern_kmq_open ( struct thread *  td,
const char *  upath,
int  flags,
mode_t  mode,
const struct mq_attr *  attr 
)
static

Definition at line 1947 of file uipc_mqueue.c.

References accmode, falloc(), fd, fdclose(), finit(), mqfs_info::mi_lock, mqfs_info::mi_root, mqfs_create_file(), mqfs_data, MQFS_NAMELEN, mqfs_search(), mqnode_addref(), mqueue_alloc(), mqueue_free(), mqueueops, path, and vaccess().

Referenced by sys_kmq_open().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kern_kmq_setattr ( struct thread *  td,
int  mqd,
const struct mq_attr *  attr,
struct mq_attr *  oattr 
)
static

Definition at line 2138 of file uipc_mqueue.c.

References flag, getmq(), mqueue::mq_curmsgs, mqueue::mq_maxmsg, and mqueue::mq_msgsize.

Referenced by sys_kmq_setattr().

Here is the call graph for this function:

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_MQUEUEDATA  ,
"mqdata"  ,
"mqueue data"   
)
static
MODULE_VERSION ( mqueuefs  ,
 
)
static int mq_modload ( struct module module,
int  cmd,
void *  arg 
)
static

Definition at line 2838 of file uipc_mqueue.c.

References mqinit(), mqunload(), and vfs_modevent().

Here is the call graph for this function:

static void mq_proc_exit ( void *  arg,
struct proc *  p 
)
static

Referenced by mqfs_init().

Here is the caller graph for this function:

static void mq_proc_exit ( void *arg  __unused,
struct proc *  p 
)
static

Definition at line 2383 of file uipc_mqueue.c.

References FPTOMQ, mqueue::mq_mutex, mqueueops, and notifier_remove().

Here is the call graph for this function:

static int mqf_chmod ( struct file *  fp,
mode_t  mode,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 2496 of file uipc_mqueue.c.

References mqfs_info::mi_lock, mqfs_data, and vaccess().

Here is the call graph for this function:

static int mqf_chown ( struct file *  fp,
uid_t  uid,
gid_t  gid,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 2516 of file uipc_mqueue.c.

References groupmember(), mqfs_info::mi_lock, mqfs_data, and priv_check_cred().

Here is the call graph for this function:

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

Definition at line 2463 of file uipc_mqueue.c.

References badfileops, mqfs_info::mi_lock, mqfs_data, and mqnode_release().

Here is the call graph for this function:

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

Definition at line 2428 of file uipc_mqueue.c.

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

Definition at line 2541 of file uipc_mqueue.c.

References FPTOMQ, knlist_add(), mq_rfiltops, mqueue::mq_rsel, mq_wfiltops, and mqueue::mq_wsel.

Here is the call graph for this function:

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

Definition at line 2435 of file uipc_mqueue.c.

References FPTOMQ, mqueue::mq_curmsgs, mqueue::mq_flags, mqueue::mq_maxmsg, mqueue::mq_mutex, mqueue::mq_rsel, MQ_RSEL, mqueue::mq_wsel, MQ_WSEL, and selrecord().

Here is the call graph for this function:

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

Definition at line 2406 of file uipc_mqueue.c.

static int mqf_stat ( struct file *  fp,
struct stat *  st,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 2477 of file uipc_mqueue.c.

References mqfs_info::mi_lock, and mqfs_data.

static int mqf_truncate ( struct file *  fp,
off_t  length,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 2420 of file uipc_mqueue.c.

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

Definition at line 2413 of file uipc_mqueue.c.

static int mqfs_access ( struct vop_access_args *  ap)
static

Definition at line 1146 of file uipc_mqueue.c.

References vaccess().

Here is the call graph for this function:

static int mqfs_add_node ( struct mqfs_node parent,
struct mqfs_node node 
)
static

Definition at line 411 of file uipc_mqueue.c.

References mqfs_node::mn_info, mqfs_node::mn_parent, mqfstype_dir, mqfstype_root, mqnode_addref(), and parent.

Referenced by mqfs_create_file(), and mqfs_fixup_dir().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqfs_allocv ( struct mount *  mp,
struct vnode **  vpp,
struct mqfs_node pn 
)
static
static int mqfs_close ( struct vop_close_args *  ap)
static

Definition at line 1127 of file uipc_mqueue.c.

static int mqfs_create ( struct vop_create_args *  ap)
static
static struct mqfs_node * mqfs_create_file ( struct mqfs_node parent,
const char *  name,
int  namelen,
struct ucred *  cred,
int  mode 
)
static

Definition at line 452 of file uipc_mqueue.c.

References mqfs_add_node(), mqfs_create_node(), mqfstype_file, and mqnode_free().

Referenced by kern_kmq_open(), and mqfs_create().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mqfs_node* mqfs_create_node ( const char *  name,
int  namelen,
struct ucred *  cred,
int  mode,
int  nodetype 
)
static

Definition at line 430 of file uipc_mqueue.c.

References mqfs_node::mn_name, mode, mqnode_alloc(), and vfs_timestamp().

Referenced by mqfs_create_file(), and mqfs_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqfs_destroy ( struct mqfs_node mn)
static

Definition at line 542 of file uipc_mqueue.c.

References mqfs_node::mn_info, mqfs_node::mn_parent, mqfs_fileno_free(), mqfstype_dir, mqfstype_root, mqnode_free(), mqueue_free(), and parent.

Referenced by mqfs_create(), mqfs_uninit(), and mqnode_release().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqfs_fileno_alloc ( struct mqfs_info mi,
struct mqfs_node mn 
)
static

Definition at line 304 of file uipc_mqueue.c.

References alloc_unr(), mqfs_info::mi_root, mqfs_info::mi_unrhdr, mqfs_node::mn_parent, mqfstype_dir, mqfstype_file, mqfstype_parent, mqfstype_root, mqfstype_symlink, and mqfstype_this.

Referenced by mqfs_init(), and mqfs_readdir().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqfs_fileno_free ( struct mqfs_info mi,
struct mqfs_node mn 
)
static

Definition at line 345 of file uipc_mqueue.c.

References free_unr(), mqfs_info::mi_unrhdr, mqfstype_dir, mqfstype_file, mqfstype_parent, mqfstype_root, mqfstype_symlink, and mqfstype_this.

Referenced by mqfs_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqfs_fileno_init ( struct mqfs_info mi)
static

Definition at line 279 of file uipc_mqueue.c.

References mqfs_info::mi_unrhdr, and new_unrhdr().

Referenced by mqfs_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqfs_fileno_uninit ( struct mqfs_info mi)
static

Definition at line 291 of file uipc_mqueue.c.

References delete_unrhdr(), and mqfs_info::mi_unrhdr.

Referenced by mqfs_uninit().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqfs_fixup_dir ( struct mqfs_node parent)
static

Definition at line 469 of file uipc_mqueue.c.

References mqfs_node::mn_name, mqfs_add_node(), mqfstype_parent, mqfstype_this, mqnode_alloc(), and mqnode_free().

Referenced by mqfs_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqfs_getattr ( struct vop_getattr_args *  ap)
static

Definition at line 1173 of file uipc_mqueue.c.

References VTON.

static int mqfs_inactive ( struct vop_inactive_args *  ap)
static

Definition at line 1063 of file uipc_mqueue.c.

References vrecycle(), and VTON.

Here is the call graph for this function:

static int mqfs_init ( struct vfsconf vfc)
static
static int mqfs_lookup ( struct vop_cachedlookup_args *  ap)
static

Definition at line 937 of file uipc_mqueue.c.

References mqfs_lookupx().

Here is the call graph for this function:

static int mqfs_lookupx ( struct vop_cachedlookup_args *  ap)
static

Definition at line 819 of file uipc_mqueue.c.

References cache_enter(), mqfs_info::mi_lock, mqfs_node::mn_info, mqfs_node::mn_parent, mqfs_allocv(), MQFS_NAMELEN, mqfs_search(), mqnode_addref(), mqnode_release(), and VTON.

Referenced by mqfs_lookup().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqfs_mount ( struct mount *  mp)
static

Definition at line 575 of file uipc_mqueue.c.

References mqfs_data, vfs_getnewfsid(), and vfs_mountedfrom().

Here is the call graph for this function:

static int mqfs_open ( struct vop_open_args *  ap)
static

Definition at line 1111 of file uipc_mqueue.c.

static int mqfs_read ( struct vop_read_args *  ap)
static

Definition at line 1315 of file uipc_mqueue.c.

References buf, mqueue::mq_curmsgs, mqueue::mq_maxmsg, mqueue::mq_msgsize, mqueue::mq_totalbytes, snprintf(), uiomove_frombuf(), VTOMQ, and VTON.

Here is the call graph for this function:

static int mqfs_readdir ( struct vop_readdir_args *  ap)
static
static int mqfs_reclaim ( struct vop_reclaim_args *  ap)
static

Definition at line 1081 of file uipc_mqueue.c.

References mqfs_info::mi_lock, mqnode_release(), and VFSTOMQFS.

Here is the call graph for this function:

static int mqfs_remove ( struct vop_remove_args *  ap)
static

Definition at line 1040 of file uipc_mqueue.c.

References do_unlink(), mqfs_info::mi_lock, VFSTOMQFS, and VTON.

Here is the call graph for this function:

static int mqfs_root ( struct mount *  mp,
int  flags,
struct vnode **  vpp 
)
static

Definition at line 618 of file uipc_mqueue.c.

References mqfs_info::mi_root, mqfs_allocv(), and VFSTOMQFS.

Here is the call graph for this function:

static struct mqfs_node* mqfs_search ( struct mqfs_node pd,
const char *  name,
int  len 
)
static

Definition at line 802 of file uipc_mqueue.c.

References mqfs_info::mi_lock, mqfs_node::mn_info, and mqfs_node::mn_name.

Referenced by kern_kmq_open(), mqfs_lookupx(), and sys_kmq_unlink().

Here is the caller graph for this function:

static int mqfs_setattr ( struct vop_setattr_args *  ap)
static

Definition at line 1214 of file uipc_mqueue.c.

References groupmember(), priv_check(), vfs_timestamp(), and VTON.

Here is the call graph for this function:

static int mqfs_statfs ( struct mount *  mp,
struct statfs *  sbp 
)
static

Definition at line 632 of file uipc_mqueue.c.

static int mqfs_uninit ( struct vfsconf vfc)
static

Definition at line 679 of file uipc_mqueue.c.

References mqfs_info::mi_lock, mqfs_info::mi_root, mqfs_data, mqfs_destroy(), mqfs_fileno_uninit(), and sx_destroy().

Here is the call graph for this function:

static int mqfs_unmount ( struct mount *  mp,
int  mntflags 
)
static

Definition at line 605 of file uipc_mqueue.c.

References vflush().

Here is the call graph for this function:

static int mqinit ( void  )
static

Definition at line 2811 of file uipc_mqueue.c.

References syscall_helper_register().

Referenced by mq_modload().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline void mqnode_addref ( struct mqfs_node node)
static

Definition at line 379 of file uipc_mqueue.c.

Referenced by kern_kmq_open(), mqfs_add_node(), mqfs_allocv(), mqfs_create(), and mqfs_lookupx().

Here is the caller graph for this function:

static __inline struct mqfs_node* mqnode_alloc ( void  )
static

Definition at line 367 of file uipc_mqueue.c.

Referenced by mqfs_create_node(), and mqfs_fixup_dir().

Here is the caller graph for this function:

static __inline void mqnode_free ( struct mqfs_node node)
static

Definition at line 373 of file uipc_mqueue.c.

Referenced by mqfs_create_file(), mqfs_destroy(), and mqfs_fixup_dir().

Here is the caller graph for this function:

static __inline void mqnode_release ( struct mqfs_node node)
static

Definition at line 385 of file uipc_mqueue.c.

References mqfs_info::mi_lock, mqfs_node::mn_info, mqfs_destroy(), mqfstype_dir, and mqfstype_root.

Referenced by do_unlink(), mqf_close(), mqfs_create(), mqfs_lookupx(), and mqfs_reclaim().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mqueue * mqueue_alloc ( const struct mq_attr *  attr)
static

Definition at line 1529 of file uipc_mqueue.c.

References default_maxmsg, default_msgsize, knlist_init_mtx(), mqueue::mq_maxmsg, mqueue::mq_msgq, mqueue::mq_msgsize, mqueue::mq_mutex, mqueue::mq_rsel, mqueue::mq_wsel, and mtx_init().

Referenced by kern_kmq_open(), and mqfs_create().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqueue_fdclose ( struct thread *  td,
int  fd,
struct file *  fp 
)
static

Definition at line 2356 of file uipc_mqueue.c.

References FPTOMQ, mqueue::mq_flags, mqueue::mq_mutex, mqueue::mq_rsel, MQ_RSEL, mqueue::mq_wsel, MQ_WSEL, mqueueops, notifier_remove(), and selwakeup().

Referenced by mqfs_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqueue_free ( struct mqueue mq)
static

Definition at line 1555 of file uipc_mqueue.c.

References free(), knlist_destroy(), mqueue::mq_msgq, mqueue::mq_mutex, mqueue::mq_rsel, mqueue::mq_wsel, mtx_destroy(), and seldrain().

Referenced by kern_kmq_open(), mqfs_create(), and mqfs_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline void mqueue_freemsg ( struct mqueue_msg msg)
static

Definition at line 1616 of file uipc_mqueue.c.

References free().

Referenced by mqueue_receive(), and mqueue_send().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mqueue_msg* mqueue_loadmsg ( const char *  msg_ptr,
size_t  msg_size,
int  msg_prio 
)
static

Definition at line 1577 of file uipc_mqueue.c.

References free(), and malloc().

Referenced by mqueue_send().

Here is the call graph for this function:

Here is the caller graph for this function:

int mqueue_receive ( struct mqueue mq,
char *  msg_ptr,
size_t  msg_len,
unsigned *  msg_prio,
int  waitok,
const struct timespec *  abs_timeout 
)
static

Definition at line 1783 of file uipc_mqueue.c.

References _mqueue_recv(), getnanotime(), mqueue_freemsg(), mqueue_savemsg(), and tvtohz().

Referenced by sys_kmq_timedreceive().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqueue_savemsg ( struct mqueue_msg msg,
char *  msg_ptr,
int *  msg_prio 
)
static

Definition at line 1601 of file uipc_mqueue.c.

Referenced by mqueue_receive().

Here is the caller graph for this function:

int mqueue_send ( struct mqueue mq,
const char *  msg_ptr,
size_t  msg_len,
unsigned  msg_prio,
int  waitok,
const struct timespec *  abs_timeout 
)
static

Definition at line 1627 of file uipc_mqueue.c.

References _mqueue_send(), getnanotime(), mqueue::mq_msgsize, mqueue_freemsg(), mqueue_loadmsg(), and tvtohz().

Referenced by sys_kmq_timedsend().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mqueue_send_notification ( struct mqueue mq)
static

Definition at line 1752 of file uipc_mqueue.c.

References mqueue::mq_mutex, mqueue::mq_notifier, sigev_findtd(), and tdsendsignal().

Referenced by _mqueue_recv(), _mqueue_send(), and kern_kmq_notify().

Here is the call graph for this function:

Here is the caller graph for this function:

static int mqunload ( void  )
static

Definition at line 2827 of file uipc_mqueue.c.

References syscall_helper_unregister().

Referenced by mq_modload().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline struct mqueue_notifier* notifier_alloc ( void  )
static

Definition at line 1893 of file uipc_mqueue.c.

Referenced by kern_kmq_notify().

Here is the caller graph for this function:

static __inline void notifier_delete ( struct proc *  p,
struct mqueue_notifier nt 
)
static

Definition at line 1923 of file uipc_mqueue.c.

References notifier_free().

Referenced by notifier_remove().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline void notifier_free ( struct mqueue_notifier p)
static

Definition at line 1899 of file uipc_mqueue.c.

Referenced by kern_kmq_notify(), and notifier_delete().

Here is the caller graph for this function:

static __inline void notifier_insert ( struct proc *  p,
struct mqueue_notifier nt 
)
static

Definition at line 1917 of file uipc_mqueue.c.

Referenced by kern_kmq_notify().

Here is the caller graph for this function:

static void notifier_remove ( struct proc *  p,
struct mqueue mq,
int  fd 
)
static

Definition at line 1930 of file uipc_mqueue.c.

References mqueue::mq_mutex, mqueue::mq_notifier, notifier_delete(), notifier_search(), and sigqueue_take().

Referenced by kern_kmq_notify(), mq_proc_exit(), and mqueue_fdclose().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mqueue_notifier* notifier_search ( struct proc *  p,
int  fd 
)
static

Definition at line 1905 of file uipc_mqueue.c.

Referenced by kern_kmq_notify(), and notifier_remove().

Here is the caller graph for this function:

int sys_kmq_notify ( struct thread *  td,
struct kmq_notify_args *  uap 
)

Definition at line 2339 of file uipc_mqueue.c.

References kern_kmq_notify().

Here is the call graph for this function:

int sys_kmq_open ( struct thread *  td,
struct kmq_open_args *  uap 
)

Definition at line 2044 of file uipc_mqueue.c.

References kern_kmq_open().

Here is the call graph for this function:

int sys_kmq_setattr ( struct thread *  td,
struct kmq_setattr_args *  uap 
)

Definition at line 2168 of file uipc_mqueue.c.

References kern_kmq_setattr().

Here is the call graph for this function:

int sys_kmq_timedreceive ( struct thread *  td,
struct kmq_timedreceive_args *  uap 
)

Definition at line 2188 of file uipc_mqueue.c.

References getmq_read(), and mqueue_receive().

Here is the call graph for this function:

int sys_kmq_timedsend ( struct thread *  td,
struct kmq_timedsend_args *  uap 
)

Definition at line 2214 of file uipc_mqueue.c.

References getmq_write(), and mqueue_send().

Here is the call graph for this function:

int sys_kmq_unlink ( struct thread *  td,
struct kmq_unlink_args *  uap 
)

Definition at line 2065 of file uipc_mqueue.c.

References do_unlink(), mqfs_info::mi_lock, mqfs_info::mi_root, mqfs_data, MQFS_NAMELEN, mqfs_search(), and path.

Here is the call graph for this function:

SYSCTL_INT ( _kern_mqueue  ,
OID_AUTO  ,
maxmsg  ,
CTLFLAG_RW  ,
maxmsg,
,
"Default maximum messages in queue"   
)
SYSCTL_INT ( _kern_mqueue  ,
OID_AUTO  ,
maxmsgsize  ,
CTLFLAG_RW  ,
maxmsgsize,
,
"Default maximum message size"   
)
SYSCTL_INT ( _kern_mqueue  ,
OID_AUTO  ,
maxmq  ,
CTLFLAG_RW  ,
maxmq,
,
"maximum message queues"   
)
SYSCTL_INT ( _kern_mqueue  ,
OID_AUTO  ,
curmq  ,
CTLFLAG_RW  ,
curmq,
,
"current message queue number"   
)
static SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
mqueue  ,
CTLFLAG_RW  ,
,
"POSIX real time message queue"   
)
static
TAILQ_HEAD ( msgq  ,
mqueue_msg   
)

Variable Documentation

int curmq = 0
static

Definition at line 204 of file uipc_mqueue.c.

int default_maxmsg = 10
static

Definition at line 192 of file uipc_mqueue.c.

Referenced by mqueue_alloc().

int default_msgsize = 1024
static

Definition at line 193 of file uipc_mqueue.c.

Referenced by mqueue_alloc().

eventhandler_tag exit_tag
static

Definition at line 210 of file uipc_mqueue.c.

int maxmq = 100
static

Definition at line 201 of file uipc_mqueue.c.

int maxmsg = 100
static

Definition at line 195 of file uipc_mqueue.c.

int maxmsgsize = 16384
static

Definition at line 198 of file uipc_mqueue.c.

struct filterops mq_rfiltops
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_mqdetach,
.f_event = filt_mqread,
}
static void filt_mqdetach(struct knote *kn)
Definition: uipc_mqueue.c:2558
static int filt_mqread(struct knote *kn, long hint)
Definition: uipc_mqueue.c:2571

Definition at line 264 of file uipc_mqueue.c.

Referenced by mqf_kqfilter().

struct syscall_helper_data mq_syscalls[]
static
Initial value:
= {
SYSCALL_INIT_HELPER(kmq_open),
SYSCALL_INIT_HELPER(kmq_setattr),
SYSCALL_INIT_HELPER(kmq_timedsend),
SYSCALL_INIT_HELPER(kmq_timedreceive),
SYSCALL_INIT_HELPER(kmq_notify),
SYSCALL_INIT_HELPER(kmq_unlink),
SYSCALL_INIT_LAST
}

Definition at line 2638 of file uipc_mqueue.c.

struct filterops mq_wfiltops
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_mqdetach,
.f_event = filt_mqwrite,
}
static void filt_mqdetach(struct knote *kn)
Definition: uipc_mqueue.c:2558
static int filt_mqwrite(struct knote *kn, long hint)
Definition: uipc_mqueue.c:2580

Definition at line 269 of file uipc_mqueue.c.

Referenced by mqf_kqfilter().

struct mqfs_info mqfs_data
static
struct vfsops mqfs_vfsops
static
Initial value:
= {
.vfs_init = mqfs_init,
.vfs_uninit = mqfs_uninit,
.vfs_mount = mqfs_mount,
.vfs_unmount = mqfs_unmount,
.vfs_root = mqfs_root,
.vfs_statfs = mqfs_statfs,
}
static int mqfs_init(struct vfsconf *vfc)
Definition: uipc_mqueue.c:642
static int mqfs_mount(struct mount *mp)
Definition: uipc_mqueue.c:575
static int mqfs_unmount(struct mount *mp, int mntflags)
Definition: uipc_mqueue.c:605
static int mqfs_statfs(struct mount *mp, struct statfs *sbp)
Definition: uipc_mqueue.c:632
static int mqfs_uninit(struct vfsconf *vfc)
Definition: uipc_mqueue.c:679
static int mqfs_root(struct mount *mp, int flags, struct vnode **vpp)
Definition: uipc_mqueue.c:618

Definition at line 2621 of file uipc_mqueue.c.

static struct vop_vector mqfs_vnodeops
static
Initial value:
= {
.vop_default = &default_vnodeops,
.vop_access = mqfs_access,
.vop_cachedlookup = mqfs_lookup,
.vop_lookup = vfs_cache_lookup,
.vop_reclaim = mqfs_reclaim,
.vop_create = mqfs_create,
.vop_remove = mqfs_remove,
.vop_inactive = mqfs_inactive,
.vop_open = mqfs_open,
.vop_close = mqfs_close,
.vop_getattr = mqfs_getattr,
.vop_setattr = mqfs_setattr,
.vop_read = mqfs_read,
.vop_write = VOP_EOPNOTSUPP,
.vop_readdir = mqfs_readdir,
.vop_mkdir = VOP_EOPNOTSUPP,
.vop_rmdir = VOP_EOPNOTSUPP
}
int vfs_cache_lookup(struct vop_lookup_args *ap)
Definition: vfs_cache.c:1008
static int mqfs_close(struct vop_close_args *ap)
Definition: uipc_mqueue.c:1127
static int mqfs_read(struct vop_read_args *ap)
Definition: uipc_mqueue.c:1315
static int mqfs_remove(struct vop_remove_args *ap)
Definition: uipc_mqueue.c:1040
static int mqfs_reclaim(struct vop_reclaim_args *ap)
Definition: uipc_mqueue.c:1081
static int mqfs_lookup(struct vop_cachedlookup_args *ap)
Definition: uipc_mqueue.c:937
struct vop_vector default_vnodeops
Definition: vfs_default.c:99
static int mqfs_setattr(struct vop_setattr_args *ap)
Definition: uipc_mqueue.c:1214
static int mqfs_access(struct vop_access_args *ap)
Definition: uipc_mqueue.c:1146
static int mqfs_create(struct vop_create_args *ap)
Definition: uipc_mqueue.c:958
static int mqfs_readdir(struct vop_readdir_args *ap)
Definition: uipc_mqueue.c:1357
static int mqfs_open(struct vop_open_args *ap)
Definition: uipc_mqueue.c:1111
static int mqfs_getattr(struct vop_getattr_args *ap)
Definition: uipc_mqueue.c:1173
static int mqfs_inactive(struct vop_inactive_args *ap)
Definition: uipc_mqueue.c:1063

Definition at line 218 of file uipc_mqueue.c.

Referenced by mqfs_allocv().

uma_zone_t mqnode_zone
static

Definition at line 214 of file uipc_mqueue.c.

uma_zone_t mqnoti_zone
static

Definition at line 217 of file uipc_mqueue.c.

uma_zone_t mqueue_zone
static

Definition at line 215 of file uipc_mqueue.c.

moduledata_t mqueuefs_mod
static
Initial value:
= {
"mqueuefs",
}
static struct vfsconf mqueuefs_vfsconf
Definition: uipc_mqueue.c:2630
static int mq_modload(struct module *module, int cmd, void *arg)
Definition: uipc_mqueue.c:2838

Definition at line 2861 of file uipc_mqueue.c.

struct vfsconf mqueuefs_vfsconf
static
Initial value:
= {
.vfc_version = VFS_VERSION,
.vfc_name = "mqueuefs",
.vfc_vfsops = &mqfs_vfsops,
.vfc_typenum = -1,
.vfc_flags = VFCF_SYNTHETIC
}
static struct vfsops mqfs_vfsops
Definition: uipc_mqueue.c:2621

Definition at line 2630 of file uipc_mqueue.c.

static struct fileops mqueueops
static
Initial value:
= {
.fo_read = mqf_read,
.fo_write = mqf_write,
.fo_truncate = mqf_truncate,
.fo_ioctl = mqf_ioctl,
.fo_poll = mqf_poll,
.fo_kqfilter = mqf_kqfilter,
.fo_stat = mqf_stat,
.fo_chmod = mqf_chmod,
.fo_chown = mqf_chown,
.fo_close = mqf_close
}
static int mqf_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
Definition: uipc_mqueue.c:2413
static int mqf_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2428
static int mqf_close(struct file *fp, struct thread *td)
Definition: uipc_mqueue.c:2463
static int mqf_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2516
static int mqf_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2496
static int mqf_read(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
Definition: uipc_mqueue.c:2406
static int mqf_kqfilter(struct file *fp, struct knote *kn)
Definition: uipc_mqueue.c:2541
static int mqf_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2435
static int mqf_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2420
static int mqf_stat(struct file *fp, struct stat *st, struct ucred *active_cred, struct thread *td)
Definition: uipc_mqueue.c:2477

Definition at line 219 of file uipc_mqueue.c.

Referenced by _getmq(), kern_kmq_open(), mq_proc_exit(), and mqueue_fdclose().

uma_zone_t mvdata_zone
static

Definition at line 216 of file uipc_mqueue.c.

int unloadable = 0
static

Definition at line 207 of file uipc_mqueue.c.

Referenced by accept_filt_generic_mod_event().