logd: fix time passed via unix fd
[project/ubox.git] / libblkid-tiny / blkid.h
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
6 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
7 *
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #ifndef _BLKID_BLKID_H
24 #define _BLKID_BLKID_H
25
26 #include <stdint.h>
27 #include <sys/types.h>
28
29 #include "libblkid-tiny.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define BLKID_VERSION "2.21.0"
36 #define BLKID_DATE "25-May-2012"
37
38 /**
39 * blkid_dev:
40 *
41 * The device object keeps information about one device
42 */
43 typedef struct blkid_struct_dev *blkid_dev;
44
45 /**
46 * blkid_cache:
47 *
48 * information about all system devices
49 */
50 typedef struct blkid_struct_cache *blkid_cache;
51
52 /**
53 * blkid_probe:
54 *
55 * low-level probing setting
56 */
57 typedef struct blkid_struct_probe *blkid_probe;
58
59 /**
60 * blkid_topology:
61 *
62 * device topology information
63 */
64 typedef struct blkid_struct_topology *blkid_topology;
65
66 /**
67 * blkid_partlist
68 *
69 * list of all detected partitions and partitions tables
70 */
71 typedef struct blkid_struct_partlist *blkid_partlist;
72
73 /**
74 * blkid_partition:
75 *
76 * information about a partition
77 */
78 typedef struct blkid_struct_partition *blkid_partition;
79
80 /**
81 * blkid_parttable:
82 *
83 * information about a partition table
84 */
85 typedef struct blkid_struct_parttable *blkid_parttable;
86
87 /**
88 * blkid_loff_t:
89 *
90 * 64-bit signed number for offsets and sizes
91 */
92 typedef int64_t blkid_loff_t;
93
94 /**
95 * blkid_tag_iterate:
96 *
97 * tags iterator for high-level (blkid_cache) API
98 */
99 typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
100
101 /**
102 * blkid_dev_iterate:
103 *
104 * devices iterator for high-level (blkid_cache) API
105 */
106 typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
107
108 /*
109 * Flags for blkid_get_dev
110 *
111 * BLKID_DEV_CREATE Create an empty device structure if not found
112 * in the cache.
113 * BLKID_DEV_VERIFY Make sure the device structure corresponds
114 * with reality.
115 * BLKID_DEV_FIND Just look up a device entry, and return NULL
116 * if it is not found.
117 * BLKID_DEV_NORMAL Get a valid device structure, either from the
118 * cache or by probing the device.
119 */
120 #define BLKID_DEV_FIND 0x0000
121 #define BLKID_DEV_CREATE 0x0001
122 #define BLKID_DEV_VERIFY 0x0002
123 #define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
124
125 /* cache.c */
126 extern void blkid_put_cache(blkid_cache cache);
127 extern int blkid_get_cache(blkid_cache *cache, const char *filename);
128 extern void blkid_gc_cache(blkid_cache cache);
129
130 /* dev.c */
131 extern const char *blkid_dev_devname(blkid_dev dev);
132
133 extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
134 extern int blkid_dev_set_search(blkid_dev_iterate iter,
135 char *search_type, char *search_value);
136 extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
137 extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
138
139 /* devno.c */
140 extern char *blkid_devno_to_devname(dev_t devno);
141 extern int blkid_devno_to_wholedisk(dev_t dev, char *diskname,
142 size_t len, dev_t *diskdevno);
143
144 /* devname.c */
145 extern int blkid_probe_all(blkid_cache cache);
146 extern int blkid_probe_all_new(blkid_cache cache);
147 extern int blkid_probe_all_removable(blkid_cache cache);
148 extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname,
149 int flags);
150
151 /* getsize.c */
152 extern blkid_loff_t blkid_get_dev_size(int fd);
153
154 /* verify.c */
155 extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
156
157 /* read.c */
158
159 /* resolve.c */
160 extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
161 const char *devname);
162 extern char *blkid_get_devname(blkid_cache cache, const char *token,
163 const char *value);
164
165 /* tag.c */
166 extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
167 extern int blkid_tag_next(blkid_tag_iterate iterate,
168 const char **type, const char **value);
169 extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
170 extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
171 const char *value);
172 extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
173 const char *type,
174 const char *value);
175 extern int blkid_parse_tag_string(const char *token, char **ret_type,
176 char **ret_val);
177
178 /* version.c */
179 extern int blkid_parse_version_string(const char *ver_string);
180 extern int blkid_get_library_version(const char **ver_string,
181 const char **date_string);
182
183 /* encode.c */
184 extern int blkid_encode_string(const char *str, char *str_enc, size_t len);
185 extern int blkid_safe_string(const char *str, char *str_safe, size_t len);
186
187 /* evaluate.c */
188 extern int blkid_send_uevent(const char *devname, const char *action);
189 extern char *blkid_evaluate_tag(const char *token, const char *value,
190 blkid_cache *cache);
191 extern char *blkid_evaluate_spec(const char *spec, blkid_cache *cache);
192
193 /* probe.c */
194 extern blkid_probe blkid_new_probe(void);
195 extern blkid_probe blkid_new_probe_from_filename(const char *filename);
196 extern void blkid_free_probe(blkid_probe pr);
197 extern void blkid_reset_probe(blkid_probe pr);
198
199 extern int blkid_probe_set_device(blkid_probe pr, int fd,
200 blkid_loff_t off, blkid_loff_t size);
201
202 extern dev_t blkid_probe_get_devno(blkid_probe pr);
203 extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr);
204 extern int blkid_probe_is_wholedisk(blkid_probe pr);
205
206 extern blkid_loff_t blkid_probe_get_size(blkid_probe pr);
207 extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr);
208 extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr);
209 extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr);
210
211 extern int blkid_probe_get_fd(blkid_probe pr);
212
213 /*
214 * superblocks probing
215 */
216 extern int blkid_known_fstype(const char *fstype);
217 extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage);
218
219 extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable);
220
221 #define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
222 #define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
223 #define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
224 #define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
225 #define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
226 #define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
227 #define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
228 #define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
229 #define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
230
231 #define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
232 BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
233
234 extern int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags);
235
236 extern int blkid_probe_reset_superblocks_filter(blkid_probe pr);
237 extern int blkid_probe_invert_superblocks_filter(blkid_probe pr);
238
239 /**
240 * BLKID_FLTR_NOTIN
241 */
242 #define BLKID_FLTR_NOTIN 1
243 /**
244 * BLKID_FLTR_ONLYIN
245 */
246 #define BLKID_FLTR_ONLYIN 2
247 extern int blkid_probe_filter_superblocks_type(blkid_probe pr, int flag, char *names[]);
248
249 #define BLKID_USAGE_FILESYSTEM (1 << 1)
250 #define BLKID_USAGE_RAID (1 << 2)
251 #define BLKID_USAGE_CRYPTO (1 << 3)
252 #define BLKID_USAGE_OTHER (1 << 4)
253 extern int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage);
254
255 /*
256 * topology probing
257 */
258 extern int blkid_probe_enable_topology(blkid_probe pr, int enable);
259
260 /* binary interface */
261 extern blkid_topology blkid_probe_get_topology(blkid_probe pr);
262
263 extern unsigned long blkid_topology_get_alignment_offset(blkid_topology tp);
264 extern unsigned long blkid_topology_get_minimum_io_size(blkid_topology tp);
265 extern unsigned long blkid_topology_get_optimal_io_size(blkid_topology tp);
266 extern unsigned long blkid_topology_get_logical_sector_size(blkid_topology tp);
267 extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp);
268
269 /*
270 * partitions probing
271 */
272 extern int blkid_known_pttype(const char *pttype);
273 extern int blkid_probe_enable_partitions(blkid_probe pr, int enable);
274
275 extern int blkid_probe_reset_partitions_filter(blkid_probe pr);
276 extern int blkid_probe_invert_partitions_filter(blkid_probe pr);
277 extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[]);
278
279
280 /* partitions probing flags */
281 #define BLKID_PARTS_FORCE_GPT (1 << 1)
282 #define BLKID_PARTS_ENTRY_DETAILS (1 << 2)
283 #define BLKID_PARTS_MAGIC (1 << 3)
284 extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags);
285
286 /* binary interface */
287 extern blkid_partlist blkid_probe_get_partitions(blkid_probe pr);
288
289 extern int blkid_partlist_numof_partitions(blkid_partlist ls);
290 extern blkid_parttable blkid_partlist_get_table(blkid_partlist ls);
291 extern blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n);
292 extern blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno);
293
294 extern blkid_parttable blkid_partition_get_table(blkid_partition par);
295 extern const char *blkid_partition_get_name(blkid_partition par);
296 extern const char *blkid_partition_get_uuid(blkid_partition par);
297 extern int blkid_partition_get_partno(blkid_partition par);
298 extern blkid_loff_t blkid_partition_get_start(blkid_partition par);
299 extern blkid_loff_t blkid_partition_get_size(blkid_partition par);
300 extern int blkid_partition_get_type(blkid_partition par);
301 extern const char *blkid_partition_get_type_string(blkid_partition par);
302 extern unsigned long long blkid_partition_get_flags(blkid_partition par);
303 extern int blkid_partition_is_logical(blkid_partition par);
304 extern int blkid_partition_is_extended(blkid_partition par);
305 extern int blkid_partition_is_primary(blkid_partition par);
306
307 extern const char *blkid_parttable_get_type(blkid_parttable tab);
308 extern blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab);
309 extern blkid_partition blkid_parttable_get_parent(blkid_parttable tab);
310
311 /*
312 * NAME=value low-level interface
313 */
314 extern int blkid_do_probe(blkid_probe pr);
315 extern int blkid_do_safeprobe(blkid_probe pr);
316 extern int blkid_do_fullprobe(blkid_probe pr);
317
318 extern int blkid_probe_numof_values(blkid_probe pr);
319 extern int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
320 const char **data, size_t *len);
321 extern int blkid_probe_lookup_value(blkid_probe pr, const char *name,
322 const char **data, size_t *len);
323 extern int blkid_probe_has_value(blkid_probe pr, const char *name);
324
325 extern int blkid_do_wipe(blkid_probe pr, int dryrun);
326
327 /*
328 * Deprecated functions/macros
329 */
330 #ifndef BLKID_DISABLE_DEPRECATED
331
332 #define BLKID_PROBREQ_LABEL BLKID_SUBLKS_LABEL
333 #define BLKID_PROBREQ_LABELRAW BLKID_SUBLKS_LABELRAW
334 #define BLKID_PROBREQ_UUID BLKID_SUBLKS_UUID
335 #define BLKID_PROBREQ_UUIDRAW BLKID_SUBLKS_UUIDRAW
336 #define BLKID_PROBREQ_TYPE BLKID_SUBLKS_TYPE
337 #define BLKID_PROBREQ_SECTYPE BLKID_SUBLKS_SECTYPE
338 #define BLKID_PROBREQ_USAGE BLKID_SUBLKS_USAGE
339 #define BLKID_PROBREQ_VERSION BLKID_SUBLKS_VERSION
340
341 extern int blkid_probe_set_request(blkid_probe pr, int flags);
342 extern int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage);
343 extern int blkid_probe_filter_types(blkid_probe pr, int flag, char *names[]);
344 extern int blkid_probe_invert_filter(blkid_probe pr);
345 extern int blkid_probe_reset_filter(blkid_probe pr);
346
347 #endif /* BLKID_DISABLE_DEPRECATED */
348
349 #ifdef __cplusplus
350 }
351 #endif
352
353 #endif /* _BLKID_BLKID_H */