2 * blkid.h - Interface for libblkid, a library to identify block devices
4 * Copyright (C) 2001 Andreas Dilger
5 * Copyright (C) 2003 Theodore Ts'o
6 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
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.
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.
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef _BLKID_BLKID_H
24 #define _BLKID_BLKID_H
27 #include <sys/types.h>
33 typedef struct blkid_struct_dev *blkid_dev;
34 typedef struct blkid_struct_cache *blkid_cache;
35 typedef struct blkid_struct_probe *blkid_probe;
37 typedef int64_t blkid_loff_t;
39 typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
40 typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
43 * Flags for blkid_get_dev
45 * BLKID_DEV_CREATE Create an empty device structure if not found
47 * BLKID_DEV_VERIFY Make sure the device structure corresponds
49 * BLKID_DEV_FIND Just look up a device entry, and return NULL
51 * BLKID_DEV_NORMAL Get a valid device structure, either from the
52 * cache or by probing the device.
54 #define BLKID_DEV_FIND 0x0000
55 #define BLKID_DEV_CREATE 0x0001
56 #define BLKID_DEV_VERIFY 0x0002
57 #define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
60 extern void blkid_put_cache(blkid_cache cache);
61 extern int blkid_get_cache(blkid_cache *cache, const char *filename);
62 extern void blkid_gc_cache(blkid_cache cache);
65 extern const char *blkid_dev_devname(blkid_dev dev);
67 extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
68 extern int blkid_dev_set_search(blkid_dev_iterate iter,
69 char *search_type, char *search_value);
70 extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
71 extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
74 extern char *blkid_devno_to_devname(dev_t devno);
77 extern int blkid_probe_all(blkid_cache cache);
78 extern int blkid_probe_all_new(blkid_cache cache);
79 extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname,
83 extern blkid_loff_t blkid_get_dev_size(int fd);
86 extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
91 extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
93 extern char *blkid_get_devname(blkid_cache cache, const char *token,
97 extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
98 extern int blkid_tag_next(blkid_tag_iterate iterate,
99 const char **type, const char **value);
100 extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
101 extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
103 extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
106 extern int blkid_parse_tag_string(const char *token, char **ret_type,
110 extern int blkid_parse_version_string(const char *ver_string);
111 extern int blkid_get_library_version(const char **ver_string,
112 const char **date_string);
115 extern int blkid_encode_string(const char *str, char *str_enc, size_t len);
116 extern int blkid_safe_string(const char *str, char *str_safe, size_t len);
119 extern int blkid_send_uevent(const char *devname, const char *action);
120 extern char *blkid_evaluate_tag(const char *token, const char *value,
124 extern int blkid_known_fstype(const char *fstype);
125 extern blkid_probe blkid_new_probe(void);
126 extern void blkid_free_probe(blkid_probe pr);
127 extern void blkid_reset_probe(blkid_probe pr);
129 extern int blkid_probe_set_device(blkid_probe pr, int fd,
130 blkid_loff_t off, blkid_loff_t size);
132 #define BLKID_PROBREQ_LABEL (1 << 1)
133 #define BLKID_PROBREQ_LABELRAW (1 << 2)
134 #define BLKID_PROBREQ_UUID (1 << 3)
135 #define BLKID_PROBREQ_UUIDRAW (1 << 4)
136 #define BLKID_PROBREQ_TYPE (1 << 5)
137 #define BLKID_PROBREQ_SECTYPE (1 << 6)
138 #define BLKID_PROBREQ_USAGE (1 << 7)
139 #define BLKID_PROBREQ_VERSION (1 << 8)
140 extern int blkid_probe_set_request(blkid_probe pr, int flags);
142 #define BLKID_USAGE_FILESYSTEM (1 << 1)
143 #define BLKID_USAGE_RAID (1 << 2)
144 #define BLKID_USAGE_CRYPTO (1 << 3)
145 #define BLKID_USAGE_OTHER (1 << 4)
146 extern int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage);
148 #define BLKID_FLTR_NOTIN 1
149 #define BLKID_FLTR_ONLYIN 2
150 extern int blkid_probe_filter_types(blkid_probe pr,
151 int flag, char *names[]);
154 extern int blkid_probe_invert_filter(blkid_probe pr);
155 extern int blkid_probe_reset_filter(blkid_probe pr);
157 extern int blkid_do_probe(blkid_probe pr);
158 extern int blkid_do_safeprobe(blkid_probe pr);
160 extern int blkid_probe_numof_values(blkid_probe pr);
161 extern int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
162 const char **data, size_t *len);
163 extern int blkid_probe_lookup_value(blkid_probe pr, const char *name,
164 const char **data, size_t *len);
165 extern int blkid_probe_has_value(blkid_probe pr, const char *name);
171 #endif /* _BLKID_BLKID_H */