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 routines can be called at any time. Therefore, you should call disk_create only when your driver is completely ready to handle any operation.

When a disk structure is no longer needed, it should be freed with disk_destroy. You can destroy an opened disk structure. Of course, you’ll need to free any resources that were allocated during d_open afterward, as d_close can no longer be called.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.141.44