SCO OpenServer
strategy(D2oddi)
strategy --
handle block device input and output
Synopsis
void prefixstrategy (struct buf *bp);
Description
The
strategy( )
entry point routine handles the data transfer
through the buffer cache that is used by block devices.
Block drivers must include a
strategy( )
routine to initiate the transfer,
validate the buffer header information,
and generate the device operations
required to start the data transfer.
Arguments
buf-
pointer to a buf data structure.
The pointer is the address of an instance of
the buf data structure that is defined in
the <sys/buf.h> header file.
All information about the data transfer
is contained in this structure.
The pointer is also used to return status and error information
to the kernel and convey the information to the user.
Return values
None
Usage
The
strategy( )
routine should perform the following activities:
-
Get and validate the device number
-
Schedule block I/O requests
-
Call subordinate driver routines (if any)
to notify a controller than an I/O operation is waiting
-
If the device can only handle
one I/O operation at a time,
the
strategy( )
routine must cause the process to sleep
until the device is available.
For example,
a sequential access device such as a tape drive
should handle only one read/write operation at a time.
-
Handle any errors occurring during the read/write operation
-
Log device errors to the hard disk error log
If an error occurs,
set the b_error
member of the buf structure
and OR the B_ERROR flag into the b_flags member.
The test should be for B_READ and ``not'' B_READ .
B_WRITE cannot be tested because it is not a flag,
it is 0.
You must also supply a
print(D2oddi)
routine for the kernel to call
to output a message to the console and putbuf structure.
Context and synchronization
Blockable
context.
The driver can block but cannot do operations such as
copyout(D3)
that require access to
the requesting process's address space.
context
Hardware applicability
All
Version applicability
oddi:
1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp
SVR5 DDI compatibility
The
strategy(D2)
entry point routine provides the same functionality
for DDI versions prior to DDI 8.
Beginning with DDI 8,
use the
biostart(D2)
entry point routine for
both block and raw access I/O operations.
External dependencies
Drivers that contain a
strategy( )
routine must have a b in the second column of the
mdevice(F)
file to indicate that it is a block device.
The kernel expects a
strategy( )
routine for every block driver that is configured.
References
print(D2oddi)
``Buffered I/O buffers, allocating'' in HDK Technical Reference
``Block device drivers'' in HDK Technical Reference
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005