]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
1b9e5b12 LP |
2 | #pragma once |
3 | ||
349cc4a5 | 4 | #if HAVE_BLKID |
0f495e01 | 5 | # include <blkid.h> |
1b9e5b12 | 6 | |
e3b9a5ff LP |
7 | # include "sd-id128.h" |
8 | ||
0f495e01 | 9 | # include "macro.h" |
e3b9a5ff | 10 | # include "string-util.h" |
1b9e5b12 | 11 | |
fd421c4a | 12 | DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(blkid_probe, blkid_free_probe, NULL); |
e3b9a5ff LP |
13 | |
14 | static inline int blkid_partition_get_uuid_id128(blkid_partition p, sd_id128_t *ret) { | |
15 | const char *s; | |
16 | ||
17 | assert(p); | |
18 | ||
19 | s = blkid_partition_get_uuid(p); | |
20 | if (isempty(s)) | |
21 | return -ENXIO; | |
22 | ||
23 | return sd_id128_from_string(s, ret); | |
24 | } | |
25 | ||
26 | static inline int blkid_partition_get_type_id128(blkid_partition p, sd_id128_t *ret) { | |
27 | const char *s; | |
28 | ||
29 | assert(p); | |
30 | ||
31 | s = blkid_partition_get_type_string(p); | |
32 | if (isempty(s)) | |
33 | return -ENXIO; | |
34 | ||
35 | return sd_id128_from_string(s, ret); | |
36 | } | |
2e3944b8 LP |
37 | |
38 | /* Define symbolic names for blkid_do_safeprobe() return values, since blkid only uses literal numbers. We | |
39 | * prefix these symbolic definitions with underscores, to not invade libblkid's namespace needlessly. */ | |
40 | enum { | |
41 | _BLKID_SAFEPROBE_FOUND = 0, | |
42 | _BLKID_SAFEPROBE_NOT_FOUND = 1, | |
43 | _BLKID_SAFEPROBE_AMBIGUOUS = -2, | |
44 | _BLKID_SAFEPROBE_ERROR = -1, | |
45 | }; | |
46 | ||
1b9e5b12 | 47 | #endif |