Debian Codegraph @

src/lib/plugin_apis/swap.api

raw
1 #include <glib.h>
2 #include <blockdev/utils.h>
3
4 #ifndef BD_SWAP_API
5 #define BD_SWAP_API
6
7 GQuark bd_swap_error_quark (void) {
8 return g_quark_from_static_string ("g-bd-swap-error-quark");
9 }
10
11 #define BD_SWAP_ERROR bd_swap_error_quark ()
12 typedef enum {
13 BD_SWAP_ERROR_TECH_UNAVAIL,
14 BD_SWAP_ERROR_UNKNOWN_STATE,
15 BD_SWAP_ERROR_ACTIVATE,
16 BD_SWAP_ERROR_ACTIVATE_OLD,
17 BD_SWAP_ERROR_ACTIVATE_SUSPEND,
18 BD_SWAP_ERROR_ACTIVATE_UNKNOWN,
19 BD_SWAP_ERROR_ACTIVATE_PAGESIZE,
20 BD_SWAP_ERROR_LABEL_INVALID,
21 BD_SWAP_ERROR_UUID_INVALID,
22 } BDSwapError;
23
24 typedef enum {
25 BD_SWAP_TECH_SWAP = 0,
26 } BDSwapTech;
27
28 typedef enum {
29 BD_SWAP_TECH_MODE_CREATE = 1 << 0,
30 BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE = 1 << 1,
31 BD_SWAP_TECH_MODE_QUERY = 1 << 2,
32 BD_SWAP_TECH_MODE_SET_LABEL = 1 << 3,
33 BD_SWAP_TECH_MODE_SET_UUID = 1 << 4,
34 } BDSwapTechMode;
35
36 /**
37 * bd_swap_is_tech_avail:
38 * @tech: the queried tech
39 * @mode: a bit mask of queried modes of operation (#BDSwapTechMode) for @tech
40 * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available)
41 *
42 * Returns: whether the @tech-@mode combination is available -- supported by the
43 * plugin implementation and having all the runtime dependencies available
44 */
45 gboolean bd_swap_is_tech_avail (BDSwapTech tech, guint64 mode, GError **error);
46
47 /**
48 * bd_swap_mkswap:
49 * @device: a device to create swap space on
50 * @label: (nullable): a label for the swap space device
51 * @uuid: (nullable): UUID for the swap space device
52 * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now
53 * passed to the 'mkswap' utility)
54 * @error: (out) (optional): place to store error (if any)
55 *
56 * Returns: whether the swap space was successfully created or not
57 *
58 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_CREATE
59 */
60 gboolean bd_swap_mkswap (const gchar *device, const gchar *label, const gchar *uuid, const BDExtraArg **extra, GError **error);
61
62 /**
63 * bd_swap_swapon:
64 * @device: swap device to activate
65 * @priority: priority of the activated device or -1 to use the default
66 * @error: (out) (optional): place to store error (if any)
67 *
68 * Returns: whether the swap device was successfully activated or not
69 *
70 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE
71 */
72 gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error);
73
74 /**
75 * bd_swap_swapoff:
76 * @device: swap device to deactivate
77 * @error: (out) (optional): place to store error (if any)
78 *
79 * Returns: whether the swap device was successfully deactivated or not
80 *
81 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE
82 */
83 gboolean bd_swap_swapoff (const gchar *device, GError **error);
84
85 /**
86 * bd_swap_swapstatus:
87 * @device: swap device to get status of
88 * @error: (out) (optional): place to store error (if any)
89 *
90 * Returns: %TRUE if the swap device is active, %FALSE if not active or failed
91 * to determine (@error) is set not a non-NULL value in such case)
92 *
93 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_QUERY
94 */
95 gboolean bd_swap_swapstatus (const gchar *device, GError **error);
96
97 /**
98 * bd_swap_check_label:
99 * @label: label to check
100 * @error: (out) (optional): place to store error
101 *
102 * Returns: whether @label is a valid label for swap or not
103 * (reason is provided in @error)
104 *
105 * Tech category: always available
106 */
107 gboolean bd_swap_check_label (const gchar *label, GError **error);
108
109 /**
110 * bd_swap_set_label:
111 * @device: a device to set label on
112 * @label: label that will be set
113 * @error: (out) (optional): place to store error (if any)
114 *
115 * Returns: whether the label was successfully set or not
116 *
117 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_SET_LABEL
118 */
119 gboolean bd_swap_set_label (const gchar *device, const gchar *label, GError **error);
120
121 /**
122 * bd_swap_check_uuid:
123 * @uuid: UUID to check
124 * @error: (out) (optional): place to store error
125 *
126 * Returns: whether @uuid is a valid UUID for swap or not
127 * (reason is provided in @error)
128 *
129 * Tech category: always available
130 */
131 gboolean bd_swap_check_uuid (const gchar *uuid, GError **error);
132
133 /**
134 * bd_swap_set_uuid:
135 * @device: a device to set UUID on
136 * @uuid: UUID that will be set
137 * @error: (out) (optional): place to store error (if any)
138 *
139 * Returns: whether the UUID was successfully set or not
140 *
141 * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_SET_UUID
142 */
143 gboolean bd_swap_set_uuid (const gchar *device, const gchar *uuid, GError **error);
144
145 #endif /* BD_SWAP_API */