chiark / gitweb /
[PATCH] klibc: update to version 0.196
[elogind.git] / extras / volume_id / volume_id.h
1 /*
2  * volume_id - reads partition label and uuid
3  *
4  * Copyright (C) 2004 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 #define VOLUME_ID_VERSION               27
25
26 #define VOLUME_ID_LABEL_SIZE            64
27 #define VOLUME_ID_UUID_SIZE             16
28 #define VOLUME_ID_UUID_STRING_SIZE      37
29 #define VOLUME_ID_FORMAT_SIZE           32
30 #define VOLUME_ID_PATH_MAX              256
31 #define VOLUME_ID_PARTITIONS_MAX        256
32
33 enum volume_id_usage {
34         VOLUME_ID_UNUSED,
35         VOLUME_ID_UNPROBED,
36         VOLUME_ID_OTHER,
37         VOLUME_ID_FILESYSTEM,
38         VOLUME_ID_PARTITIONTABLE,
39         VOLUME_ID_RAID,
40 };
41
42 enum volume_id_type {
43         VOLUME_ID_ALL,
44         VOLUME_ID_MSDOSPARTTABLE,
45         VOLUME_ID_MSDOSEXTENDED,
46         VOLUME_ID_SWAP,
47         VOLUME_ID_EXT2,
48         VOLUME_ID_EXT3,
49         VOLUME_ID_REISERFS,
50         VOLUME_ID_XFS,
51         VOLUME_ID_JFS,
52         VOLUME_ID_VFAT,
53         VOLUME_ID_UDF,
54         VOLUME_ID_ISO9660,
55         VOLUME_ID_NTFS,
56         VOLUME_ID_MACPARTMAP,
57         VOLUME_ID_HFS,
58         VOLUME_ID_HFSPLUS,
59         VOLUME_ID_UFS,
60         VOLUME_ID_LINUX_RAID,
61         VOLUME_ID_LVM1,
62         VOLUME_ID_LVM2,
63         VOLUME_ID_HPTRAID,
64 };
65
66 struct volume_id_partition {
67         enum            volume_id_usage usage_id;
68         enum            volume_id_type type_id;
69         char            *type;
70         unsigned long long off;
71         unsigned long long len;
72         unsigned int partition_type_raw;
73 };
74
75 struct volume_id {
76         unsigned char   label_raw[VOLUME_ID_LABEL_SIZE];
77         unsigned int    label_raw_len;
78         char            label[VOLUME_ID_LABEL_SIZE+1];
79         unsigned char   uuid_raw[VOLUME_ID_UUID_SIZE];
80         char            uuid[VOLUME_ID_UUID_STRING_SIZE];
81         enum            volume_id_usage usage_id;
82         enum            volume_id_type type_id;
83         char            *type;
84         char            type_version[VOLUME_ID_FORMAT_SIZE];
85         struct volume_id_partition *partitions;
86         unsigned int    partition_count;
87         int             fd;
88         unsigned char   *sbbuf;
89         unsigned int    sbbuf_len;
90         unsigned char   *seekbuf;
91         unsigned long long seekbuf_off;
92         unsigned int    seekbuf_len;
93         int             fd_close;
94 };
95
96 /* open volume by already open file descriptor */
97 extern struct volume_id *volume_id_open_fd(int fd);
98
99 /* open volume by device node */
100 extern struct volume_id *volume_id_open_node(const char *path);
101
102 /* open volume by major/minor */
103 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
104
105 /* probe volume for filesystem type and try to read label/uuid */
106 extern int volume_id_probe(struct volume_id *id, enum volume_id_type type,
107                            unsigned long long off, unsigned long long size);
108
109 /* free allocated device info */
110 extern void volume_id_close(struct volume_id *id);
111
112 #endif