#include <sys/conf.h>
sys/conf.h
typedefopen_close_fcn_t
Device switch function types.
typedef int (dev_t, int, int, struct proc *) open_close_fcn_t;
typedefd_devtotty_t
typedef struct tty *d_devtotty_t(dev_t dev)
typedefstrategy_fcn_t
typedef void strategy_fcn_t(struct buf *bp)
typedefioctl_fcn_t
typedef int (dev_t, u_long, caddr_t, int, struct proc *) ioctl_fcn_t;
typedefpsize_fcn_t
typedef int psize_fcn_t(dev_t dev)
typedefread_write_fcn_t
typedef int read_write_fcn_t(dev_t dev, struct uio *uio, int ioflag)
typedefstop_fcn_t
typedef int stop_fcn_t(struct tty *tp, int rw)
typedefreset_fcn_t
typedef int reset_fcn_t(int uban)
typedefselect_fcn_t
typedef int select_fcn_t(dev_t dev, int which, void * wql, struct proc *p)
typedefmmap_fcn_t
typedef int mmap_fcn_t(void)
typedefrsvd_fcn_t
typedef int rsvd_fcn_t(void)
typedefempty_fcn_t
typedef void empty_fcn_t(void)
macrod_open_t
#define d_open_t open_close_fcn_t
macrod_close_t
#define d_close_t open_close_fcn_t
macrod_read_t
#define d_read_t read_write_fcn_t
macrod_write_t
#define d_write_t read_write_fcn_t
macrod_ioctl_t
#define d_ioctl_t ioctl_fcn_t
macrod_stop_t
#define d_stop_t stop_fcn_t
macrod_reset_t
#define d_reset_t reset_fcn_t
macrod_select_t
#define d_select_t select_fcn_t
macrod_mmap_t
#define d_mmap_t mmap_fcn_t
macrod_strategy_t
#define d_strategy_t strategy_fcn_t
functionenodev
int enodev(void)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/subr_xxx.c
Returns ENODEV. Installed in bdevsw/cdevsw entry points to reject an unsupported device function, such as writing to a read-only device.
functionenodev_strat
void enodev_strat(void)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/subr_xxx.c
No-op strategy routine for unsupported devices; the void-returning counterpart of enodev, suitable for the d_strategy slot of a device switch entry.
macroeno_opcl
Versions of enodev() pointer, cast to appropriate function type. For use
in empty devsw slots.
#define eno_opcl ((open_close_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_strat
#define eno_strat ((strategy_fcn_t *)(empty_fcn_t*)&enodev_strat)
macroeno_ioctl
#define eno_ioctl ((ioctl_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_dump
#define eno_dump ((dump_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_psize
#define eno_psize ((psize_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_rdwrt
#define eno_rdwrt ((read_write_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_stop
#define eno_stop ((stop_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_reset
#define eno_reset ((reset_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_mmap
#define eno_mmap ((mmap_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_select
#define eno_select ((select_fcn_t *)(empty_fcn_t*)&enodev)
macroeno_putc
#define eno_putc ((rsvd_fcn_t *)&enodev)
structbdevsw
Block device switch table
| open_close_fcn_t * | d_open | |
| open_close_fcn_t * | d_close | |
| strategy_fcn_t * | d_strategy | |
| ioctl_fcn_t * | d_ioctl | |
| dump_fcn_t * | d_dump | |
| psize_fcn_t * | d_psize | |
| int | d_type |
macroNO_BDEVICE
Contents of empty bdevsw slot.
#define NO_BDEVICE { eno_opcl, eno_opcl, eno_strat, eno_ioctl,
eno_dump, eno_psize, 0 }structcdevsw
Character device switch table
| open_close_fcn_t * | d_open | |
| open_close_fcn_t * | d_close | |
| read_write_fcn_t * | d_read | |
| read_write_fcn_t * | d_write | |
| ioctl_fcn_t * | d_ioctl | |
| stop_fcn_t * | d_stop | |
| reset_fcn_t * | d_reset | |
| struct tty ** | d_ttys | |
| select_fcn_t * | d_select | |
| mmap_fcn_t * | d_mmap | |
| strategy_fcn_t * | d_strategy | |
| rsvd_fcn_t * | d_reserved_1 | |
| rsvd_fcn_t * | d_reserved_2 | |
| int | d_type |
macroNO_CDEVICE
#define NO_CDEVICE {
eno_opcl, eno_opcl, eno_rdwrt, eno_rdwrt,
eno_ioctl, eno_stop, eno_reset, 0,
(select_fcn_t *)(void (*)(void))seltrue, eno_mmap,
eno_strat, eno_getc,
eno_putc, 0
}functionbdevsw_isfree
int bdevsw_isfree(int)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Checks availability of a slot in the block device switch table. If index is -1, searches for the first free slot, starting at 1 (slot 0 is avoided for historical volfs reasons); if index is otherwise negative, the search starts at -index; a nonnegative index checks that specific slot. Returns the free major number, or -1 if the slot is in use or out of range.
functionbdevsw_add
int bdevsw_add(int, const struct bdevsw *)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Adds a block device switch to the bdevsw table. The slot is chosen as by bdevsw_isfree: -1 selects the first free slot, other negative values start the search at -index, and a nonnegative index must itself be free. Copies *bsw into the slot under the devsw lock. Returns the major number used, or -1 if no slot was available.
functionbdevsw_remove
int bdevsw_remove(int, const struct bdevsw *)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Removes a block device switch from slot index of the bdevsw table, but only if the slot's current contents match *bsw; the slot is then reset to the null device entry. Returns index on success, or -1 if index is out of range or the entry does not match.
functioncdevsw_isfree
int cdevsw_isfree(int)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Checks availability of a slot in the character device switch table. If index is -1, searches for the first free slot starting at 0; if index is otherwise negative, the search starts at -index; a nonnegative index checks that specific slot. Returns the free major number, or -1 if the slot is in use or out of range.
functioncdevsw_add
int cdevsw_add(int, const struct cdevsw *)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Adds a character device switch to the cdevsw table. The slot is chosen as by cdevsw_isfree: -1 selects the first free slot, other negative values start the search at -index, and a nonnegative index must itself be free. Copies *csw into the slot under the devsw lock and returns the major number used, or -1. The source notes that -1 is unusable in practice, because kernel-internal devices later claim absolute indexes; -24 is noted as a safe starting point for the search.
functioncdevsw_add_with_bdev
int cdevsw_add_with_bdev(int index, const struct cdevsw * csw, int bdev)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Adds a character device switch as cdevsw_add does, then records the association between the resulting character major number and the block major bdev (the chrtoblk mapping). If the association cannot be established, the entry is removed again and -1 is returned; otherwise returns the character major number used.
functioncdevsw_remove
int cdevsw_remove(int, const struct cdevsw *)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/bsd_stubs.c
Removes a character device switch from slot index of the cdevsw table, but only if the slot's current contents match *csw; the slot is reset to the null device entry and its cdevsw_flags are cleared. Returns index on success, or -1 if index is out of range or the entry does not match.