Reads the specified block data into a buffer.
#include <sys/types.h> #include <sys/errno.h> #include <sys/buf.h>
struct buf *bread (dev, blkno) dev_t dev; daddr_t blkno;
dev | Specifies the device containing the block to be read. |
blkno | Specifies the block to be read. |
The bread kernel service assigns a buffer to the given block. If the specified block is already in the buffer cache, then the block buffer header is returned. Otherwise, a free buffer is assigned to the specified block and the data is read into the buffer. The bread service waits for I/O to complete to return the buffer header.
The buffer is allocated to the caller and marked as busy.
The bread kernel service can be called from the process environment only.
The bread service returns the address of the selected buffer's header. A nonzero value for B_ERROR in the b_flags field of the buffer's header (buf structure) indicates an error. If this occurs, the caller should release the buffer associated with the block using the brelse kernel service.
The bread kernel service is part of Base Operating System (BOS) Runtime.
The getblk kernel service, iowait kernel service.
Block I/O Buffer Cache Kernel Services: Overview in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts describes how the buffer cache services manage the block I/O buffer cache mechanism.
I/O Kernel Services in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.