Skip to main content

Module character_device

Module character_device 

Source
Expand description

Character device contracts, including the terminal line discipline controls.

§Terminal control commands (kind b'T')

NumberCommandDirectionInputOutputEffect
0x00IS_A_TERMINALRead()u8Whether the device is an interactive terminal (0 or 1).
0x01GET_TERMINAL_ATTRIBUTESRead()TerminalAttributesReturns the current line discipline settings.
0x02SET_TERMINAL_ATTRIBUTESReadTerminalAttributes()Applies new line discipline settings.

These commands play the role of POSIX tcgetattr and tcsetattr. SET_TERMINAL_ATTRIBUTES is declared with the Read direction on purpose: a program changes the settings of its standard input, which is opened read-only, just as tcsetattr accepts a read-only descriptor. The VFS requires write access only for commands declared Write.

A device that has no line discipline answers both commands with Unsupported; callers then keep their usual behaviour. A device rejects flags it does not know with InvalidArgument, so a program can tell when a setting it asked for is not available.

Structs§

GET_TERMINAL_ATTRIBUTES
IS_A_TERMINAL
SET_TERMINAL_ATTRIBUTES
TerminalAttributes
Terminal line discipline settings, exchanged by GET_TERMINAL_ATTRIBUTES and SET_TERMINAL_ATTRIBUTES.
TerminalFlags
Line discipline switches of a terminal, see TerminalAttributes.

Traits§

CharacterDevice
DirectCharacterDevice