Debian Codegraph @

src/shared/blkid-util.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "sd-dlopen.h"
5
6 #include "shared-forward.h"
7
8 #if HAVE_BLKID
9
10 #include <blkid.h>
11
12 #include "dlfcn-util.h"
13
14 extern DLSYM_PROTOTYPE(blkid_do_fullprobe);
15 extern DLSYM_PROTOTYPE(blkid_do_probe);
16 extern DLSYM_PROTOTYPE(blkid_do_safeprobe);
17 extern DLSYM_PROTOTYPE(blkid_do_wipe);
18 extern DLSYM_PROTOTYPE(blkid_encode_string);
19 extern DLSYM_PROTOTYPE(blkid_free_probe);
20 extern DLSYM_PROTOTYPE(blkid_new_probe);
21 extern DLSYM_PROTOTYPE(blkid_new_probe_from_filename);
22 extern DLSYM_PROTOTYPE(blkid_partition_get_flags);
23 extern DLSYM_PROTOTYPE(blkid_partition_get_name);
24 extern DLSYM_PROTOTYPE(blkid_partition_get_partno);
25 extern DLSYM_PROTOTYPE(blkid_partition_get_size);
26 extern DLSYM_PROTOTYPE(blkid_partition_get_start);
27 extern DLSYM_PROTOTYPE(blkid_partition_get_type);
28 extern DLSYM_PROTOTYPE(blkid_partition_get_type_string);
29 extern DLSYM_PROTOTYPE(blkid_partition_get_uuid);
30 extern DLSYM_PROTOTYPE(blkid_partlist_devno_to_partition);
31 extern DLSYM_PROTOTYPE(blkid_partlist_get_partition);
32 extern DLSYM_PROTOTYPE(blkid_partlist_numof_partitions);
33 extern DLSYM_PROTOTYPE(blkid_probe_enable_partitions);
34 extern DLSYM_PROTOTYPE(blkid_probe_enable_superblocks);
35 extern DLSYM_PROTOTYPE(blkid_probe_filter_superblocks_type);
36 extern DLSYM_PROTOTYPE(blkid_probe_filter_superblocks_usage);
37 extern DLSYM_PROTOTYPE(blkid_probe_get_fd);
38 extern DLSYM_PROTOTYPE(blkid_probe_get_partitions);
39 extern DLSYM_PROTOTYPE(blkid_probe_get_size);
40 extern DLSYM_PROTOTYPE(blkid_probe_get_value);
41 extern DLSYM_PROTOTYPE(blkid_probe_is_wholedisk);
42 extern DLSYM_PROTOTYPE(blkid_probe_lookup_value);
43 extern DLSYM_PROTOTYPE(blkid_probe_numof_values);
44 extern DLSYM_PROTOTYPE(blkid_probe_set_device);
45 extern DLSYM_PROTOTYPE(blkid_probe_set_hint);
46 extern DLSYM_PROTOTYPE(blkid_probe_set_partitions_flags);
47 extern DLSYM_PROTOTYPE(blkid_probe_set_sectorsize);
48 extern DLSYM_PROTOTYPE(blkid_probe_set_superblocks_flags);
49 extern DLSYM_PROTOTYPE(blkid_safe_string);
50
51 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(blkid_probe, sym_blkid_free_probe, blkid_free_probep, NULL);
52
53 int blkid_partition_get_uuid_id128(blkid_partition p, sd_id128_t *ret);
54
55 int blkid_partition_get_type_id128(blkid_partition p, sd_id128_t *ret);
56
57 /* Define symbolic names for blkid_do_safeprobe() return values, since blkid only uses literal numbers. We
58 * prefix these symbolic definitions with underscores, to not invade libblkid's namespace needlessly. */
59 enum {
60 _BLKID_SAFEPROBE_FOUND = 0,
61 _BLKID_SAFEPROBE_NOT_FOUND = 1,
62 _BLKID_SAFEPROBE_AMBIGUOUS = -2,
63 _BLKID_SAFEPROBE_ERROR = -1,
64 };
65
66 int blkid_probe_lookup_value_id128(blkid_probe b, const char *field, sd_id128_t *ret);
67 int blkid_probe_lookup_value_u64(blkid_probe b, const char *field, uint64_t *ret);
68
69 #define LIBBLKID_NOTE(priority) \
70 SD_ELF_NOTE_DLOPEN("blkid", \
71 "Support for block device identification", \
72 priority, \
73 "libblkid.so.1")
74
75 #define DLOPEN_LIBBLKID(log_level, priority) \
76 ({ \
77 LIBBLKID_NOTE(priority); \
78 dlopen_libblkid(log_level); \
79 })
80 #else
81 #define DLOPEN_LIBBLKID(log_level, priority) dlopen_libblkid(log_level)
82 #endif
83
84 int dlopen_libblkid(int log_level);