Index Index for
Section 9s
Index Alphabetical
listing for B
Bottom of page Bottom of
page

buf(9s)

NAME

buf - General: Describes arbitrary I/O

SYNOPSIS

_________________________________ Member Name Data Type _________________________________ b_flags int b_forw struct buf * b_back struct buf * av_forw struct buf * av_back struct buf * b_bcount int b_error short b_dev dev_t b_un.b_addr caddr_t b_lblkno daddr_t b_blkno daddr_t b_resid int b_iodone void (*b_iodone) () b_proc struct proc * _________________________________

MEMBERS

b_flags Specifies binary status flags. These flags indicate how a request is to be handled and the current status of the request. The following flags are applicable to kernel modules that are device drivers: B_READ, B_DONE, B_ERROR, B_BUSY, and B_PHYS. See the DESCRIPTION section for more information on these flags. b_forw Specifies a hash chain. Only the entity (driver, buffer cache) that owns the buf structure can use or reference this member. A driver receiving a buf structure from the buffer cache through the strategy routine must not use this member. b_back Specifies a hash chain. Only the entity (driver, buffer cache) that owns the buf structure can use or reference this member. A driver receiving a buf structure from the buffer cache through the strategy routine must not use this member. av_forw Specifies the position on the free list if the b_flags member is not set to B_BUSY. av_back Specifies the position on the free list if the b_flags member is not set to B_BUSY. b_bcount Specifies the size of the requested transfer (in bytes). b_error Specifies that an error occurred on this data transfer. This member is set to an error code if the b_flags member bit was set. b_dev Specifies the special device to which the transfer is directed. b_un.b_addr Specifies the address at which to pull or push the data. b_lblkno Specifies the logical block number. b_blkno Specifies the block number on the partition of a disk or on the file system. b_resid Specifies (in bytes) the data not transferred because of some error. b_iodone Specifies the routine called by iodone. The device driver calls iodone at the completion of an I/O operation. b_proc Specifies a pointer to the proc structure that represents the process performing the I/O.

DESCRIPTION

The buf data structure describes arbitrary I/O, but is usually associated with block I/O and physio. A systemwide pool of buf data structures exists for block I/O; however, many kernel modules that are device drivers also include locally defined buf data structures. Kernel modules can use the following flags with the b_flags member: B_READ This flag is set if the operation is read and cleared if the operation is write. B_DONE This flag is cleared when a request is passed to a driver strategy routine. The writer must call iodone to mark a buffer as completed. B_ERROR This flag specifies that an error occurred on this data transfer. Kernel modules set this flag if an error occurs. B_BUSY This flag indicates that the buffer is in use. B_PHYS This flag indicates that the associated data is in user address space.

NOTES

The operating system does not define a B_CALL flag. The iodone routine checks the b_iodone member to determine if you specified a completion routine. If so, iodone clears b_iodone and then calls the specified completion routine. If you want to reuse this buf data structure, you must reset the b_iodone member to a completion routine. In fact, it is good programming practice to reset all of the referenced members of a buf data structure that you plan to reuse.

FILES

<sys/buf.h>

Index Index for
Section 9s
Index Alphabetical
listing for B
Top of page Top of
page