[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

bread Kernel Service

Purpose

Reads the specified block data into a buffer.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/buf.h>
struct buf *bread (dev, blkno)
dev_t  dev;
daddr_t  blkno;

Parameters

dev Specifies the device containing the block to be read.
blkno Specifies the block to be read.

Description

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.

Execution Environment

The bread kernel service can be called from the process environment only.

Return Values

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.

Implementation Specifics

The bread kernel service is part of Base Operating System (BOS) Runtime.

Related Information

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.


[ Previous | Next | Contents | Home | Search ]