| 1 |
#include <glib.h> |
| 2 |
#include <glib-object.h> |
| 3 |
#include <blockdev/utils.h> |
| 4 |
|
| 5 |
#ifndef BD_BTRFS_API |
| 6 |
#define BD_BTRFS_API |
| 7 |
|
| 8 |
#define BD_BTRFS_MAIN_VOLUME_ID 5 |
| 9 |
#define BD_BTRFS_MIN_MEMBER_SIZE G_GUINT64_CONSTANT (134217728ULL) /* 128 MiB */ |
| 10 |
|
| 11 |
GQuark bd_btrfs_error_quark (void) { |
| 12 |
return g_quark_from_static_string ("g-bd-btrfs-error-quark"); |
| 13 |
} |
| 14 |
|
| 15 |
#define BD_BTRFS_ERROR bd_btrfs_error_quark () |
| 16 |
typedef enum { |
| 17 |
BD_BTRFS_ERROR_TECH_UNAVAIL, |
| 18 |
BD_BTRFS_ERROR_DEVICE, |
| 19 |
BD_BTRFS_ERROR_PARSE, |
| 20 |
} BDBtrfsError; |
| 21 |
|
| 22 |
#define BD_BTRFS_TYPE_DEVICE_INFO (bd_btrfs_device_info_get_type ()) |
| 23 |
GType bd_btrfs_device_info_get_type(); |
| 24 |
|
| 25 |
/** |
| 26 |
* BDBtrfsDeviceInfo: |
| 27 |
* @id: ID of the device |
| 28 |
* @path: path of the device |
| 29 |
* @size: size of the device |
| 30 |
* @used: size of the used space |
| 31 |
*/ |
| 32 |
typedef struct BDBtrfsDeviceInfo { |
| 33 |
guint64 id; |
| 34 |
gchar *path; |
| 35 |
guint64 size; |
| 36 |
guint64 used; |
| 37 |
} BDBtrfsDeviceInfo; |
| 38 |
|
| 39 |
/** |
| 40 |
* bd_btrfs_device_info_copy: (skip) |
| 41 |
* @info: (nullable): %BDBtrfsDeviceInfo to copy |
| 42 |
* |
| 43 |
* Creates a new copy of @info. |
| 44 |
*/ |
| 45 |
BDBtrfsDeviceInfo* bd_btrfs_device_info_copy (BDBtrfsDeviceInfo *info) { |
| 46 |
if (info == NULL) |
| 47 |
return NULL; |
| 48 |
|
| 49 |
BDBtrfsDeviceInfo *new_info = g_new0 (BDBtrfsDeviceInfo, 1); |
| 50 |
|
| 51 |
new_info->id = info->id; |
| 52 |
new_info->path = g_strdup (info->path); |
| 53 |
new_info->size = info->size; |
| 54 |
new_info->used = info->used; |
| 55 |
|
| 56 |
return new_info; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* bd_btrfs_device_info_free: (skip) |
| 61 |
* @info: (nullable): %BDBtrfsDeviceInfo to free |
| 62 |
* |
| 63 |
* Frees @info. |
| 64 |
*/ |
| 65 |
void bd_btrfs_device_info_free (BDBtrfsDeviceInfo *info) { |
| 66 |
if (info == NULL) |
| 67 |
return; |
| 68 |
|
| 69 |
g_free (info->path); |
| 70 |
g_free (info); |
| 71 |
} |
| 72 |
|
| 73 |
GType bd_btrfs_device_info_get_type () { |
| 74 |
static GType type = 0; |
| 75 |
|
| 76 |
if (G_UNLIKELY(type == 0)) { |
| 77 |
type = g_boxed_type_register_static("BDBtrfsDeviceInfo", |
| 78 |
(GBoxedCopyFunc) bd_btrfs_device_info_copy, |
| 79 |
(GBoxedFreeFunc) bd_btrfs_device_info_free); |
| 80 |
} |
| 81 |
|
| 82 |
return type; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
#define BD_BTRFS_TYPE_SUBVOLUME_INFO (bd_btrfs_subvolume_info_get_type ()) |
| 87 |
GType bd_btrfs_subvolume_info_get_type(); |
| 88 |
|
| 89 |
/** |
| 90 |
* BDBtrfsSubvolumeInfo: |
| 91 |
* @id: ID of the subvolume |
| 92 |
* @parent_id: ID of the parent (sub)volume |
| 93 |
* @path: path of the subvolume |
| 94 |
*/ |
| 95 |
typedef struct BDBtrfsSubvolumeInfo { |
| 96 |
guint64 id; |
| 97 |
guint64 parent_id; |
| 98 |
gchar *path; |
| 99 |
} BDBtrfsSubvolumeInfo; |
| 100 |
|
| 101 |
/** |
| 102 |
* bd_btrfs_subvolume_info_copy: (skip) |
| 103 |
* @info: (nullable): %BDBtrfsSubvolumeInfo to copy |
| 104 |
* |
| 105 |
* Creates a new copy of @info. |
| 106 |
*/ |
| 107 |
BDBtrfsSubvolumeInfo* bd_btrfs_subvolume_info_copy (BDBtrfsSubvolumeInfo *info) { |
| 108 |
if (info == NULL) |
| 109 |
return NULL; |
| 110 |
|
| 111 |
BDBtrfsSubvolumeInfo *new_info = g_new0 (BDBtrfsSubvolumeInfo, 1); |
| 112 |
|
| 113 |
new_info->id = info->id; |
| 114 |
new_info->parent_id = info->parent_id; |
| 115 |
new_info->path = g_strdup (info->path); |
| 116 |
|
| 117 |
return new_info; |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* bd_btrfs_subvolume_info_free: (skip) |
| 122 |
* @info: (nullable): %BDBtrfsSubvolumeInfo to free |
| 123 |
* |
| 124 |
* Frees @info. |
| 125 |
*/ |
| 126 |
void bd_btrfs_subvolume_info_free (BDBtrfsSubvolumeInfo *info) { |
| 127 |
if (info == NULL) |
| 128 |
return; |
| 129 |
|
| 130 |
g_free (info->path); |
| 131 |
g_free (info); |
| 132 |
} |
| 133 |
|
| 134 |
GType bd_btrfs_subvolume_info_get_type () { |
| 135 |
static GType type = 0; |
| 136 |
|
| 137 |
if (G_UNLIKELY(type == 0)) { |
| 138 |
type = g_boxed_type_register_static("BDBtrfsSubvolumeInfo", |
| 139 |
(GBoxedCopyFunc) bd_btrfs_subvolume_info_copy, |
| 140 |
(GBoxedFreeFunc) bd_btrfs_subvolume_info_free); |
| 141 |
} |
| 142 |
|
| 143 |
return type; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
#define BD_BTRFS_TYPE_FILESYSTEM_INFO (bd_btrfs_filesystem_info_get_type ()) |
| 148 |
GType bd_btrfs_filesystem_info_get_type(); |
| 149 |
|
| 150 |
/** |
| 151 |
* BDBtrfsFilesystemInfo: |
| 152 |
* @label: label of the filesystem |
| 153 |
* @uuid: uuid of the filesystem |
| 154 |
* @num_devices: number of device in the filesystem |
| 155 |
* @used: size of the used space |
| 156 |
*/ |
| 157 |
typedef struct BDBtrfsFilesystemInfo { |
| 158 |
gchar *label; |
| 159 |
gchar *uuid; |
| 160 |
guint64 num_devices; |
| 161 |
guint64 used; |
| 162 |
} BDBtrfsFilesystemInfo; |
| 163 |
|
| 164 |
/** |
| 165 |
* bd_btrfs_filesystem_info_copy: (skip) |
| 166 |
* @info: (nullable): %BDBtrfsFilesystemInfo to copy |
| 167 |
* |
| 168 |
* Creates a new copy of @info. |
| 169 |
*/ |
| 170 |
BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info_copy (BDBtrfsFilesystemInfo *info) { |
| 171 |
if (info == NULL) |
| 172 |
return NULL; |
| 173 |
|
| 174 |
BDBtrfsFilesystemInfo *new_info = g_new0 (BDBtrfsFilesystemInfo, 1); |
| 175 |
|
| 176 |
new_info->label = g_strdup (info->label); |
| 177 |
new_info->uuid = g_strdup (info->uuid); |
| 178 |
new_info->num_devices = info->num_devices; |
| 179 |
new_info->used = info->used; |
| 180 |
|
| 181 |
return new_info; |
| 182 |
} |
| 183 |
|
| 184 |
/** |
| 185 |
* bd_btrfs_filesystem_info_free: (skip) |
| 186 |
* @info: (nullable): %BDBtrfsFilesystemInfo to free |
| 187 |
* |
| 188 |
* Frees @info. |
| 189 |
*/ |
| 190 |
void bd_btrfs_filesystem_info_free (BDBtrfsFilesystemInfo *info) { |
| 191 |
if (info == NULL) |
| 192 |
return; |
| 193 |
|
| 194 |
g_free (info->label); |
| 195 |
g_free (info->uuid); |
| 196 |
g_free (info); |
| 197 |
} |
| 198 |
|
| 199 |
GType bd_btrfs_filesystem_info_get_type () { |
| 200 |
static GType type = 0; |
| 201 |
|
| 202 |
if (G_UNLIKELY(type == 0)) { |
| 203 |
type = g_boxed_type_register_static("BDBtrfsFilesystemInfo", |
| 204 |
(GBoxedCopyFunc) bd_btrfs_filesystem_info_copy, |
| 205 |
(GBoxedFreeFunc) bd_btrfs_filesystem_info_free); |
| 206 |
} |
| 207 |
|
| 208 |
return type; |
| 209 |
} |
| 210 |
|
| 211 |
#define BD_BTRFS_TYPE_DEVICE_STATS (bd_btrfs_device_stats_get_type ()) |
| 212 |
GType bd_btrfs_device_stats_get_type(); |
| 213 |
|
| 214 |
/** |
| 215 |
* BDBtrfsDeviceStats: |
| 216 |
* @id: ID of the device |
| 217 |
* @path: path of the device |
| 218 |
* @write_io_errs: number of write I/O errors |
| 219 |
* @read_io_errs: number of read I/O errors |
| 220 |
* @flush_io_errs: number of flush I/O errors |
| 221 |
* @corruption_errs: number of corruption errors |
| 222 |
* @generation_errs: number of generation errors |
| 223 |
*/ |
| 224 |
typedef struct BDBtrfsDeviceStats { |
| 225 |
guint64 id; |
| 226 |
gchar *path; |
| 227 |
guint64 write_io_errs; |
| 228 |
guint64 read_io_errs; |
| 229 |
guint64 flush_io_errs; |
| 230 |
guint64 corruption_errs; |
| 231 |
guint64 generation_errs; |
| 232 |
} BDBtrfsDeviceStats; |
| 233 |
|
| 234 |
/** |
| 235 |
* bd_btrfs_device_stats_copy: (skip) |
| 236 |
* @stats: (nullable): %BDBtrfsDeviceStats to copy |
| 237 |
* |
| 238 |
* Creates a new copy of @stats. |
| 239 |
*/ |
| 240 |
BDBtrfsDeviceStats* bd_btrfs_device_stats_copy (BDBtrfsDeviceStats *stats) { |
| 241 |
if (stats == NULL) |
| 242 |
return NULL; |
| 243 |
|
| 244 |
BDBtrfsDeviceStats *new_stats = g_new0 (BDBtrfsDeviceStats, 1); |
| 245 |
|
| 246 |
new_stats->id = stats->id; |
| 247 |
new_stats->path = g_strdup (stats->path); |
| 248 |
new_stats->write_io_errs = stats->write_io_errs; |
| 249 |
new_stats->read_io_errs = stats->read_io_errs; |
| 250 |
new_stats->flush_io_errs = stats->flush_io_errs; |
| 251 |
new_stats->corruption_errs = stats->corruption_errs; |
| 252 |
new_stats->generation_errs = stats->generation_errs; |
| 253 |
|
| 254 |
return new_stats; |
| 255 |
} |
| 256 |
|
| 257 |
/** |
| 258 |
* bd_btrfs_device_stats_free: (skip) |
| 259 |
* @stats: (nullable): %BDBtrfsDeviceStats to free |
| 260 |
* |
| 261 |
* Frees @stats. |
| 262 |
*/ |
| 263 |
void bd_btrfs_device_stats_free (BDBtrfsDeviceStats *stats) { |
| 264 |
if (stats == NULL) |
| 265 |
return; |
| 266 |
|
| 267 |
g_free (stats->path); |
| 268 |
g_free (stats); |
| 269 |
} |
| 270 |
|
| 271 |
GType bd_btrfs_device_stats_get_type () { |
| 272 |
static GType type = 0; |
| 273 |
|
| 274 |
if (G_UNLIKELY(type == 0)) { |
| 275 |
type = g_boxed_type_register_static("BDBtrfsDeviceStats", |
| 276 |
(GBoxedCopyFunc) bd_btrfs_device_stats_copy, |
| 277 |
(GBoxedFreeFunc) bd_btrfs_device_stats_free); |
| 278 |
} |
| 279 |
|
| 280 |
return type; |
| 281 |
} |
| 282 |
|
| 283 |
typedef enum { |
| 284 |
BD_BTRFS_TECH_FS = 0, |
| 285 |
BD_BTRFS_TECH_MULTI_DEV, |
| 286 |
BD_BTRFS_TECH_SUBVOL, |
| 287 |
BD_BTRFS_TECH_SNAPSHOT, |
| 288 |
} BDBtrfsTech; |
| 289 |
|
| 290 |
typedef enum { |
| 291 |
BD_BTRFS_TECH_MODE_CREATE = 1 << 0, |
| 292 |
BD_BTRFS_TECH_MODE_DELETE = 1 << 1, |
| 293 |
BD_BTRFS_TECH_MODE_MODIFY = 1 << 2, |
| 294 |
BD_BTRFS_TECH_MODE_QUERY = 1 << 3, |
| 295 |
BD_BTRFS_TECH_MODE_DELETE_RECURSIVE = 1 << 4, |
| 296 |
} BDBtrfsTechMode; |
| 297 |
|
| 298 |
/** |
| 299 |
* bd_btrfs_is_tech_avail: |
| 300 |
* @tech: the queried tech |
| 301 |
* @mode: a bit mask of queried modes of operation (#BDBtrfsTechMode) for @tech |
| 302 |
* @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) |
| 303 |
* |
| 304 |
* Returns: whether the @tech-@mode combination is available -- supported by the |
| 305 |
* plugin implementation and having all the runtime dependencies available |
| 306 |
*/ |
| 307 |
gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech, guint64 mode, GError **error); |
| 308 |
|
| 309 |
|
| 310 |
/** |
| 311 |
* bd_btrfs_create_volume: |
| 312 |
* @devices: (array zero-terminated=1): list of devices to create btrfs volume from |
| 313 |
* @label: (nullable): label for the volume |
| 314 |
* @data_level: (nullable): RAID level for the data or %NULL to use the default |
| 315 |
* @md_level: (nullable): RAID level for the metadata or %NULL to use the default |
| 316 |
* @extra: (nullable) (array zero-terminated=1): extra options for the volume creation (right now |
| 317 |
* passed to the 'mkfs.btrfs' utility) |
| 318 |
* @error: (out) (optional): place to store error (if any) |
| 319 |
* |
| 320 |
* Returns: whether the new btrfs volume was created from @devices or not |
| 321 |
* |
| 322 |
* See mkfs.btrfs(8) for details about @data_level, @md_level and btrfs in general. |
| 323 |
* |
| 324 |
* Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_CREATE |
| 325 |
*/ |
| 326 |
gboolean bd_btrfs_create_volume (const gchar **devices, const gchar *label, const gchar *data_level, const gchar *md_level, const BDExtraArg **extra, GError **error); |
| 327 |
|
| 328 |
/** |
| 329 |
* bd_btrfs_add_device: |
| 330 |
* @mountpoint: mountpoint of the btrfs volume to add new device to |
| 331 |
* @device: a device to add to the btrfs volume |
| 332 |
* @extra: (nullable) (array zero-terminated=1): extra options for the addition (right now |
| 333 |
* passed to the 'btrfs' utility) |
| 334 |
* @error: (out) (optional): place to store error (if any) |
| 335 |
* |
| 336 |
* Returns: whether the @device was successfully added to the @mountpoint btrfs volume or not |
| 337 |
* |
| 338 |
* Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY |
| 339 |
*/ |
| 340 |
gboolean bd_btrfs_add_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error); |
| 341 |
|
| 342 |
/** |
| 343 |
* bd_btrfs_remove_device: |
| 344 |
* @mountpoint: mountpoint of the btrfs volume to remove device from |
| 345 |
* @device: a device to remove from the btrfs volume |
| 346 |
* @extra: (nullable) (array zero-terminated=1): extra options for the removal (right now |
| 347 |
* passed to the 'btrfs' utility) |
| 348 |
* @error: (out) (optional): place to store error (if any) |
| 349 |
* |
| 350 |
* Returns: whether the @device was successfully removed from the @mountpoint btrfs volume or not |
| 351 |
* |
| 352 |
* Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY |
| 353 |
*/ |
| 354 |
gboolean bd_btrfs_remove_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error); |
| 355 |
|
| 356 |
/** |
| 357 |
* bd_btrfs_create_subvolume: |
| 358 |
* @mountpoint: mountpoint of the btrfs volume to create subvolume under |
| 359 |
* @name: name of the subvolume |
| 360 |
* @extra: (nullable) (array zero-terminated=1): extra options for the subvolume creation (right now |
| 361 |
* passed to the 'btrfs' utility) |
| 362 |
* @error: (out) (optional): place to store error (if any) |
| 363 |
* |
| 364 |
* Returns: whether the @mountpoint/@name subvolume was successfully created or not |
| 365 |
* |
| 366 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_CREATE |
| 367 |
*/ |
| 368 |
gboolean bd_btrfs_create_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error); |
| 369 |
|
| 370 |
/** |
| 371 |
* bd_btrfs_delete_subvolume: |
| 372 |
* @mountpoint: mountpoint of the btrfs volume to delete subvolume from |
| 373 |
* @name: name of the subvolume |
| 374 |
* @extra: (nullable) (array zero-terminated=1): extra options for the subvolume deletion (right now |
| 375 |
* passed to the 'btrfs' utility) |
| 376 |
* @error: (out) (optional): place to store error (if any) |
| 377 |
* |
| 378 |
* Returns: whether the @mountpoint/@name subvolume was successfully deleted or not |
| 379 |
* |
| 380 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_DELETE |
| 381 |
*/ |
| 382 |
gboolean bd_btrfs_delete_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error); |
| 383 |
|
| 384 |
/** |
| 385 |
* bd_btrfs_delete_subvolume_recursive: |
| 386 |
* @mountpoint: mountpoint of the btrfs volume to delete subvolume from |
| 387 |
* @name: name of the subvolume |
| 388 |
* @recursive: whether to delete child subvolumes recursively |
| 389 |
* @extra: (nullable) (array zero-terminated=1): extra options for the subvolume deletion (right now |
| 390 |
* passed to the 'btrfs' utility) |
| 391 |
* @error: (out) (optional): place to store error (if any) |
| 392 |
* |
| 393 |
* Returns: whether the @mountpoint/@name subvolume was successfully deleted or not |
| 394 |
* |
| 395 |
* If @recursive is %TRUE, all child subvolumes will be deleted before deleting |
| 396 |
* the subvolume itself. This requires btrfs-progs >= 6.12. |
| 397 |
* |
| 398 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_DELETE if @recursive is %FALSE, |
| 399 |
* %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_DELETE_RECURSIVE if @recursive is %TRUE |
| 400 |
*/ |
| 401 |
gboolean bd_btrfs_delete_subvolume_recursive (const gchar *mountpoint, const gchar *name, gboolean recursive, const BDExtraArg **extra, GError **error); |
| 402 |
|
| 403 |
/** |
| 404 |
* bd_btrfs_get_default_subvolume_id: |
| 405 |
* @mountpoint: mountpoint of the volume to get the default subvolume ID of |
| 406 |
* @error: (out) (optional): place to store error (if any) |
| 407 |
* |
| 408 |
* Returns: ID of the @mountpoint volume's default subvolume. If 0, |
| 409 |
* @error may be set to indicate error |
| 410 |
* |
| 411 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY |
| 412 |
*/ |
| 413 |
guint64 bd_btrfs_get_default_subvolume_id (const gchar *mountpoint, GError **error); |
| 414 |
|
| 415 |
/** |
| 416 |
* bd_btrfs_set_default_subvolume: |
| 417 |
* @mountpoint: mountpoint of the volume to set the default subvolume ID of |
| 418 |
* @subvol_id: ID of the subvolume to be set as the default subvolume |
| 419 |
* @extra: (nullable) (array zero-terminated=1): extra options for the setting (right now |
| 420 |
* passed to the 'btrfs' utility) |
| 421 |
* @error: (out) (optional): place to store error (if any) |
| 422 |
* |
| 423 |
* Returns: whether the @mountpoint volume's default subvolume was correctly set |
| 424 |
* to @subvol_id or not |
| 425 |
* |
| 426 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_MODIFY |
| 427 |
*/ |
| 428 |
gboolean bd_btrfs_set_default_subvolume (const gchar *mountpoint, guint64 subvol_id, const BDExtraArg **extra, GError **error); |
| 429 |
|
| 430 |
/** |
| 431 |
* bd_btrfs_create_snapshot: |
| 432 |
* @source: path to source subvolume |
| 433 |
* @dest: path to new snapshot volume |
| 434 |
* @ro: whether the snapshot should be read-only |
| 435 |
* @extra: (nullable) (array zero-terminated=1): extra options for the snapshot creation (right now |
| 436 |
* passed to the 'btrfs' utility) |
| 437 |
* @error: (out) (optional): place to store error (if any) |
| 438 |
* |
| 439 |
* Returns: whether the @dest snapshot of @source was successfully created or not |
| 440 |
* |
| 441 |
* Tech category: %BD_BTRFS_TECH_SNAPSHOT-%BD_BTRFS_TECH_MODE_CREATE |
| 442 |
*/ |
| 443 |
gboolean bd_btrfs_create_snapshot (const gchar *source, const gchar *dest, gboolean ro, const BDExtraArg **extra, GError **error); |
| 444 |
|
| 445 |
/** |
| 446 |
* bd_btrfs_list_devices: |
| 447 |
* @device: a device that is part of the queried btrfs volume |
| 448 |
* @error: (out) (optional): place to store error (if any) |
| 449 |
* |
| 450 |
* Returns: (array zero-terminated=1): information about the devices that are part of the btrfs volume |
| 451 |
* containing @device or %NULL in case of error |
| 452 |
* |
| 453 |
* Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_QUERY |
| 454 |
*/ |
| 455 |
BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error); |
| 456 |
|
| 457 |
/** |
| 458 |
* bd_btrfs_list_subvolumes: |
| 459 |
* @mountpoint: a mountpoint of the queried btrfs volume |
| 460 |
* @snapshots_only: whether to list only snapshot subvolumes or not |
| 461 |
* @error: (out) (optional): place to store error (if any) |
| 462 |
* |
| 463 |
* Returns: (array zero-terminated=1): information about the subvolumes that are part of the btrfs volume |
| 464 |
* mounted at @mountpoint or %NULL in case of error |
| 465 |
* |
| 466 |
* The subvolumes are sorted in a way that no child subvolume appears in the |
| 467 |
* list before its parent (sub)volume. |
| 468 |
* |
| 469 |
* Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY |
| 470 |
*/ |
| 471 |
BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboolean snapshots_only, GError **error); |
| 472 |
|
| 473 |
/** |
| 474 |
* bd_btrfs_filesystem_info: |
| 475 |
* @device: a device that is part of the queried btrfs volume |
| 476 |
* @error: (out) (optional): place to store error (if any) |
| 477 |
* |
| 478 |
* Returns: information about the @device's volume's filesystem or %NULL in case of error |
| 479 |
* |
| 480 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_QUERY |
| 481 |
*/ |
| 482 |
BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info (const gchar *device, GError **error); |
| 483 |
|
| 484 |
/** |
| 485 |
* bd_btrfs_mkfs: |
| 486 |
* @devices: (array zero-terminated=1): list of devices to create btrfs volume from |
| 487 |
* @label: (nullable): label for the volume |
| 488 |
* @data_level: (nullable): RAID level for the data or %NULL to use the default |
| 489 |
* @md_level: (nullable): RAID level for the metadata or %NULL to use the default |
| 490 |
* @extra: (nullable) (array zero-terminated=1): extra options for the volume creation (right now |
| 491 |
* passed to the 'btrfs' utility) |
| 492 |
* @error: (out) (optional): place to store error (if any) |
| 493 |
* |
| 494 |
* Returns: whether the new btrfs volume was created from @devices or not |
| 495 |
* |
| 496 |
* See mkfs.btrfs(8) for details about @data_level, @md_level and btrfs in general. |
| 497 |
* |
| 498 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_CREATE |
| 499 |
*/ |
| 500 |
gboolean bd_btrfs_mkfs (const gchar **devices, const gchar *label, const gchar *data_level, const gchar *md_level, const BDExtraArg **extra, GError **error); |
| 501 |
|
| 502 |
/** |
| 503 |
* bd_btrfs_resize: |
| 504 |
* @mountpoint: a mountpoint of the to be resized btrfs filesystem |
| 505 |
* @size: requested new size |
| 506 |
* @extra: (nullable) (array zero-terminated=1): extra options for the volume resize (right now |
| 507 |
* passed to the 'btrfs' utility) |
| 508 |
* @error: (out) (optional): place to store error (if any) |
| 509 |
* |
| 510 |
* Returns: whether the @mountpoint filesystem was successfully resized to @size |
| 511 |
* or not |
| 512 |
* |
| 513 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY |
| 514 |
*/ |
| 515 |
gboolean bd_btrfs_resize (const gchar *mountpoint, guint64 size, const BDExtraArg **extra, GError **error); |
| 516 |
|
| 517 |
/** |
| 518 |
* bd_btrfs_check: |
| 519 |
* @device: a device that is part of the checked btrfs volume |
| 520 |
* @extra: (nullable) (array zero-terminated=1): extra options for the check (right now |
| 521 |
* passed to the 'btrfs' utility) |
| 522 |
* @error: (out) (optional): place to store error (if any) |
| 523 |
* |
| 524 |
* Returns: whether the filesystem was successfully checked or not |
| 525 |
* |
| 526 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_QUERY |
| 527 |
*/ |
| 528 |
gboolean bd_btrfs_check (const gchar *device, const BDExtraArg **extra, GError **error); |
| 529 |
|
| 530 |
/** |
| 531 |
* bd_btrfs_repair: |
| 532 |
* @device: a device that is part of the to be repaired btrfs volume |
| 533 |
* @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now |
| 534 |
* passed to the 'btrfs' utility) |
| 535 |
* @error: (out) (optional): place to store error (if any) |
| 536 |
* |
| 537 |
* Returns: whether the filesystem was successfully checked and repaired or not |
| 538 |
* |
| 539 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY |
| 540 |
*/ |
| 541 |
gboolean bd_btrfs_repair (const gchar *device, const BDExtraArg **extra, GError **error); |
| 542 |
|
| 543 |
/** |
| 544 |
* bd_btrfs_change_label: |
| 545 |
* @mountpoint: a mountpoint of the btrfs filesystem to change label of |
| 546 |
* @label: new label for the filesystem |
| 547 |
* @error: (out) (optional): place to store error (if any) |
| 548 |
* |
| 549 |
* Returns: whether the label of the @mountpoint filesystem was successfully set |
| 550 |
* to @label or not |
| 551 |
* |
| 552 |
* Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY |
| 553 |
*/ |
| 554 |
gboolean bd_btrfs_change_label (const gchar *mountpoint, const gchar *label, GError **error); |
| 555 |
|
| 556 |
/** |
| 557 |
* bd_btrfs_device_stats: |
| 558 |
* @mountpoint: a mountpoint of the queried btrfs volume |
| 559 |
* @error: (out) (optional): place to store error (if any) |
| 560 |
* |
| 561 |
* Returns: (array zero-terminated=1): device stats for each device that is part of the btrfs volume |
| 562 |
* mounted at @mountpoint or %NULL in case of error |
| 563 |
* |
| 564 |
* Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_QUERY |
| 565 |
*/ |
| 566 |
BDBtrfsDeviceStats** bd_btrfs_device_stats (const gchar *mountpoint, GError **error); |
| 567 |
|
| 568 |
#endif /* BD_BTRFS_API */ |