Opens a device special file.
#include <sys/types.h> #include <sys/errno.h>
int fp_opendev (devno, devflag, channame, ext, fpp) dev_t devno; int devflag; char *channame; int ext; struct file**fpp;
|devno||Specifies the major and minor device number of device driver to open.|
|devflag|| Specifies one of the following values:
|channame||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 nonmultiplexed:
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 channame pointer to the channel identification string if non-null. If the channame 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 fp_opendev kernel service returns an ENXIO error code. If successful, the i-node reference count is incremented. The device driver's ddopen routine is also called with the devno, devflag, chan (provided by ddmpx routine), and ext parameters.
If the return value from the specified device driver's 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's 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.
|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:
|EINVAL||Indicates that the major portion of the devno parameter exceeds the maximum number allowed, or the devflags 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.
The fp_opendev kernel service is part of Base Operating System (BOS) Runtime.
The ddopen Device Driver Entry Point.
The fp_close kernel service, fp_ioctl kernel service, fp_poll kernel service, fp_read kernel service, fp_readv kernel service, fp_rwuio kernel service, fp_select kernel service, fp_write kernel service, fp_writev kernel service.
Logical File System Kernel Services in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.