Specifications
D
evice Driver Programming
10-12
FEXCL Interpreted in a driver dependent manner. Some drivers
interpret this flag to mean open the device with exclusive
access. (fail all other attempts to open the device)
The otyp argument specifies the type of open call that is being made. Three distinct and
mutually exclusive types of open calls are defined in the file <sys/open.h>. They are
briefly described as follows:
OTYP_BLK Block special file
OTYP_CHR Character special file
OTYP_LYR Layered process
The crp argument is a pointer to a cred structure that contains the access credentials of the
calling process. The cred structure is defined in the file <sys/cred.h>; it is described
in Chapter 9, “The cred Structure” on page 9-7.
The open() routine can perform any of the following general functions, depending on
the type of device and service provided:
• Enable device interrupts
• Allocate buffers or other resources needed to use the device
• Lock a non-sharable device
• Notify the device of the open
The driver should verify that the minor number component of devp is valid and that the
type of access requested by otyp and oflag is appropriate for the device. If required, the
driver must check permissions using the user credentials pointed to by credp. (see
drv_priv(D3)).
When sleeping within the open call, the driver might sleep interruptibly such that signals
can cause it to longjmp().
Note that the open() is not called when a process performs a close() or a dup() sys-
tem call. The kernel keeps track of how many processes have the device open and only
calls the close() entry point when the last process performs a close() system call.
Also note that the open() must check whether the device was detected during boot time
in the init() entry point. If not, the driver must return with error code ENXIO.