chiark / gitweb /
volume_id: support sub-uuid's and plug in btrfs device uuid
[elogind.git] / extras / volume_id / lib / libvolume_id.h
1 /*
2  * volume_id - reads volume label and uuid
3  *
4  * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef _LIBVOLUME_ID_H_
21 #define _LIBVOLUME_ID_H_
22
23 #include <stdint.h>
24 #include <stddef.h>
25
26 struct volume_id;
27 typedef void (*volume_id_log_fn_t)(int priority, const char *file, int line, const char *format, ...)
28              __attribute__ ((format(printf, 4, 5)));
29 extern volume_id_log_fn_t volume_id_log_fn;
30
31 typedef int (*volume_id_probe_fn_t)(struct volume_id *id, uint64_t off, uint64_t size);
32 typedef int (*all_probers_fn_t)(volume_id_probe_fn_t probe_fn,
33                                 struct volume_id *id, uint64_t off, uint64_t size,
34                                 void *data);
35
36 extern struct volume_id *volume_id_open_fd(int fd);
37 extern void volume_id_close(struct volume_id *id);
38 extern int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size);
39 extern int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size);
40 extern int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size);
41 extern const volume_id_probe_fn_t *volume_id_get_prober_by_type(const char *type);
42 extern void volume_id_all_probers(all_probers_fn_t all_probers_fn,
43                                   struct volume_id *id, uint64_t off, uint64_t size,
44                                   void *data);
45 extern int volume_id_get_label(struct volume_id *id, const char **label);
46 extern int volume_id_get_label_raw(struct volume_id *id, const uint8_t **label, size_t *len);
47 extern int volume_id_get_uuid(struct volume_id *id, const char **uuid);
48 extern int volume_id_get_uuid_sub(struct volume_id *id, const char **uuid);
49 extern int volume_id_get_uuid_raw(struct volume_id *id, const uint8_t **uuid, size_t *len);
50 extern int volume_id_get_usage(struct volume_id *id, const char **usage);
51 extern int volume_id_get_type(struct volume_id *id, const char **type);
52 extern int volume_id_get_type_version(struct volume_id *id, const char **type_version);
53 extern int volume_id_encode_string(const char *str, char *str_enc, size_t len);
54
55 #endif