Upload Tizen:Base source
[framework/base/util-linux-ng.git] / shlibs / blkid / src / 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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 typedef struct blkid_struct_dev *blkid_dev;
34 typedef struct blkid_struct_cache *blkid_cache;
35 typedef struct blkid_struct_probe *blkid_probe;
36
37 typedef int64_t blkid_loff_t;
38
39 typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
40 typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
41
42 /*
43  * Flags for blkid_get_dev
44  *
45  * BLKID_DEV_CREATE     Create an empty device structure if not found
46  *                      in the cache.
47  * BLKID_DEV_VERIFY     Make sure the device structure corresponds
48  *                      with reality.
49  * BLKID_DEV_FIND       Just look up a device entry, and return NULL
50  *                      if it is not found.
51  * BLKID_DEV_NORMAL     Get a valid device structure, either from the
52  *                      cache or by probing the device.
53  */
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)
58
59 /* cache.c */
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);
63
64 /* dev.c */
65 extern const char *blkid_dev_devname(blkid_dev dev);
66
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);
72
73 /* devno.c */
74 extern char *blkid_devno_to_devname(dev_t devno);
75
76 /* devname.c */
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,
80                                int flags);
81
82 /* getsize.c */
83 extern blkid_loff_t blkid_get_dev_size(int fd);
84
85 /* verify.c */
86 extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
87
88 /* read.c */
89
90 /* resolve.c */
91 extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
92                                        const char *devname);
93 extern char *blkid_get_devname(blkid_cache cache, const char *token,
94                                const char *value);
95
96 /* tag.c */
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,
102                              const char *value);
103 extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
104                                          const char *type,
105                                          const char *value);
106 extern int blkid_parse_tag_string(const char *token, char **ret_type,
107                                   char **ret_val);
108
109 /* version.c */
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);
113
114 /* encode.c */
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);
117
118 /* evaluate.c */
119 extern int blkid_send_uevent(const char *devname, const char *action);
120 extern char *blkid_evaluate_tag(const char *token, const char *value,
121                                 blkid_cache *cache);
122
123 /* probe.c */
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);
128
129 extern int blkid_probe_set_device(blkid_probe pr, int fd,
130                         blkid_loff_t off, blkid_loff_t size);
131
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);
141
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);
147
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[]);
152
153
154 extern int blkid_probe_invert_filter(blkid_probe pr);
155 extern int blkid_probe_reset_filter(blkid_probe pr);
156
157 extern int blkid_do_probe(blkid_probe pr);
158 extern int blkid_do_safeprobe(blkid_probe pr);
159
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);
166
167 #ifdef __cplusplus
168 }
169 #endif
170
171 #endif /* _BLKID_BLKID_H */