## Swap

Swap — plugin for operations with swap space

## Functions

gboolean | bd_swap_init ()
void | bd_swap_close ()
GQuark | bd_swap_error_quark ()
gboolean | bd_swap_mkswap ()
gboolean | bd_swap_swapon ()
gboolean | bd_swap_swapoff ()
gboolean | bd_swap_swapstatus ()
gboolean | bd_swap_check_label ()
gboolean | bd_swap_set_label ()
gboolean | bd_swap_check_uuid ()
gboolean | bd_swap_set_uuid ()
gboolean | bd_swap_is_tech_avail ()

## Types and Values

#define | BD_SWAP_ERROR
enum | BDSwapError
enum | BDSwapTech
enum | BDSwapTechMode

## Includes

    #include <swap.h>

## Description

A plugin for operations with swap space.

## Functions

### bd_swap_init ()

    gboolean
    bd_swap_init (void);

Initializes the plugin. **This function is called automatically by the library's initialization functions.**

### bd_swap_close ()

    void
    bd_swap_close (void);

Cleans up after the plugin. **This function is called automatically by the library's functions that unload it.**

### bd_swap_error_quark ()

    GQuark
    bd_swap_error_quark (void);

[skip]

### bd_swap_mkswap ()

    gboolean
    bd_swap_mkswap (const gchar *device,
                    const gchar *label,
                    const gchar *uuid,
                    const BDExtraArg **extra,
                    GError **error);

#### Parameters

device | a device to create swap space on |
label | a label for the swap space device. | [nullable]
uuid | UUID for the swap space device. | [nullable]
extra | extra options for the creation (right now passed to the 'mkswap' utility). | [nullable][array zero-terminated=1]
error | place to store error (if any). | [out][optional]

#### Returns

whether the swap space was successfully created or not

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_CREATE`

### bd_swap_swapon ()

    gboolean
    bd_swap_swapon (const gchar *device,
                    gint priority,
                    GError **error);

#### Parameters

device | swap device to activate |
priority | priority of the activated device or -1 to use the default |
error | place to store error (if any). | [out][optional]

#### Returns

whether the swap device was successfully activated or not

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE`

### bd_swap_swapoff ()

    gboolean
    bd_swap_swapoff (const gchar *device,
                     GError **error);

#### Parameters

device | swap device to deactivate |
error | place to store error (if any). | [out][optional]

#### Returns

whether the swap device was successfully deactivated or not

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE`

### bd_swap_swapstatus ()

    gboolean
    bd_swap_swapstatus (const gchar *device,
                        GError **error);

#### Parameters

device | swap device to get status of |
error | place to store error (if any). | [out][optional]

#### Returns

`TRUE` if the swap device is active, `FALSE` if not active or failed to determine (`error` ) is set not a non-NULL value in such case)

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_QUERY`

### bd_swap_check_label ()

    gboolean
    bd_swap_check_label (const gchar *label,
                         GError **error);

#### Parameters

label | label to check |
error | place to store error. | [out][optional]

#### Returns

whether `label` is a valid label for swap or not (reason is provided in `error` )

Tech category: always available

### bd_swap_set_label ()

    gboolean
    bd_swap_set_label (const gchar *device,
                       const gchar *label,
                       GError **error);

#### Parameters

device | a device to set label on |
label | label that will be set |
error | place to store error (if any). | [out][optional]

#### Returns

whether the label was successfully set or not

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_SET_LABEL`

### bd_swap_check_uuid ()

    gboolean
    bd_swap_check_uuid (const gchar *uuid,
                        GError **error);

#### Parameters

uuid | UUID to check |
error | place to store error. | [out][optional]

#### Returns

whether `uuid` is a valid UUID for swap or not (reason is provided in `error` )

Tech category: always available

### bd_swap_set_uuid ()

    gboolean
    bd_swap_set_uuid (const gchar *device,
                      const gchar *uuid,
                      GError **error);

#### Parameters

device | a device to set UUID on |
uuid | UUID that will be set |
error | place to store error (if any). | [out][optional]

#### Returns

whether the UUID was successfully set or not

Tech category: `BD_SWAP_TECH_SWAP`-`BD_SWAP_TECH_MODE_SET_UUID`

### bd_swap_is_tech_avail ()

    gboolean
    bd_swap_is_tech_avail (BDSwapTech tech,
                           guint64 mode,
                           GError **error);

#### Parameters

tech | the queried tech |
mode | a bit mask of queried modes of operation (BDSwapTechMode) for `tech` |
error | place to store error (details about why the `tech` -`mode` combination is not available). | [out][optional]

#### Returns

whether the `tech` -`mode` combination is available -- supported by the plugin implementation and having all the runtime dependencies available

## Types and Values

### BD_SWAP_ERROR

    #define             BD_SWAP_ERROR

### enum BDSwapError

#### Members

BD_SWAP_ERROR_TECH_UNAVAIL |  |
BD_SWAP_ERROR_UNKNOWN_STATE |  |
BD_SWAP_ERROR_ACTIVATE |  |
BD_SWAP_ERROR_ACTIVATE_OLD |  |
BD_SWAP_ERROR_ACTIVATE_SUSPEND |  |
BD_SWAP_ERROR_ACTIVATE_UNKNOWN |  |
BD_SWAP_ERROR_ACTIVATE_PAGESIZE |  |
BD_SWAP_ERROR_LABEL_INVALID |  |
BD_SWAP_ERROR_UUID_INVALID |  |

### enum BDSwapTech

#### Members

BD_SWAP_TECH_SWAP |  |

### enum BDSwapTechMode

#### Members

BD_SWAP_TECH_MODE_CREATE |  |
BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE |  |
BD_SWAP_TECH_MODE_QUERY |  |
BD_SWAP_TECH_MODE_SET_LABEL |  |
BD_SWAP_TECH_MODE_SET_UUID |  |