FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/devctl.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/vnode.h>
#include <sys/queue.h>
#include <sys/poll.h>
#include <sys/sx.h>
#include <sys/ctype.h>
#include <sys/ucred.h>
#include <sys/taskqueue.h>
#include <machine/stdarg.h>
#include <fs/devfs/devfs_int.h>
#include <vm/vm.h>
#include "opt_ddb.h"
Go to the source code of this file.
Data Structures | |
struct | clonedevs |
Macros | |
#define | dead_open (d_open_t *)enxio |
#define | dead_close (d_close_t *)enxio |
#define | dead_read (d_read_t *)enxio |
#define | dead_write (d_write_t *)enxio |
#define | dead_ioctl (d_ioctl_t *)enxio |
#define | dead_poll (d_poll_t *)enodev |
#define | dead_mmap (d_mmap_t *)enodev |
#define | dead_dump (dumper_t *)enxio |
#define | dead_kqfilter (d_kqfilter_t *)enxio |
#define | dead_mmap_single (d_mmap_single_t *)enodev |
#define | null_open (d_open_t *)nullop |
#define | null_close (d_close_t *)nullop |
#define | no_read (d_read_t *)enodev |
#define | no_write (d_write_t *)enodev |
#define | no_ioctl (d_ioctl_t *)enodev |
#define | no_mmap (d_mmap_t *)enodev |
#define | no_kqfilter (d_kqfilter_t *)enodev |
#define | no_mmap_single (d_mmap_single_t *)enodev |
#define | no_dump (dumper_t *)enodev |
#define | FIXUP(member, noop, giant) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_DEVT, "cdev", "cdev storage") |
static void | destroy_devl (struct cdev *dev) |
static int | destroy_dev_sched_cbl (struct cdev *dev, void(*cb)(void *), void *arg) |
static void | destroy_dev_tq (void *ctx, int pending) |
static int | make_dev_credv (int flags, struct cdev **dres, struct cdevsw *devsw, int unit, struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt, va_list ap) |
static | SLIST_HEAD (free_cdevsw, cdevsw) |
static void | dev_unlock_and_free (void) |
static void | dev_free_devlocked (struct cdev *cdev) |
static void | cdevsw_free_devlocked (struct cdevsw *csw) |
void | dev_unlock (void) |
void | dev_ref (struct cdev *dev) |
void | dev_refl (struct cdev *dev) |
void | dev_rel (struct cdev *dev) |
struct cdevsw * | dev_refthread (struct cdev *dev, int *ref) |
struct cdevsw * | devvn_refthread (struct vnode *vp, struct cdev **devp, int *ref) |
void | dev_relthread (struct cdev *dev, int ref) |
int | nullop (void) |
int | eopnotsupp (void) |
static int | enxio (void) |
static int | enodev (void) |
static void | dead_strategy (struct bio *bp) |
static void | no_strategy (struct bio *bp) |
static int | no_poll (struct cdev *dev __unused, int events, struct thread *td __unused) |
static int | giant_open (struct cdev *dev, int oflags, int devtype, struct thread *td) |
static int | giant_fdopen (struct cdev *dev, int oflags, struct thread *td, struct file *fp) |
static int | giant_close (struct cdev *dev, int fflag, int devtype, struct thread *td) |
static void | giant_strategy (struct bio *bp) |
static int | giant_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) |
static int | giant_read (struct cdev *dev, struct uio *uio, int ioflag) |
static int | giant_write (struct cdev *dev, struct uio *uio, int ioflag) |
static int | giant_poll (struct cdev *dev, int events, struct thread *td) |
static int | giant_kqfilter (struct cdev *dev, struct knote *kn) |
static int | giant_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) |
static int | giant_mmap_single (struct cdev *dev, vm_ooffset_t *offset, vm_size_t size, vm_object_t *object, int nprot) |
static void | notify (struct cdev *dev, const char *ev, int flags) |
static void | notify_create (struct cdev *dev, int flags) |
static void | notify_destroy (struct cdev *dev) |
static struct cdev * | newdev (struct make_dev_args *args, struct cdev *si) |
static void | fini_cdevsw (struct cdevsw *devsw) |
static int | prep_cdevsw (struct cdevsw *devsw, int flags) |
static int | prep_devname (struct cdev *dev, const char *fmt, va_list ap) |
void | make_dev_args_init_impl (struct make_dev_args *args, size_t sz) |
static int | make_dev_sv (struct make_dev_args *args1, struct cdev **dres, const char *fmt, va_list ap) |
int | make_dev_s (struct make_dev_args *args, struct cdev **dres, const char *fmt,...) |
struct cdev * | make_dev (struct cdevsw *devsw, int unit, uid_t uid, gid_t gid, int mode, const char *fmt,...) |
struct cdev * | make_dev_cred (struct cdevsw *devsw, int unit, struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt,...) |
struct cdev * | make_dev_credf (int flags, struct cdevsw *devsw, int unit, struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt,...) |
int | make_dev_p (int flags, struct cdev **cdev, struct cdevsw *devsw, struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt,...) |
static void | dev_dependsl (struct cdev *pdev, struct cdev *cdev) |
void | dev_depends (struct cdev *pdev, struct cdev *cdev) |
static int | make_dev_alias_v (int flags, struct cdev **cdev, struct cdev *pdev, const char *fmt, va_list ap) |
struct cdev * | make_dev_alias (struct cdev *pdev, const char *fmt,...) |
int | make_dev_alias_p (int flags, struct cdev **cdev, struct cdev *pdev, const char *fmt,...) |
int | make_dev_physpath_alias (int flags, struct cdev **cdev, struct cdev *pdev, struct cdev *old_alias, const char *physpath) |
static void | delist_dev_locked (struct cdev *dev) |
void | delist_dev (struct cdev *dev) |
void | destroy_dev (struct cdev *dev) |
const char * | devtoname (struct cdev *dev) |
int | dev_stdclone (char *name, char **namep, const char *stem, int *unit) |
void | clone_setup (struct clonedevs **cdp) |
int | clone_create (struct clonedevs **cdp, struct cdevsw *csw, int *up, struct cdev **dp, int extra) |
void | clone_cleanup (struct clonedevs **cdp) |
static | TAILQ_HEAD (cdev_priv) |
int | destroy_dev_sched_cb (struct cdev *dev, void(*cb)(void *), void *arg) |
int | destroy_dev_sched (struct cdev *dev) |
void | destroy_dev_drain (struct cdevsw *csw) |
void | drain_dev_clone_events (void) |
Variables | |
struct mtx | devmtx |
static struct cdev_priv_list | cdevp_free_list |
static struct cdevsw | dead_cdevsw |
#define dead_close (d_close_t *)enxio |
Definition at line 289 of file kern_conf.c.
#define dead_dump (dumper_t *)enxio |
Definition at line 303 of file kern_conf.c.
#define dead_ioctl (d_ioctl_t *)enxio |
Definition at line 292 of file kern_conf.c.
#define dead_kqfilter (d_kqfilter_t *)enxio |
Definition at line 304 of file kern_conf.c.
#define dead_mmap (d_mmap_t *)enodev |
Definition at line 294 of file kern_conf.c.
#define dead_mmap_single (d_mmap_single_t *)enodev |
Definition at line 305 of file kern_conf.c.
#define dead_open (d_open_t *)enxio |
Definition at line 288 of file kern_conf.c.
#define dead_poll (d_poll_t *)enodev |
Definition at line 293 of file kern_conf.c.
#define dead_read (d_read_t *)enxio |
Definition at line 290 of file kern_conf.c.
#define dead_write (d_write_t *)enxio |
Definition at line 291 of file kern_conf.c.
#define FIXUP | ( | member, | |
noop, | |||
giant | |||
) |
#define no_dump (dumper_t *)enodev |
Definition at line 348 of file kern_conf.c.
#define no_ioctl (d_ioctl_t *)enodev |
Definition at line 329 of file kern_conf.c.
#define no_kqfilter (d_kqfilter_t *)enodev |
Definition at line 331 of file kern_conf.c.
#define no_mmap (d_mmap_t *)enodev |
Definition at line 330 of file kern_conf.c.
#define no_mmap_single (d_mmap_single_t *)enodev |
Definition at line 332 of file kern_conf.c.
#define no_read (d_read_t *)enodev |
Definition at line 327 of file kern_conf.c.
#define no_write (d_write_t *)enodev |
Definition at line 328 of file kern_conf.c.
#define null_close (d_close_t *)nullop |
Definition at line 326 of file kern_conf.c.
#define null_open (d_open_t *)nullop |
Definition at line 325 of file kern_conf.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 127 of file kern_conf.c.
Referenced by fini_cdevsw(), and prep_cdevsw().
void clone_cleanup | ( | struct clonedevs ** | cdp | ) |
Definition at line 1399 of file kern_conf.c.
References destroy_devl(), dev_unlock_and_free(), and free().
int clone_create | ( | struct clonedevs ** | cdp, |
struct cdevsw * | csw, | ||
int * | up, | ||
struct cdev ** | dp, | ||
int | extra | ||
) |
Definition at line 1312 of file kern_conf.c.
References dev_unlock(), dev_unlock_and_free(), newdev(), panic(), prep_cdevsw(), and printf().
void clone_setup | ( | struct clonedevs ** | cdp | ) |
Definition at line 1304 of file kern_conf.c.
References malloc().
|
static |
Definition at line 297 of file kern_conf.c.
References biofinish().
Referenced by prep_cdevsw().
void delist_dev | ( | struct cdev * | dev | ) |
Definition at line 1229 of file kern_conf.c.
References delist_dev_locked(), and dev_unlock().
|
static |
Definition at line 1200 of file kern_conf.c.
References child, delist_dev_locked(), dev_refl(), dev_unlock(), and notify_destroy().
Referenced by delist_dev(), and delist_dev_locked().
void destroy_dev | ( | struct cdev * | dev | ) |
Definition at line 1239 of file kern_conf.c.
References destroy_devl(), and dev_unlock_and_free().
Referenced by make_dev_physpath_alias(), and tty_makedevf().
void destroy_dev_drain | ( | struct cdevsw * | csw | ) |
Definition at line 1501 of file kern_conf.c.
References dev_unlock(), devmtx, and hz.
int destroy_dev_sched | ( | struct cdev * | dev | ) |
Definition at line 1494 of file kern_conf.c.
References destroy_dev_sched_cb().
Referenced by ptsdrv_free().
int destroy_dev_sched_cb | ( | struct cdev * | dev, |
void(*)(void *) | cb, | ||
void * | arg | ||
) |
Definition at line 1486 of file kern_conf.c.
References destroy_dev_sched_cbl().
Referenced by destroy_dev_sched(), and tty_rel_free().
|
static |
Definition at line 1465 of file kern_conf.c.
References dev_refl(), dev_unlock(), and taskqueue_enqueue().
Referenced by destroy_dev_sched_cb().
|
static |
|
static |
Definition at line 1098 of file kern_conf.c.
References dead_cdevsw, destroy_devl(), dev_free_devlocked(), dev_refl(), dev_unlock(), devmtx, devtoname(), fini_cdevsw(), hz, notify_destroy(), printf(), and wakeup().
Referenced by clone_cleanup(), destroy_dev(), and destroy_devl().
void dev_depends | ( | struct cdev * | pdev, |
struct cdev * | cdev | ||
) |
Definition at line 957 of file kern_conf.c.
References dev_dependsl(), and dev_unlock().
Referenced by tty_makedevf().
|
static |
Definition at line 948 of file kern_conf.c.
Referenced by dev_depends(), and make_dev_alias_v().
|
static |
Definition at line 115 of file kern_conf.c.
References cdevp_free_list.
Referenced by destroy_devl(), and newdev().
void dev_ref | ( | struct cdev * | dev | ) |
Definition at line 142 of file kern_conf.c.
References devmtx.
void dev_refl | ( | struct cdev * | dev | ) |
Definition at line 152 of file kern_conf.c.
Referenced by ctty_clone(), delist_dev_locked(), destroy_dev_sched_cbl(), destroy_devl(), and make_dev_sv().
struct cdevsw * dev_refthread | ( | struct cdev * | dev, |
int * | ref | ||
) |
Definition at line 179 of file kern_conf.c.
Referenced by giant_close(), giant_fdopen(), giant_ioctl(), giant_kqfilter(), giant_mmap(), giant_mmap_single(), giant_open(), giant_poll(), giant_read(), giant_strategy(), and giant_write().
void dev_rel | ( | struct cdev * | dev | ) |
Definition at line 160 of file kern_conf.c.
References dev_unlock(), devtoname(), and flag.
void dev_relthread | ( | struct cdev * | dev, |
int | ref | ||
) |
Definition at line 249 of file kern_conf.c.
Referenced by aio_qbio(), giant_close(), giant_fdopen(), giant_ioctl(), giant_kqfilter(), giant_mmap(), giant_mmap_single(), giant_open(), giant_poll(), giant_read(), giant_strategy(), giant_write(), and ttyhook_register().
int dev_stdclone | ( | char * | name, |
char ** | namep, | ||
const char * | stem, | ||
int * | unit | ||
) |
Definition at line 1256 of file kern_conf.c.
References name.
void dev_unlock | ( | void | ) |
Definition at line 135 of file kern_conf.c.
References devmtx.
Referenced by clone_create(), ctty_clone(), delist_dev(), delist_dev_locked(), destroy_dev_drain(), destroy_dev_sched_cbl(), destroy_devl(), dev_depends(), dev_rel(), make_dev_alias_v(), make_dev_sv(), prep_cdevsw(), and vn_isdisk_error().
|
static |
Definition at line 84 of file kern_conf.c.
References cdevp_free_list, devmtx, and free().
Referenced by clone_cleanup(), clone_create(), destroy_dev(), and make_dev_sv().
const char * devtoname | ( | struct cdev * | dev | ) |
Definition at line 1249 of file kern_conf.c.
Referenced by destroy_devl(), dev_rel(), disk_err(), make_dev_sv(), newdev(), and physio().
struct cdevsw * devvn_refthread | ( | struct vnode * | vp, |
struct cdev ** | devp, | ||
int * | ref | ||
) |
Definition at line 205 of file kern_conf.c.
Referenced by aio_qbio(), and ttyhook_register().
void drain_dev_clone_events | ( | void | ) |
Definition at line 1512 of file kern_conf.c.
|
static |
Definition at line 281 of file kern_conf.c.
|
static |
Definition at line 275 of file kern_conf.c.
int eopnotsupp | ( | void | ) |
Definition at line 268 of file kern_conf.c.
|
static |
Definition at line 614 of file kern_conf.c.
References cdevsw_free_devlocked().
Referenced by destroy_devl().
|
static |
Definition at line 383 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 367 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 418 of file kern_conf.c.
References data, dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 482 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 498 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 516 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 351 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 466 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 434 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 399 of file kern_conf.c.
References biofinish(), dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
|
static |
Definition at line 450 of file kern_conf.c.
References dev_refthread(), dev_relthread(), and Giant.
Referenced by prep_cdevsw().
struct cdev * make_dev | ( | struct cdevsw * | devsw, |
int | unit, | ||
uid_t | uid, | ||
gid_t | gid, | ||
int | mode, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 877 of file kern_conf.c.
References make_dev_credv(), mode, and res.
struct cdev * make_dev_alias | ( | struct cdev * | pdev, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1007 of file kern_conf.c.
References make_dev_alias_v(), and res.
Referenced by fildesc_drvinit().
int make_dev_alias_p | ( | int | flags, |
struct cdev ** | cdev, | ||
struct cdev * | pdev, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 1023 of file kern_conf.c.
References flags, make_dev_alias_v(), and res.
Referenced by make_dev_physpath_alias().
|
static |
Definition at line 966 of file kern_conf.c.
References clean_unrhdrl(), dev_dependsl(), dev_unlock(), flags, notify_create(), panic(), and prep_devname().
Referenced by make_dev_alias(), and make_dev_alias_p().
void make_dev_args_init_impl | ( | struct make_dev_args * | args, |
size_t | sz | ||
) |
Definition at line 771 of file kern_conf.c.
struct cdev * make_dev_cred | ( | struct cdevsw * | devsw, |
int | unit, | ||
struct ucred * | cr, | ||
uid_t | uid, | ||
gid_t | gid, | ||
int | mode, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 894 of file kern_conf.c.
References make_dev_credv(), mode, and res.
struct cdev * make_dev_credf | ( | int | flags, |
struct cdevsw * | devsw, | ||
int | unit, | ||
struct ucred * | cr, | ||
uid_t | uid, | ||
gid_t | gid, | ||
int | mode, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 911 of file kern_conf.c.
References flags, make_dev_credv(), mode, and res.
Referenced by ctty_drvinit(), devctl2_init(), devinit(), devstat_alloc(), fildesc_drvinit(), log_drvinit(), and ttyconsdev_init().
|
static |
Definition at line 859 of file kern_conf.c.
References flags, make_dev_sv(), and mode.
Referenced by make_dev(), make_dev_cred(), make_dev_credf(), and make_dev_p().
int make_dev_p | ( | int | flags, |
struct cdev ** | cdev, | ||
struct cdevsw * | devsw, | ||
struct ucred * | cr, | ||
uid_t | uid, | ||
gid_t | gid, | ||
int | mode, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 930 of file kern_conf.c.
References flags, make_dev_credv(), mode, and res.
Referenced by reroot_conf().
int make_dev_physpath_alias | ( | int | flags, |
struct cdev ** | cdev, | ||
struct cdev * | pdev, | ||
struct cdev * | old_alias, | ||
const char * | physpath | ||
) |
Definition at line 1036 of file kern_conf.c.
References destroy_dev(), flags, free(), make_dev_alias_p(), malloc(), and sprintf().
int make_dev_s | ( | struct make_dev_args * | args, |
struct cdev ** | dres, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 846 of file kern_conf.c.
References make_dev_sv(), and res.
Referenced by kcov_init(), and tty_makedevf().
|
static |
Definition at line 779 of file kern_conf.c.
References clean_unrhdrl(), crhold(), dev_refl(), dev_unlock(), dev_unlock_and_free(), devtoname(), newdev(), notify_create(), panic(), prep_cdevsw(), prep_devname(), and res.
Referenced by make_dev_credv(), and make_dev_s().
|
static |
|
static |
Definition at line 568 of file kern_conf.c.
References dev_free_devlocked(), and devtoname().
Referenced by clone_create(), and make_dev_sv().
|
static |
Definition at line 342 of file kern_conf.c.
References poll_no_poll().
Referenced by prep_cdevsw().
|
static |
Definition at line 335 of file kern_conf.c.
References biofinish().
Referenced by prep_cdevsw().
|
static |
Definition at line 534 of file kern_conf.c.
References data, devctl_notify(), ev, flags, free(), and malloc().
Referenced by notify_create(), and notify_destroy().
|
static |
Definition at line 554 of file kern_conf.c.
References flags, and notify().
Referenced by make_dev_alias_v(), and make_dev_sv().
|
static |
Definition at line 561 of file kern_conf.c.
References notify().
Referenced by delist_dev_locked(), and destroy_devl().
int nullop | ( | void | ) |
Definition at line 261 of file kern_conf.c.
|
static |
Definition at line 628 of file kern_conf.c.
References cdevsw_free_devlocked(), dead_close, dead_dump, dead_ioctl, dead_kqfilter, dead_mmap, dead_mmap_single, dead_open, dead_poll, dead_read, dead_strategy(), dead_write, dev_unlock(), FIXUP, flags, giant_close(), giant_fdopen(), giant_ioctl(), giant_kqfilter(), giant_mmap(), giant_mmap_single(), giant_open(), giant_poll(), giant_read(), giant_strategy(), giant_write(), malloc(), no_dump, no_ioctl, no_kqfilter, no_mmap, no_mmap_single, no_poll(), no_read, no_strategy(), no_write, null_close, null_open, and printf().
Referenced by clone_create(), and make_dev_sv().
|
static |
Definition at line 715 of file kern_conf.c.
References vsnrprintf().
Referenced by make_dev_alias_v(), and make_dev_sv().
|
static |
Definition at line 67 of file kern_conf.c.
|
static |
Definition at line 1429 of file kern_conf.c.
|
static |
Definition at line 65 of file kern_conf.c.
Referenced by dev_free_devlocked(), and dev_unlock_and_free().
|
static |
Definition at line 307 of file kern_conf.c.
Referenced by destroy_devl().
struct mtx devmtx |
Definition at line 56 of file kern_conf.c.
Referenced by destroy_dev_drain(), destroy_devl(), dev_ref(), dev_unlock(), dev_unlock_and_free(), and mutex_init().