]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libblkid/src/blkid.h.in
Merge branch 'libuuid-range' of https://github.com/UQ-RCC/util-linux
[thirdparty/util-linux.git] / libblkid / src / blkid.h.in
CommitLineData
a0948ffe
KZ
1/*
2 * blkid.h - Interface for libblkid, a library to identify block devices
3 *
4 * Copyright (C) 2001 Andreas Dilger
5 * Copyright (C) 2003 Theodore Ts'o
4a92038d 6 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
a0948ffe 7 *
4a92038d
KZ
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
7cebf0bb 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
a0948ffe
KZ
21 */
22
23#ifndef _BLKID_BLKID_H
24#define _BLKID_BLKID_H
25
e1ad8bb3 26#include <stdint.h>
a0948ffe 27#include <sys/types.h>
a0948ffe
KZ
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
033cf439
KZ
33#define BLKID_VERSION "@LIBBLKID_VERSION@"
34#define BLKID_DATE "@LIBBLKID_DATE@"
35
488e52be
KZ
36/**
37 * blkid_dev:
38 *
39 * The device object keeps information about one device
40 */
a0948ffe 41typedef struct blkid_struct_dev *blkid_dev;
488e52be
KZ
42
43/**
44 * blkid_cache:
45 *
46 * information about all system devices
47 */
a0948ffe 48typedef struct blkid_struct_cache *blkid_cache;
488e52be
KZ
49
50/**
51 * blkid_probe:
52 *
53 * low-level probing setting
54 */
51410fc6
KZ
55typedef struct blkid_struct_probe *blkid_probe;
56
cc33d693
KZ
57/**
58 * blkid_topology:
59 *
60 * device topology information
61 */
62typedef struct blkid_struct_topology *blkid_topology;
63
e4799a35
KZ
64/**
65 * blkid_partlist
66 *
67 * list of all detected partitions and partitions tables
68 */
69typedef struct blkid_struct_partlist *blkid_partlist;
70
71/**
72 * blkid_partition:
73 *
74 * information about a partition
75 */
76typedef struct blkid_struct_partition *blkid_partition;
77
78/**
79 * blkid_parttable:
80 *
81 * information about a partition table
82 */
83typedef struct blkid_struct_parttable *blkid_parttable;
84
488e52be
KZ
85/**
86 * blkid_loff_t:
87 *
88 * 64-bit signed number for offsets and sizes
89 */
e1ad8bb3 90typedef int64_t blkid_loff_t;
a0948ffe 91
488e52be
KZ
92/**
93 * blkid_tag_iterate:
94 *
95 * tags iterator for high-level (blkid_cache) API
96 */
a0948ffe 97typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
488e52be
KZ
98
99/**
100 * blkid_dev_iterate:
101 *
102 * devices iterator for high-level (blkid_cache) API
103 */
a0948ffe
KZ
104typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
105
106/*
107 * Flags for blkid_get_dev
108 *
109 * BLKID_DEV_CREATE Create an empty device structure if not found
b227e3b7 110 * in the cache.
a0948ffe 111 * BLKID_DEV_VERIFY Make sure the device structure corresponds
b227e3b7 112 * with reality.
a0948ffe 113 * BLKID_DEV_FIND Just look up a device entry, and return NULL
b227e3b7 114 * if it is not found.
a0948ffe 115 * BLKID_DEV_NORMAL Get a valid device structure, either from the
b227e3b7 116 * cache or by probing the device.
a0948ffe
KZ
117 */
118#define BLKID_DEV_FIND 0x0000
119#define BLKID_DEV_CREATE 0x0001
120#define BLKID_DEV_VERIFY 0x0002
121#define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
122
21eff114
OO
123
124#ifndef __GNUC_PREREQ
125# if defined __GNUC__ && defined __GNUC_MINOR__
126# define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
127# else
128# define __GNUC_PREREQ(maj, min) 0
129# endif
130#endif
131
132#ifndef __ul_attribute__
133# if __GNUC_PREREQ (3, 4)
134# define __ul_attribute__(_a_) __attribute__(_a_)
135# else
136# define __ul_attribute__(_a_)
137# endif
138#endif
139
c54f54d6 140/* init.c */
310f6728 141extern void blkid_init_debug(int mask);
c54f54d6
JB
142
143/* cache.c */
2e31fe23
KZ
144extern void blkid_put_cache(blkid_cache cache);
145extern int blkid_get_cache(blkid_cache *cache, const char *filename);
146extern void blkid_gc_cache(blkid_cache cache);
a0948ffe
KZ
147
148/* dev.c */
21eff114 149extern const char *blkid_dev_devname(blkid_dev dev)
21eff114 150 __ul_attribute__((warn_unused_result));
a0948ffe 151
2bb7a706 152extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
a0948ffe 153extern int blkid_dev_set_search(blkid_dev_iterate iter,
f024c96c 154 const char *search_type, const char *search_value);
2e31fe23
KZ
155extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
156extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
a0948ffe
KZ
157
158/* devno.c */
21eff114
OO
159extern char *blkid_devno_to_devname(dev_t devno)
160 __ul_attribute__((warn_unused_result));
0d44d469 161extern int blkid_devno_to_wholedisk(dev_t dev, char *diskname,
21eff114
OO
162 size_t len, dev_t *diskdevno)
163 __ul_attribute__((warn_unused_result));
a0948ffe
KZ
164
165/* devname.c */
2e31fe23
KZ
166extern int blkid_probe_all(blkid_cache cache);
167extern int blkid_probe_all_new(blkid_cache cache);
168extern int blkid_probe_all_removable(blkid_cache cache);
169
170extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags);
a0948ffe
KZ
171
172/* getsize.c */
2bb7a706 173extern blkid_loff_t blkid_get_dev_size(int fd);
a0948ffe 174
51410fc6 175/* verify.c */
2e31fe23 176extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
a0948ffe
KZ
177
178/* read.c */
179
180/* resolve.c */
181extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
21eff114 182 const char *devname)
21eff114 183 __ul_attribute__((warn_unused_result));
a0948ffe 184extern char *blkid_get_devname(blkid_cache cache, const char *token,
21eff114 185 const char *value)
21eff114 186 __ul_attribute__((warn_unused_result));
a0948ffe
KZ
187
188/* tag.c */
2bb7a706 189extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
a0948ffe 190extern int blkid_tag_next(blkid_tag_iterate iterate,
2e31fe23
KZ
191 const char **type, const char **value);
192extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
2bb7a706 193extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value);
2e31fe23 194
a0948ffe
KZ
195extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
196 const char *type,
2bb7a706 197 const char *value);
2e31fe23
KZ
198
199extern int blkid_parse_tag_string(const char *token, char **ret_type, char **ret_val);
a0948ffe
KZ
200
201/* version.c */
21eff114 202extern int blkid_parse_version_string(const char *ver_string)
2bb7a706 203 __ul_attribute__((nonnull));
a0948ffe 204extern int blkid_get_library_version(const char **ver_string,
2e31fe23 205 const char **date_string);
a0948ffe 206
dd20a05a 207/* encode.c */
2e31fe23
KZ
208extern int blkid_encode_string(const char *str, char *str_enc, size_t len);
209extern int blkid_safe_string(const char *str, char *str_safe, size_t len);
51410fc6 210
892a404c 211/* evaluate.c */
2e31fe23 212extern int blkid_send_uevent(const char *devname, const char *action);
cee95a95 213extern char *blkid_evaluate_tag(const char *token, const char *value,
21eff114 214 blkid_cache *cache)
21eff114
OO
215 __ul_attribute__((warn_unused_result));
216extern char *blkid_evaluate_spec(const char *spec, blkid_cache *cache)
21eff114 217 __ul_attribute__((warn_unused_result));
892a404c 218
51410fc6 219/* probe.c */
21eff114
OO
220extern blkid_probe blkid_new_probe(void)
221 __ul_attribute__((warn_unused_result));
222extern blkid_probe blkid_new_probe_from_filename(const char *filename)
7f787ced
KZ
223 __ul_attribute__((warn_unused_result))
224 __ul_attribute__((nonnull));
51410fc6 225extern void blkid_free_probe(blkid_probe pr);
51410fc6 226
2e31fe23 227extern void blkid_reset_probe(blkid_probe pr);
d2b0c658
KZ
228extern int blkid_probe_reset_buffers(blkid_probe pr);
229extern int blkid_probe_hide_range(blkid_probe pr, uint64_t off, uint64_t len);
601fb1c1 230
21eff114 231extern int blkid_probe_set_device(blkid_probe pr, int fd,
7f787ced
KZ
232 blkid_loff_t off, blkid_loff_t size)
233 __ul_attribute__((nonnull));
21eff114
OO
234
235extern dev_t blkid_probe_get_devno(blkid_probe pr)
2bb7a706 236 __ul_attribute__((nonnull));
2e31fe23 237
21eff114 238extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr)
2bb7a706 239 __ul_attribute__((nonnull));
2e31fe23 240
21eff114 241extern int blkid_probe_is_wholedisk(blkid_probe pr)
2bb7a706 242 __ul_attribute__((nonnull));
21eff114 243
7f787ced
KZ
244extern blkid_loff_t blkid_probe_get_size(blkid_probe pr)
245 __ul_attribute__((nonnull));
246extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
247 __ul_attribute__((nonnull));
248extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
249 __ul_attribute__((nonnull));
76fab513
KZ
250extern int blkid_probe_set_sectorsize(blkid_probe pr, unsigned int sz)
251 __ul_attribute__((nonnull));
7f787ced
KZ
252extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
253 __ul_attribute__((nonnull));
21eff114 254
7f787ced
KZ
255extern int blkid_probe_get_fd(blkid_probe pr)
256 __ul_attribute__((nonnull));
56e961e2 257
5657c25a
KZ
258/*
259 * superblocks probing
260 */
7f787ced
KZ
261extern int blkid_known_fstype(const char *fstype)
262 __ul_attribute__((nonnull));
21eff114 263
70db6c7e
KZ
264extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage);
265
7f787ced
KZ
266extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
267 __ul_attribute__((nonnull));
b227e3b7 268
5657c25a
KZ
269#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
270#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
271#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
272#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
273#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
274#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
275#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
276#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
92838067 277#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
02f3c12a 278#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
5657c25a
KZ
279
280#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
281 BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
51410fc6 282
7f787ced
KZ
283extern int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags)
284 __ul_attribute__((nonnull));
285extern int blkid_probe_reset_superblocks_filter(blkid_probe pr)
286 __ul_attribute__((nonnull));
287extern int blkid_probe_invert_superblocks_filter(blkid_probe pr)
288 __ul_attribute__((nonnull));
b227e3b7 289
fd7c9e35
KZ
290/**
291 * BLKID_FLTR_NOTIN
292 */
b227e3b7 293#define BLKID_FLTR_NOTIN 1
fd7c9e35
KZ
294/**
295 * BLKID_FLTR_ONLYIN
296 */
b227e3b7 297#define BLKID_FLTR_ONLYIN 2
7f787ced
KZ
298extern int blkid_probe_filter_superblocks_type(blkid_probe pr, int flag, char *names[])
299 __ul_attribute__((nonnull));
b227e3b7 300
51410fc6
KZ
301#define BLKID_USAGE_FILESYSTEM (1 << 1)
302#define BLKID_USAGE_RAID (1 << 2)
303#define BLKID_USAGE_CRYPTO (1 << 3)
304#define BLKID_USAGE_OTHER (1 << 4)
7f787ced
KZ
305extern int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage)
306 __ul_attribute__((nonnull));
51410fc6 307
cc33d693
KZ
308/*
309 * topology probing
310 */
7f787ced
KZ
311extern int blkid_probe_enable_topology(blkid_probe pr, int enable)
312 __ul_attribute__((nonnull));
cc33d693
KZ
313
314/* binary interface */
7f787ced
KZ
315extern blkid_topology blkid_probe_get_topology(blkid_probe pr)
316 __ul_attribute__((nonnull));
21eff114
OO
317
318extern unsigned long blkid_topology_get_alignment_offset(blkid_topology tp)
2bb7a706 319 __ul_attribute__((nonnull));
21eff114 320extern unsigned long blkid_topology_get_minimum_io_size(blkid_topology tp)
2bb7a706 321 __ul_attribute__((nonnull));
21eff114 322extern unsigned long blkid_topology_get_optimal_io_size(blkid_topology tp)
2bb7a706 323 __ul_attribute__((nonnull));
21eff114 324extern unsigned long blkid_topology_get_logical_sector_size(blkid_topology tp)
2bb7a706 325 __ul_attribute__((nonnull));
21eff114 326extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
2bb7a706 327 __ul_attribute__((nonnull));
cc33d693 328
e4799a35
KZ
329/*
330 * partitions probing
331 */
2bb7a706 332extern int blkid_known_pttype(const char *pttype);
635d9aa5 333extern int blkid_partitions_get_name(const size_t idx, const char **name);
e4799a35 334
7f787ced
KZ
335extern int blkid_probe_enable_partitions(blkid_probe pr, int enable)
336 __ul_attribute__((nonnull));
48805d56 337
7f787ced
KZ
338extern int blkid_probe_reset_partitions_filter(blkid_probe pr)
339 __ul_attribute__((nonnull));
340extern int blkid_probe_invert_partitions_filter(blkid_probe pr)
341 __ul_attribute__((nonnull));
342extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[])
343 __ul_attribute__((nonnull));
48805d56 344
e4799a35 345/* partitions probing flags */
0c6dc615
KZ
346#define BLKID_PARTS_FORCE_GPT (1 << 1)
347#define BLKID_PARTS_ENTRY_DETAILS (1 << 2)
3c83b3b2 348#define BLKID_PARTS_MAGIC (1 << 3)
7f787ced
KZ
349extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags)
350 __ul_attribute__((nonnull));
e4799a35
KZ
351
352/* binary interface */
7f787ced
KZ
353extern blkid_partlist blkid_probe_get_partitions(blkid_probe pr)
354 __ul_attribute__((nonnull));
21eff114 355
7f787ced
KZ
356extern int blkid_partlist_numof_partitions(blkid_partlist ls)
357 __ul_attribute__((nonnull));
358extern blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
359 __ul_attribute__((nonnull));
360extern blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
361 __ul_attribute__((nonnull));
362extern blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n)
363 __ul_attribute__((nonnull));
364extern blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno)
365 __ul_attribute__((nonnull));
366extern blkid_parttable blkid_partition_get_table(blkid_partition par)
367 __ul_attribute__((nonnull));
2e31fe23 368
7f787ced
KZ
369extern const char *blkid_partition_get_name(blkid_partition par)
370 __ul_attribute__((nonnull));
371extern const char *blkid_partition_get_uuid(blkid_partition par)
372 __ul_attribute__((nonnull));
373extern int blkid_partition_get_partno(blkid_partition par)
374 __ul_attribute__((nonnull));
375extern blkid_loff_t blkid_partition_get_start(blkid_partition par)
376 __ul_attribute__((nonnull));
377extern blkid_loff_t blkid_partition_get_size(blkid_partition par)
378 __ul_attribute__((nonnull));
2e31fe23 379
21eff114 380extern int blkid_partition_get_type(blkid_partition par)
2bb7a706 381 __ul_attribute__((nonnull));
7f787ced
KZ
382extern const char *blkid_partition_get_type_string(blkid_partition par)
383 __ul_attribute__((nonnull));
21eff114 384extern unsigned long long blkid_partition_get_flags(blkid_partition par)
2bb7a706 385 __ul_attribute__((nonnull));
2e31fe23 386
21eff114 387extern int blkid_partition_is_logical(blkid_partition par)
2bb7a706 388 __ul_attribute__((nonnull));
21eff114 389extern int blkid_partition_is_extended(blkid_partition par)
2bb7a706 390 __ul_attribute__((nonnull));
21eff114 391extern int blkid_partition_is_primary(blkid_partition par)
2bb7a706 392 __ul_attribute__((nonnull));
2e31fe23 393
7f787ced
KZ
394extern const char *blkid_parttable_get_type(blkid_parttable tab)
395 __ul_attribute__((nonnull));
396extern const char *blkid_parttable_get_id(blkid_parttable tab)
397 __ul_attribute__((nonnull));
398extern blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
399 __ul_attribute__((nonnull));
400extern blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
401 __ul_attribute__((nonnull));
e4799a35 402
b227e3b7
KZ
403/*
404 * NAME=value low-level interface
405 */
7f787ced
KZ
406extern int blkid_do_probe(blkid_probe pr)
407 __ul_attribute__((nonnull));
408extern int blkid_do_safeprobe(blkid_probe pr)
409 __ul_attribute__((nonnull));
410extern int blkid_do_fullprobe(blkid_probe pr)
411 __ul_attribute__((nonnull));
21eff114 412
7f787ced
KZ
413extern int blkid_probe_numof_values(blkid_probe pr)
414 __ul_attribute__((nonnull));
51410fc6 415extern int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
7f787ced
KZ
416 const char **data, size_t *len)
417 __ul_attribute__((nonnull(1)));
51410fc6 418extern int blkid_probe_lookup_value(blkid_probe pr, const char *name,
7f787ced
KZ
419 const char **data, size_t *len)
420 __ul_attribute__((nonnull(1, 2)));
21eff114 421extern int blkid_probe_has_value(blkid_probe pr, const char *name)
2bb7a706 422 __ul_attribute__((nonnull));
7f787ced
KZ
423extern int blkid_do_wipe(blkid_probe pr, int dryrun)
424 __ul_attribute__((nonnull));
425extern int blkid_probe_step_back(blkid_probe pr)
426 __ul_attribute__((nonnull));
2b89be6c 427
fd7c9e35 428/*
5657c25a
KZ
429 * Deprecated functions/macros
430 */
fd7c9e35
KZ
431#ifndef BLKID_DISABLE_DEPRECATED
432
5657c25a
KZ
433#define BLKID_PROBREQ_LABEL BLKID_SUBLKS_LABEL
434#define BLKID_PROBREQ_LABELRAW BLKID_SUBLKS_LABELRAW
435#define BLKID_PROBREQ_UUID BLKID_SUBLKS_UUID
436#define BLKID_PROBREQ_UUIDRAW BLKID_SUBLKS_UUIDRAW
437#define BLKID_PROBREQ_TYPE BLKID_SUBLKS_TYPE
438#define BLKID_PROBREQ_SECTYPE BLKID_SUBLKS_SECTYPE
439#define BLKID_PROBREQ_USAGE BLKID_SUBLKS_USAGE
440#define BLKID_PROBREQ_VERSION BLKID_SUBLKS_VERSION
441
21eff114 442extern int blkid_probe_set_request(blkid_probe pr, int flags)
21eff114
OO
443 __ul_attribute__((deprecated));
444
445extern int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage)
21eff114
OO
446 __ul_attribute__((deprecated));
447
448extern int blkid_probe_filter_types(blkid_probe pr, int flag, char *names[])
21eff114
OO
449 __ul_attribute__((deprecated));
450
451extern int blkid_probe_invert_filter(blkid_probe pr)
21eff114
OO
452 __ul_attribute__((deprecated));
453
454extern int blkid_probe_reset_filter(blkid_probe pr)
21eff114 455 __ul_attribute__((deprecated));
5657c25a 456
fd7c9e35
KZ
457#endif /* BLKID_DISABLE_DEPRECATED */
458
a0948ffe
KZ
459#ifdef __cplusplus
460}
461#endif
462
463#endif /* _BLKID_BLKID_H */