#include <miscfs/specfs/specdev.h>

miscfs/specfs/specdev.h Kernel.framework

38 macros · 11 functions · 2 variables · 1 struct

structspecinfo

This structure defines the information maintained about special devices. It is allocated in checkalias and freed in vgone.
size 80, align 8
struct vnode **si_hashchain
struct vnode *si_specnext
longsi_flags
dev_tsi_rdev
int32_tsi_opencount
daddr_tsi_sizedevice block size in bytes
daddr64_tsi_lastrlast read blkno (read-ahead)
u_int64_tsi_devsizeactual device size in bytes
u_int8_tsi_initted
u_int8_tsi_throttleable
u_int16_tsi_isssd
u_int32_tsi_devbsdunit
u_int64_tsi_throttle_mask
thread_tsi_mountingowner

macrov_rdev

Exported shorthand
#define v_rdev v_specinfo->si_rdev

macrov_hashchain

#define v_hashchain v_specinfo->si_hashchain

macrov_specnext

#define v_specnext v_specinfo->si_specnext

macrov_specflags

#define v_specflags v_specinfo->si_flags

macrov_specsize

#define v_specsize v_specinfo->si_size

macrov_specdevsize

#define v_specdevsize v_specinfo->si_devsize

macrov_speclastr

#define v_speclastr v_specinfo->si_lastr

macroSI_MOUNTEDON

Flags for specinfo
#define SI_MOUNTEDON 0x0001
block special device is mounted on

macroSI_ALIASED

#define SI_ALIASED 0x0002
multiple active vnodes refer to this device

macroSI_MOUNTING

#define SI_MOUNTING 0x0004
block special device is getting mounted on

macroSI_REVOKEWAIT

#define SI_REVOKEWAIT 0x0008
Flag to serialize revoke and close for ttys

macroSPECHSZ

Special device management
#define SPECHSZ 64

macroSPECHASH

#define SPECHASH(rdev) (((rdev>>21)+(rdev))&(SPECHSZ-1))

variablespeclisth

extern struct vnode *speclisth[SPECHSZ]

variablespec_vnodeop_p

Prototypes for special file operations on vnodes.
extern int(**spec_vnodeop_p)(void *)

functionspec_ebadf

int spec_ebadf(void *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Failed-operation stub used in the specfs vnode operation table for operations that are invalid on device special files. Ignores its argument and returns EBADF.

functionspec_lookup

int spec_lookup(struct vnop_lookup_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the lookup vnode operation (VNOP_LOOKUP) for device special vnodes. Trivial routine that always fails: sets *a_vpp to NULL and returns ENOTDIR.

macrospec_create

#define spec_create (int (*) (struct  vnop_access_args *))err_create

macrospec_mknod

#define spec_mknod (int (*) (struct  vnop_access_args *))err_mknod

functionspec_open

int spec_open(struct vnop_open_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the open vnode operation (VNOP_OPEN) for device special files. Refuses the open with ENXIO if the containing filesystem is mounted MNT_NODEV or the major number is out of range. For VCHR vnodes, enforces security checks (writing to /dev/mem or /dev/kmem is refused with EPERM; at securelevel >= 1, writing a character device whose block counterpart is mounted is refused), then calls the device's d_open entry in cdevsw and, for D_DISK devices, initializes I/O throttling state (DKIOCGETTHROTTLEMASK, DKIOCISSOLIDSTATE). For VBLK vnodes, refuses opens of mounted block devices (vfs_mountedon) and, at securelevel >= 2, writes to disks; calls d_open in bdevsw, then determines and caches the device block size and device size in bytes for later use by spec_read/spec_write. Increments the specinfo open count on success.

functionspec_close

int spec_close(struct vnop_close_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the close vnode operation (VNOP_CLOSE) for device special files. Decrements the specinfo open count. For VCHR: if the vnode is the closing process' controlling terminal and this is the last reference, the session's tty association is cleared; the device's d_close entry is called on the last reference or on revoke (IO_REVOKE). For VBLK: if more than one open is outstanding the device close is skipped; otherwise dirty buffers are flushed (spec_fsync_internal) and in-core blocks invalidated (buf_invalidateblks) before calling d_close on the last reference, so that removable media can be changed. Returns the device close or flush error.

macrospec_access

#define spec_access (int (*) (struct  vnop_access_args *))spec_ebadf

macrospec_getattr

#define spec_getattr (int (*) (struct  vnop_getattr_args *))spec_ebadf

macrospec_setattr

#define spec_setattr (int (*) (struct  vnop_setattr_args *))spec_ebadf

functionspec_read

int spec_read(struct vnop_read_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the read vnode operation (VNOP_READ) for device special files. For VCHR vnodes, calls the device's d_read entry in cdevsw directly, updating disk I/O throttling state and emitting kdebug DKIO trace records for D_DISK devices. For VBLK vnodes, performs buffered I/O through the buffer cache in page-sized chunks scaled by the device block size, using read-ahead (buf_breadn) when access is sequential, and copies out via uiomove; a negative offset or a device block size larger than PAGE_SIZE returns EINVAL.

functionspec_write

int spec_write(struct vnop_write_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the write vnode operation (VNOP_WRITE) for device special files. For VCHR vnodes, calls the device's d_write entry in cdevsw, updating disk I/O throttling state and emitting kdebug DKIO trace records for D_DISK devices. For VBLK vnodes, writes through the buffer cache in device-block-scaled chunks, reading the underlying block first for partial-block writes, and issues synchronous writes (buf_bwrite) when IO_SYNC is set, delayed writes otherwise.

functionspec_ioctl

int spec_ioctl(struct vnop_ioctl_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the ioctl vnode operation (VNOP_IOCTL) for device special files. Dispatches the command to the device's d_ioctl entry in cdevsw (VCHR) or bdevsw (VBLK). For block devices, a successful DKIOCSETBLOCKSIZE also updates the vnode's cached device block size (v_specsize). Returns the driver's result.

functionspec_select

int spec_select(struct vnop_select_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the select vnode operation (VNOP_SELECT) for device special files. For VCHR vnodes, calls the device's d_select entry in cdevsw; for all other vnode types, returns 1 (always ready).

macrospec_revoke

#define spec_revoke (int (*) (struct  vnop_access_args *))nop_revoke

macrospec_mmap

#define spec_mmap (int (*) (struct  vnop_access_args *))err_mmap

functionspec_fsync

int spec_fsync(struct vnop_fsync_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the fsync vnode operation (VNOP_FSYNC) for device special files. For character devices this is a no-op returning 0. For block devices, flushes all dirty buffers associated with the device via buf_flushdirtyblks, waiting for completion when a_waitfor is MNT_WAIT or MNT_DWAIT.

macrospec_remove

#define spec_remove (int (*) (struct  vnop_access_args *))err_remove

macrospec_rename

#define spec_rename (int (*) (struct  vnop_access_args *))err_rename

macrospec_mkdir

#define spec_mkdir (int (*) (struct  vnop_access_args *))err_mkdir

macrospec_rmdir

#define spec_rmdir (int (*) (struct  vnop_access_args *))err_rmdir

macrospec_readdir

#define spec_readdir (int (*) (struct  vnop_access_args *))err_readdir

macrospec_inactive

#define spec_inactive (int (*) (struct  vnop_access_args *))nop_inactive

macrospec_reclaim

#define spec_reclaim (int (*) (struct  vnop_access_args *))nop_reclaim

macrospec_lock

#define spec_lock (int (*) (struct  vnop_access_args *))nop_lock

macrospec_unlock

#define spec_unlock (int (*)(struct  vnop_access_args *))nop_unlock

functionspec_strategy

int spec_strategy(struct vnop_strategy_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the strategy vnode operation (VNOP_STRATEGY) for device special files, passing the buffer to the block device's d_strategy entry in bdevsw. Before issuing the I/O it assigns the buffer an I/O tier from the current thread's I/O policy, applies disk I/O throttling (possibly delaying low-priority I/O), tags the buffer for passive I/O, kdebug tracing, and I/O scheduling, and may upgrade priority for waited-upon buffers. Returns 0; completion is reported through the buffer.

macrospec_islocked

#define spec_islocked (int (*) (struct  vnop_access_args *))nop_islocked

functionspec_pathconf

int spec_pathconf(struct vnop_pathconf_args *)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/miscfs/specfs/spec_vnops.c
Implements the pathconf vnode operation (VNOP_PATHCONF) for device special files. Returns POSIX pathconf information applicable to special devices: _PC_LINK_MAX LINK_MAX _PC_MAX_CANON MAX_CANON _PC_MAX_INPUT MAX_INPUT _PC_PIPE_BUF PIPE_BUF _PC_CHOWN_RESTRICTED 200112 (_POSIX_CHOWN_RESTRICTED) _PC_VDISABLE _POSIX_VDISABLE All other names return EINVAL.

macrospec_advlock

#define spec_advlock (int (*) (struct  vnop_access_args *))err_advlock

macrospec_blkatoff

#define spec_blkatoff (int (*) (struct  vnop_access_args *))err_blkatoff

macrospec_valloc

#define spec_valloc (int (*) (struct  vnop_access_args *))err_valloc

macrospec_vfree

#define spec_vfree (int (*) (struct  vnop_access_args *))err_vfree

macrospec_bwrite

#define spec_bwrite (int (*) (struct  vnop_bwrite_args *))nop_bwrite