DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Writing a SCSI host adapter driver

open routine

The open(D2osdi) routine in the Sram driver gets a file descriptor to use with the ioctl(D2osdi) functionality. The logic is:

  1. Call minor(D3oddi) to get the minor number for the device.

  2. Increment the opened variable. Because this is such a simple driver, opened is not actually used, but it is always good practice to keep track of the number of times a particular device has been opened so that the close(D2osdi) routine can identify the final close of the device. Note that this variable is declared and set to 0 in the Sram.h header file to ensure that its accuracy is preserved across a reboot.

  3. Return 0 if successful. If not successful, set u.u_error to EBUSY and return -1. The Sramopen( ) routine will be called only when the device is opened for raw I/O, so error conditions are returned through the user structure rather than through the buf structure.

This routine should be exclusive if it adjusts functionality. In that case, the close( ) routine would need to be coded to allow a file descriptor to be reopened after it is closed.


© 2005 The SCO Group, Inc. All rights reserved.