Provides access to the system console.
The /dev/console special file provides access to the device or file designated as the system console. This file can be designated as the console device by the person administering the system or a user with the appropriate permissions. The console character special file provides access to the console device driver. The console device driver in turn directs input and output to the device or file selected as the system console.
The system console is typically a terminal or display located near the system unit. It has two functions in the operating system. First, it provides access to the system when it is operating in a non-multiuser mode. (This would be the case during maintenance and diagnostic sessions.) A console login is also normally provided on this device for all operating system run levels.
Second, the system console displays messages for system errors and other problems requiring intervention. These messages are generated by the operating system and its various subsystems when starting or operating. The system console can also be redirected to a file or to the /dev/null special file for systems operating without a console device.
Console driver configuration support allows the system console to be assigned or reassigned to a specified device or file. Such support also provides query functions to determine the current and configured path names for the device or file designated as the console. This configuration support is used by the swcons, chcons, and lscons high-level system management commands. It is also used by the console configuration method at system startup.
The swcons (switch console) command can be used during system operation to switch the system console output to a different target temporarily. This command switches only system information, error, and intervention-required messages to the specified destination. The swcons command does not affect the operation of the system console device that provides a login through the getty command. The device or file specified when using the swcons command remains the target for console output until one of the following happens:
If an open or write error is detected on the device or file specified by the swcons command, the console device driver switches all output back to the device or file providing console support when the system started.
The chcons (change console) command can be used to switch the system console output to a different device or file for the next startup. This command does not affect the current console selection, but becomes effective when the system is started again.
When requested to activate a login on the console device, the getty program (which provides login support) uses the console configuration support to determine the path name of the targeted console device used at startup. This action ensures that the swcons command does not effect the console device being used for login.
The open, close, read, write, ioctl, select, and poll subroutines are supported by the console device driver and may be used with the /dev/console special file. These subroutines are redirected to the device or file serving as the current system console device by the console device driver.
When an open subroutine call is issued to the console device driver, it is redirected to the device or file currently chosen as the console device. If the system console choice is a file, the file is opened with the append and create options when the first open of the dev/console file is received. Subsequent opens have no effect when the console selection is a file. However, the opens are then passed to the device driver supporting the device chosen as the console.
If the console selection has been temporarily switched using the swcons command and the first open of the new underlying device fails, the console device driver switches back to the console device or file with which the system was booted. This prevents important system messages from being lost.
An ext parameter passed using the openx subroutine is passed to the device driver supporting the console target or else ignored. (The latter is true if the console selection is a file.)
The close subroutine support is standard.
The select, poll, and ioctl subroutines are redirected to the current system console device when the console selection is not a file. If the selected console device is a file, the console device driver returns an error indicating that the subroutine is not supported.
An ext parameter passed to the ioctlx subroutine is then passed to the device driver supporting the console target, or else ignored. (The latter is true if the console selection is a file.)
The write subroutine calls are redirected to the current console device or file. If the console selection has been temporarily switched using the swcons command, and the write to the targeted device or file is unsuccessful, the console device driver switches back to the console device or file from which the system was started and tries the write again. This prevents important system messages from being lost in case the temporary console target is unavailable or unsuccessful. The console device driver should stay connected to the original system device until another swcons command is issued.
If the current console selection is a device, it redirects the read subroutine call. If the current console selection is a file, the read call is rejected with an error (EACCES).
An ext parameter passed to the readx or writex subroutine is passed to the device driver supporting the console target, or else ignored. (The latter is true if the console selection is a file.)
The console special file is part of Base Operating System (BOS) Runtime.
|/dev/null||Provides access to the null device.|
The chcons command, getty command, lscons command, swcons command.
Special Files Overview.
The consdef file.
The close subroutine, ioctl subroutine, lseek subroutine, open subroutine, poll subroutine, read subroutine, select subroutine, write subroutine.