Swap devices interface

## Data Structures

struct | sa_swap

## Functions

int | sa_open_swap (void) SA_EXPORT
int | sa_close_swap (void) SA_EXPORT
int | sa_count_swaps (uint16_t *number) SA_EXPORT SA_NONNULL
int | sa_reset_swaps () SA_EXPORT
int | sa_get_swap (uint16_t index, struct sa_swap *dst) SA_EXPORT SA_NONNULL
int | sa_get_swaps (struct sa_swap *dst, uint16_t dst_size, uint16_t *written) SA_EXPORT SA_NONNULL

## Detailed Description

## Function Documentation

int sa_open_swap | ( | void |  | ) |

Prepares the resources needed for retrieving swap statistics. This function exists (and is needed) only when SA_OPEN_SWAP 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_swap()

int sa_close_swap | ( | void |  | ) |

This function closes the resources used for retrieving swap 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_SWAP is defined.

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

See also
  sa_open_swap()

int sa_count_swaps | ( | uint16_t * | number | ) |

Gives the total number of swap file systems. You don't need to call sa_reset_swaps() before this function.

Parameters

  number | The number will be stored here

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

int sa_reset_swaps | ( |  | ) |

Refreshes the underlying operating system cache.

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

int sa_get_swap | ( | uint16_t | index,
|  | struct sa_swap * | dst
| ) |  |

Retrieves statistics from a given swap index. sa_reset_swaps() should be called at least once before this function and everytime you need fresh values.

Parameters

  index | The swap index. It starts from 0.
  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 swap index was out of range.

int sa_get_swaps | ( | struct sa_swap * | dst,
|  | uint16_t | dst_size,
|  | uint16_t * | written
| ) |  |

Retrieves statistics from as many swap fs as possible. sa_reset_swaps() 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 swap fs 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 swap fs statistics written.

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