Opens a device special file.
Item | Description |
---|---|
devno | Specifies the major and minor device number of device driver to open. |
flag | Specifies one of the following values:
|
cname | Points to a channel specifying a character string or a null value. |
ext | Specifies an extension argument required by some device drivers. Its content, form, and use are determined by the individual driver. |
fpp | Specifies the returned file pointer. This parameter is passed by reference and is updated by the fp_opendev service to be the file pointer for this open instance. This file pointer is used as input to other Logical File System services to specify the open instance. |
The kernel or kernel extension calls the fp_opendev kernel service to open a device by specifying its device major and minor number. The fp_opendev kernel service provides the correct semantics for opening the character or multiplexed class of device drivers.
If the specified device driver is non-multiplexed:
If the device driver is a multiplexed character device driver (that is, its ddmpx entry point is defined), an in-core i-node is created for this channel. The device driver's ddmpx routine is also called with the cname pointer to the channel identification string if non-null. If the cname pointer is null, the ddmpx device driver routine is called with the pointer to a null character string.
If the device driver can allocate the channel, the ddmpx routine returns a channel ID, represented by the chan parameter. If the device driver cannot allocate a channel, the fpopendev kernel service returns an ENXIO error code. If successful, the i-node reference count is increment by 1. The device driver ddopen routine is also called with the devno, flag, chan (provided by ddmpx routine), and ext parameters.
If the return value from the specified device driver ddopen routine is nonzero, it is returned as the return code for the fp_opendev kernel service. If the return code from the device driver ddopen routine is 0, the fp_opendev service returns the file pointer corresponding to this open of the device.
The fp_opendev kernel service can only be called in the process environment or device driver top half. Interrupt handlers cannot call it. It is assumed that all arguments to the fp_opendev kernel service are in kernel space.
The file pointer (fpp) returned by the fp_opendev kernel service is only valid for use with a subset of the Logical File System services. These nine services can be called:
Other services return an EINVAL return value if called.
The fp_opendev kernel service can be called from the process environment only.
Item | Description |
---|---|
0 | Indicates a successful operation. |
The *fpp field also points to an open file structure that is valid for use with the other Logical File System services. If an error occurs, one of the following values from the /usr/include/sys/errno.h file is returned:
Item | Description |
---|---|
EINVAL | Indicates that the major portion of the devno parameter exceeds the maximum number allowed, or the flags parameter is not valid. |
ENODEV | Indicates that the device does not exist. |
EINTR | Indicates that the signal was caught while processing the fp_opendev request. |
ENFILE | Indicates that the system file table is full. |
ENXIO | Indicates that the device is multiplexed and unable to allocate the channel. |
The fp_opendev service also returns any nonzero return code returned from a device driver ddopen routine.