chiark / gitweb /
[PATCH] update udev_volume_id
[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               004
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_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         UDF,
42         ISO9660,
43         NTFS,
44         SWAP
45 };
46
47 struct volume_id {
48         unsigned char   label_raw[VOLUME_ID_LABEL_SIZE];
49         unsigned int    label_raw_len;
50         char            label_string[VOLUME_ID_LABEL_SIZE+1];
51         unsigned char   uuid[VOLUME_ID_UUID_SIZE];
52         char            uuid_string[VOLUME_ID_UUID_STRING_SIZE];
53         enum            filesystem_type fs_type;
54         char            *fs_name;
55         int             fd;
56         unsigned char   *sbbuf;
57         unsigned int    sbbuf_len;
58         unsigned char   *seekbuf;
59         unsigned int    seekbuf_off;
60         unsigned int    seekbuf_len;
61         int             fd_close;
62 };
63
64 /* open volume by already open file descriptor */
65 extern struct volume_id *volume_id_open_fd(int fd);
66
67 /* open volume by device node */
68 extern struct volume_id *volume_id_open_node(const char *path);
69
70 /* open volume by major/minor */
71 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
72
73 /* probe volume for filesystem type and try to read label/uuid */
74 extern int volume_id_probe(struct volume_id *id, enum filesystem_type fs_type);
75
76 /* free allocated device info */
77 extern void volume_id_close(struct volume_id *id);
78
79 #endif