Block I/O Structures

A bio structure represents a block-centric I/O request. Loosely speaking, when the kernel needs to transfer some data to or from a storage device, it puts together a bio structure to describe that operation; then it passes that structure to the appropriate driver.

struct bio is defined in the <sys/bio.h> header as follows:

struct bio { uint8_t bio_cmd; /* I/O operation. */ uint8_t bio_flags; /* General flags. */ uint8_t bio_cflags; /* Private use by the consumer. */ uint8_t bio_pflags; /* Private use by the provider. */ struct cdev *bio_dev; /* Device to perform I/O on. */ struct disk *bio_disk; /* Disk structure. */ off_t bio_offset; /* Requested position in file. */ long bio_bcount; /* Number of (valid) bytes. */ caddr_t bio_data; ...

Get FreeBSD Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.