xnvme_dev

Enums

Structs

Functions

xnvme_dev_close

void xnvme_dev_close(struct xnvme_dev *dev)

Destroy the given device handle (xnvme_dev)

Parameters:

xnvme_dev_derive_geo

int xnvme_dev_derive_geo(struct xnvme_dev *dev)

Derive the geometry of the given device.

This is done through a sequence of NVMe controller-register-reads, identify-controller/namespace commands, sysfs-probes, and ioctl()/stat()/ fstat() system calls. The system-interface and methods utilized are backend-specific.

Parameters:
Returns:

On success, 0 is returned. On error, negative errno is returned.

xnvme_dev_fpr

int xnvme_dev_fpr(FILE *stream, const struct xnvme_dev *dev, int opts)

Prints the given xnvme_dev to the given output stream.

Parameters:
  • stream – output stream used for printing

  • dev – pointer to structure to print

  • opts – printer options, see xnvme_pr

Returns:

On success, the number of characters printed is returned.

xnvme_dev_get_be_state

const void *xnvme_dev_get_be_state(const struct xnvme_dev *dev)

Returns the internal backend state of the given dev

Parameters:
Returns:

On success, the internal backend state is returned.

xnvme_dev_get_csi

uint8_t xnvme_dev_get_csi(const struct xnvme_dev *dev)

Returns the NVMe Command Set Identifier associated with the given dev

Parameters:
Returns:

On success, NVMe Command Set Identifier is returned

xnvme_dev_get_ctrlr

const struct xnvme_spec_idfy_ctrlr *xnvme_dev_get_ctrlr(const struct xnvme_dev *dev)

Returns the NVMe identify controller structure associated with the given device.

Parameters:
Returns:

On success, pointer to namespace structure. On error, NULL is returned and errno is set to indicate the error

xnvme_dev_get_ctrlr_css

const struct xnvme_spec_idfy_ctrlr *xnvme_dev_get_ctrlr_css(const struct xnvme_dev *dev)

Returns the NVMe identify controller structure specific to the Command Set and Namespace associated with the given device.

Parameters:
Returns:

On success, pointer to namespace structure. On error, NULL is returned and errno is set to indicate the error

xnvme_dev_get_geo

const struct xnvme_geo *xnvme_dev_get_geo(const struct xnvme_dev *dev)

Returns the geometry of the given device.

Parameters:
Returns:

The geometry (struct xnvme_geo) of given device handle

xnvme_dev_get_ident

const struct xnvme_ident *xnvme_dev_get_ident(const struct xnvme_dev *dev)

Returns the representation of device identifier once decoded from text-representation for the given dev

Parameters:
Returns:

On success, device identifier is returned

xnvme_dev_get_ns

const struct xnvme_spec_idfy_ns *xnvme_dev_get_ns(const struct xnvme_dev *dev)

Returns the NVMe identify namespace structure associated with the given device.

Parameters:
Returns:

On success, pointer to namespace structure. On error, NULL is returned and errno is set to indicate the error

xnvme_dev_get_ns_css

const struct xnvme_spec_idfy_ns *xnvme_dev_get_ns_css(const struct xnvme_dev *dev)

Returns the NVMe identify namespace structure specific to the Command Set and Namespace associated with the given device.

Parameters:
Returns:

On success, pointer to namespace structure. On error, NULL is returned and errno is set to indicate the error

xnvme_dev_get_nsid

uint32_t xnvme_dev_get_nsid(const struct xnvme_dev *dev)

Returns the NVMe namespace identifier associated with the given dev

Parameters:
Returns:

On success, NVMe namespace identifier is returned

xnvme_dev_get_opts

const struct xnvme_opts *xnvme_dev_get_opts(const struct xnvme_dev *dev)

Returns the opts struct for the given dev

Parameters:
Returns:

On success, device options are returned

xnvme_dev_get_ssw

uint64_t xnvme_dev_get_ssw(const struct xnvme_dev *dev)

Returns the sector-shift-width of the device, that is, the value used for converting block-device offset to lba, and vice-versa.

lba = ofz >> ssw ofz = lba << ssw

Returns:

On success, the ssw is returned.

xnvme_dev_open

struct xnvme_dev *xnvme_dev_open(const char *dev_uri, struct xnvme_opts *opts)

Creates a device handle (xnvme_dev) based on the given device-uri.

Parameters:
  • dev_uri – File path “/dev/nvme0n1” or “0000:04.01”

  • opts – Options for library backend and system-interfaces

Returns:

On success, a handle to the device. On error, NULL is returned and errno set to indicate the error.

xnvme_dev_pr

int xnvme_dev_pr(const struct xnvme_dev *dev, int opts)

Prints the given xnvme_dev to stdout.

Parameters:
  • dev – pointer to structure to print

  • opts – printer options, see xnvme_pr

Returns:

On success, the number of characters printed is returned.