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 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 16
33 enum volume_id_usage {
38 VOLUME_ID_PARTITIONTABLE,
44 VOLUME_ID_MSDOSPARTTABLE,
45 VOLUME_ID_MSDOSEXTENDED,
65 struct volume_id_partition {
66 enum volume_id_usage usage_id;
67 enum volume_id_type type_id;
69 unsigned long long off;
70 unsigned long long len;
71 unsigned int partition_type_raw;
75 unsigned char label_raw[VOLUME_ID_LABEL_SIZE];
76 unsigned int label_raw_len;
77 char label[VOLUME_ID_LABEL_SIZE+1];
78 unsigned char uuid_raw[VOLUME_ID_UUID_SIZE];
79 char uuid[VOLUME_ID_UUID_STRING_SIZE];
80 enum volume_id_usage usage_id;
81 enum volume_id_type type_id;
83 char type_version[VOLUME_ID_FORMAT_SIZE];
84 struct volume_id_partition *partitions;
85 unsigned int partition_count;
88 unsigned int sbbuf_len;
89 unsigned char *seekbuf;
90 unsigned long long seekbuf_off;
91 unsigned int seekbuf_len;
95 /* open volume by already open file descriptor */
96 extern struct volume_id *volume_id_open_fd(int fd);
98 /* open volume by device node */
99 extern struct volume_id *volume_id_open_node(const char *path);
101 /* open volume by major/minor */
102 extern struct volume_id *volume_id_open_dev_t(dev_t devt);
104 /* probe volume for filesystem type and try to read label/uuid */
105 extern int volume_id_probe(struct volume_id *id, enum volume_id_type type,
106 unsigned long long off, unsigned long long size);
108 /* free allocated device info */
109 extern void volume_id_close(struct volume_id *id);