chiark / gitweb /
Merge rsync://rsync.kernel.org/pub/scm/linux/hotplug/udev
[elogind.git] / extras / volume_id / volume_id / volume_id.h
1 /*
2  * volume_id - reads partition label and uuid
3  *
4  * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
5  *
6  *      This library is free software; you can redistribute it and/or
7  *      modify it under the terms of the GNU Lesser General Public
8  *      License as published by the Free Software Foundation; either
9  *      version 2.1 of the License, or (at your option) any later version.
10  *
11  *      This library 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 GNU
14  *      Lesser General Public License for more details.
15  *
16  *      You should have received a copy of the GNU Lesser General Public
17  *      License along with this library; if not, write to the Free Software
18  *      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20
21 #ifndef _VOLUME_ID_H_
22 #define _VOLUME_ID_H_
23
24 #include <stdint.h>
25
26 #define VOLUME_ID_VERSION               48
27
28 #define VOLUME_ID_LABEL_SIZE            64
29 #define VOLUME_ID_UUID_SIZE             36
30 #define VOLUME_ID_FORMAT_SIZE           32
31 #define VOLUME_ID_PATH_MAX              256
32 #define VOLUME_ID_PARTITIONS_MAX        256
33
34 enum volume_id_usage {
35         VOLUME_ID_UNUSED,
36         VOLUME_ID_UNPROBED,
37         VOLUME_ID_OTHER,
38         VOLUME_ID_FILESYSTEM,
39         VOLUME_ID_PARTITIONTABLE,
40         VOLUME_ID_RAID,
41         VOLUME_ID_DISKLABEL,
42         VOLUME_ID_CRYPTO,
43 };
44
45 struct volume_id_partition {
46         enum            volume_id_usage usage_id;
47         char            *usage;
48         char            *type;
49         uint64_t        off;
50         uint64_t        len;
51         uint8_t         partition_type_raw;
52 };
53
54 struct volume_id {
55         uint8_t         label_raw[VOLUME_ID_LABEL_SIZE];
56         size_t          label_raw_len;
57         char            label[VOLUME_ID_LABEL_SIZE+1];
58         uint8_t         uuid_raw[VOLUME_ID_UUID_SIZE];
59         size_t          uuid_raw_len;
60         char            uuid[VOLUME_ID_UUID_SIZE+1];
61         enum            volume_id_usage usage_id;
62         char            *usage;
63         char            *type;
64         char            type_version[VOLUME_ID_FORMAT_SIZE];
65
66         struct volume_id_partition *partitions;
67         size_t          partition_count;
68
69         int             fd;
70         uint8_t         *sbbuf;
71         size_t          sbbuf_len;
72         uint8_t         *seekbuf;
73         uint64_t        seekbuf_off;
74         size_t          seekbuf_len;
75         int             fd_close:1;
76 };
77
78 extern struct volume_id *volume_id_open_fd(int fd);
79 extern struct volume_id *volume_id_open_node(const char *path);
80 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
81 extern int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size);
82 extern void volume_id_close(struct volume_id *id);
83
84 #endif