chiark / gitweb /
a0d2acda225b01fa329687c61595f0f7658ef7af
[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 program is free software; you can redistribute it and/or modify it
7  *      under the terms of the GNU General Public License as published by the
8  *      Free Software Foundation version 2 of the License.
9  * 
10  *      This program is distributed in the hope that it will be useful, but
11  *      WITHOUT ANY WARRANTY; without even the implied warranty of
12  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *      General Public License for more details.
14  * 
15  *      You should have received a copy of the GNU General Public License along
16  *      with this program; if not, write to the Free Software Foundation, Inc.,
17  *      675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  */
20
21 #ifndef _VOLUME_ID_H_
22 #define _VOLUME_ID_H_
23
24 #define VOLUME_ID_VERSION               001
25
26 #define VOLUME_ID_LABEL_SIZE            16
27 #define VOLUME_ID_UUID_SIZE             16
28 #define VOLUME_ID_UUID_STRING_SIZE      37
29 #define VOLUME_ID_PATH_MAX              255
30
31
32 enum filesystem_type {
33         ALL,
34         EXT2,
35         EXT3,
36         REISER,
37         XFS,
38         JFS,
39         MSDOS,
40         VFAT,
41         NTFS,
42         SWAP
43 };
44
45 struct volume_id {
46         char label[VOLUME_ID_LABEL_SIZE];
47         char label_string[VOLUME_ID_LABEL_SIZE+1];
48         unsigned char uuid[VOLUME_ID_UUID_SIZE];
49         char uuid_string[VOLUME_ID_UUID_STRING_SIZE];
50         enum filesystem_type fs_type;
51         char *fs_name;
52         int fd;
53         char *buf;
54         int fd_close;
55 };
56
57 /* open volume by already open file descriptor */
58 extern struct volume_id *volume_id_open_fd(int fd);
59
60 /* open volume by device node */
61 extern struct volume_id *volume_id_open_node(const char *path);
62
63 /* open volume by major/minor */
64 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
65
66 /* probe volume for filesystem type and try to read label/uuid */
67 extern int volume_id_probe(struct volume_id *id, enum filesystem_type fs_type);
68
69 /* free allocated device info */
70 extern void volume_id_close(struct volume_id *id);
71
72 #endif