disk Structure Management Routines

The FreeBSD kernel provides the following functions for working with disk structures:

#include <geom/geom_disk.h>

struct disk *
disk_alloc(void);

void
disk_create(struct disk *disk, int version);

void
disk_destroy(struct disk *disk);

A disk structure is a dynamically allocated structure that’s owned by the kernel. That is, you cannot allocate a struct disk on your own. Instead, you must call disk_alloc.

Allocating a disk structure does not make the storage device available to the system. To do that, you must initialize the structure (by defining the necessary fields) and then call disk_create. The version argument must always be DISK_VERSION.

Note that as soon as disk_create returns, the device is “live” and its ...

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.