*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: devsw | Section: 9 | Source: NetBSD | File: devsw.9
DEVSW(9) FreeBSD Kernel Developer's Manual DEVSW(9) NAME devsw, devsw_attach, devsw_detach, bdevsw_lookup, cdevsw_lookup, bdevsw_lookup_major, cdevsw_lookup_major - character and block device switch functions SYNOPSIS #include <sys/conf.h> int devsw_attach(const char *devname, const struct bdevsw *bev, devmajor_t *bmajor, const struct cdevsw *cdev, devmajor_t *cmajor); void devsw_detach(const struct bdevsw *bdev, const struct cdevsw *cdev); const struct bdevsw * bdevsw_lookup(dev_t dev); const struct cdevsw * cdevsw_lookup(dev_t dev); devmajor_t bdevsw_lookup_major(const struct bdevsw *bdev); devmajor_t cdevsw_lookup_major(const struct cdevsw *cdev); DESCRIPTION If a device driver has character device interfaces accessed from userland, the driver must define a cdevsw structure. If the driver also has block device interfaces, the driver must additionally define a bdevsw structure. These structures are constant, and are defined within the driver(9). For drivers which are included in the kernel via config(1), the cdevsw and bdevsw structures are automatically linked into the configuration database. For drivers which are separately loaded, the devsw_attach() function creates the necessary linkage and associates the cdev and optional bdev with the driver(9). If there is no block device interface needed, bdev should be set to NULL and bmajor to -1. The devname, major number, and device type (character or block) must correspond to the device file which will be opened by user programs. By passing -1 to the function for the cmajor or bmajor, the major number can be automatically generated. It can then be returned to userspace (for example, using sysctl(8)) for creation of the device node. The devsw_detach() function is used to detach the bdev and cdev structures. devsw_detach() should be called before a loaded device driver is unloaded. The caller must ensure that there are no open instances of the device, and that the device's d_open() function will fail, before calling. Fn devsw_detach . The bdevsw_lookup() and cdevsw_lookup() functions return const struct bdevsw * and const struct cdevsw * for the given dev. The bdevsw_lookup_major() and cdevsw_lookup_major() functions return devmajor_t for the given const struct bdevsw * or const struct cdevsw *. RETURN VALUES Upon successful completion, devsw_attach() returns 0. Otherwise it returns an error value. In case of failure, bdevsw_lookup() and cdevsw_lookup() return the NULL value. The bdevsw_lookup_major() and cdevsw_lookup_major() functions return NODEVMAJOR for an unsuccessful completion. SEE ALSO driver(9) FreeBSD 14.1-RELEASE-p8 January 11, 2022 FreeBSD 14.1-RELEASE-p8

Navigation Options