2 * volume_id - reads partition label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
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.
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.
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
24 #define VOLUME_ID_VERSION 26
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 16
33 enum volume_id_usage {
38 VOLUME_ID_PARTITIONTABLE,
44 VOLUME_ID_MSDOSPARTTABLE,
45 VOLUME_ID_MSDOSEXTENDED,
66 struct volume_id_partition {
67 enum volume_id_usage usage_id;
68 enum volume_id_type type_id;
70 unsigned long long off;
71 unsigned long long len;
72 unsigned int partition_type_raw;
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;
84 char type_version[VOLUME_ID_FORMAT_SIZE];
85 struct volume_id_partition *partitions;
86 unsigned int partition_count;
89 unsigned int sbbuf_len;
90 unsigned char *seekbuf;
91 unsigned long long seekbuf_off;
92 unsigned int seekbuf_len;
96 /* open volume by already open file descriptor */
97 extern struct volume_id *volume_id_open_fd(int fd);
99 /* open volume by device node */
100 extern struct volume_id *volume_id_open_node(const char *path);
102 /* open volume by major/minor */
103 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
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);
109 /* free allocated device info */
110 extern void volume_id_close(struct volume_id *id);