Character device
A character device is an operating-system device interface accessed through a character-special file, with supported operations determined by the device implementation.
Identity: On Linux, S_ISCHR(st_mode) tests for the character-special file type S_IFCHR. Its st_rdev holds the represented device number; st_dev instead identifies the filesystem device containing the inode. [1]
Node and driver: mknod() creates a filesystem node and records its major/minor device numbers. The kernel's cdev_add() separately makes a character device live, and cdev_init() associates its file operations. Creating a node alone is not evidence of working hardware or an available driver. [2] [3]
Removal boundary: Linux 6.12 cdev_del() prevents new opens of that registered device, but already-open instances can still call its file operations after removal returns. Deregistration is not automatic revocation of existing handles; continued callability does not promise successful I/O or surviving hardware. [3]
Operations: /dev/null and /dev/zero both discard writes; reads return EOF from /dev/null and zero-valued bytes from /dev/zero. These examples do not store the written payload. [4] Seeking support depends on the device; the character-special type alone does not promise seeking, buffering, one-byte transfers or persistence. [5] [3]
Metadata reuse: In Linux 6.12 OverlayFS, a whiteout can use a character-special node numbered 0:0 or a zero-size regular file carrying trusted.overlay.whiteout. The marker suppresses a matching lower-layer name and is hidden in the merged view; it is not an ordinary data-device interface. [6]
Relations
- related
- Block device, Inode, Whiteout
Limitations
- File type and device numbers do not establish a working driver, physical hardware or durable storage.
- The documented Linux examples do not define every operating system's device contract.
Citations
- Linux man-pages: inode(7), file type and represented-device identity
- Linux man-pages: mknod(2), device-node creation and device numbers
- Linux 6.12 kernel API: character-device registration and file operations
- Linux man-pages: null(4), null and zero device behavior
- Linux man-pages: lseek(2), device-specific seek support
- Linux 6.12: Overlay Filesystem, whiteouts and opaque directories
Further reading
Sources & caveats
- Primary-source documentation synthesis, not a device, mounted-overlay or crash experiment.
- Concrete file types, identity fields and whiteout encodings are scoped to the cited Linux interfaces.