Disk statistics interface

## Data Structures

struct | sa_disk

## Functions

int | sa_open_disk (void) SA_EXPORT
int | sa_close_disk (void) SA_EXPORT
int | sa_count_disks (uint16_t *number) SA_EXPORT SA_NONNULL
int | sa_reset_disks () SA_EXPORT
int | sa_get_disks_ids (char *dst, uint16_t dst_size, uint16_t *written) SA_EXPORT SA_NONNULL
int | sa_get_disk (char *name, struct sa_disk *dst) SA_EXPORT SA_NONNULL
int | sa_get_disks (struct sa_disk *dst, uint16_t dst_size, uint16_t *written) SA_EXPORT SA_NONNULL

## Detailed Description

## Function Documentation

int sa_open_disk | ( | void |  | ) |

Prepares the resources needed for retrieving disk statistics. This function exists (and is needed) only when SA_OPEN_DISK is defined.

Returns
  If successful 0 is returned, otherwise an error code is returned. If the operating system is not supported the return value will be ENOTSUP.

See also
  sa_close_disk()

Since
  0.6.0

int sa_close_disk | ( | void |  | ) |

This function closes the resources used for retrieving disk statistics. You should call it even when there was a previous error in another function of this API. This function exists (and is needed) only when SA_CLOSE_DISK is defined.

Returns
  If successful 0 is returned, otherwise an error code is returned.

See also
  sa_open_disk()

Since
  0.6.0

int sa_count_disks | ( | uint16_t * | number | ) |

Gives the total number of disks. You don't need to call sa_reset_disks() before this function.

Parameters

  number | The number will be stored here

Returns
  If successful 0 is returned, otherwise an error code is returned.

Since
  0.6.0

int sa_reset_disks | ( |  | ) |

Refreshes the underlying operating system cache.

Returns
  If successful 0 is returned, otherwise an error code is returned.

Since
  0.6.0

int sa_get_disks_ids | ( | char * | dst,
|  | uint16_t | dst_size,
|  | uint16_t * | written
| ) |  |

Returns a list of the existing disks ids. The array will be fully populated even if it's not big enough (but ENOMEM is returned). sa_reset_disks() should be called at least once before this function and everytime you need fresh values.

Parameters

  dst | Where the statistics will be stored.
  dst_size | The number of ids that fits on the dst pointer.
  written | The number of disks ids written.

Returns
  If successful 0 is returned, otherwise an error code is returned. ENODEV is returned when there are no more disks available.

Since
  0.6.0

int sa_get_disk | ( | char * | name,
|  | struct sa_disk * | dst
| ) |  |

Retrieves statistics from a disk identified by its device name. sa_reset_disks() should be called at least once before this function and everytime you need fresh values.

Parameters

  name | The name of the disk.
  dst | Where the statistics will be stored.

Returns
  If successful 0 is returned, otherwise an error code is returned. ENODEV is returned when the requested device was not found.

Since
  0.6.0

int sa_get_disks | ( | struct sa_disk * | dst,
|  | uint16_t | dst_size,
|  | uint16_t * | written
| ) |  |

Retrieves statistics about all the disks' activity. sa_reset_disks() should be called at least once before this function and everytime you need fresh values.

Parameters

  dst | A buffer where the statistics will be stored.
  dst_size | The number of devices that fits in the dst buffer. If it's not big enough dst will be filled but ENOMEM will be returned.
  written | The amount of device statistics written.

Returns
  If successful 0 is returned, otherwise an error code is returned.

Since
  0.6.0