Debian Codegraph @

src/shared/blockdev-list.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "shared-forward.h"
5
6 typedef enum BlockDevListFlags {
7 BLOCKDEV_LIST_SHOW_SYMLINKS = 1 << 0, /* Pick up symlinks to block devices too */
8 BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING = 1 << 1, /* Only consider block devices with partition scanning */
9 BLOCKDEV_LIST_IGNORE_ZRAM = 1 << 2, /* Ignore ZRAM */
10 BLOCKDEV_LIST_REQUIRE_LUKS = 1 << 3, /* Only consider block devices with LUKS superblocks */
11 BLOCKDEV_LIST_IGNORE_ROOT = 1 << 4, /* Ignore the block device we are currently booted from */
12 BLOCKDEV_LIST_IGNORE_EMPTY = 1 << 5, /* Ignore disks of zero size (usually drives without a medium) */
13 BLOCKDEV_LIST_METADATA = 1 << 6, /* Fill in model, vendor, subsystem, read_only */
14 BLOCKDEV_LIST_IGNORE_READ_ONLY = 1 << 7, /* Ignore read-only block devices */
15 } BlockDevListFlags;
16
17 typedef struct BlockDevice {
18 char *node;
19 char **symlinks;
20 char *model;
21 char *vendor;
22 char *subsystem;
23 uint64_t diskseq;
24 uint64_t size; /* in bytes */
25 int read_only;
26 } BlockDevice;
27
28 #define BLOCK_DEVICE_NULL (BlockDevice) { \
29 .diskseq = UINT64_MAX, \
30 .size = UINT64_MAX, \
31 .read_only = -1, \
32 }
33
34 void block_device_done(BlockDevice *d);
35 void block_device_array_free(BlockDevice *d, size_t n_devices);
36
37 int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *ret_n_devices);