volume_id.h revision 7808297b0fcb5a8033fd2d55854d065d8b1719e8
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*
530eba85dbd41b8a0fa5255d3648d1440199a661slive * volume_id - reads volume label and uuid
e942c741056732f50da2074b36fe59805d370650slive *
7db9f691a00ead175b03335457ca296a33ddf31bnd * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * This program is free software; you can redistribute it and/or modify it
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * under the terms of the GNU General Public License as published by the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Free Software Foundation version 2 of the License.
530eba85dbd41b8a0fa5255d3648d1440199a661slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#ifndef _VOLUME_ID_H_
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define _VOLUME_ID_H_
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#include <stdint.h>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#include <stddef.h>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_VERSION 60
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele#ifndef PACKED
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define PACKED __attribute__((packed))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_LABEL_SIZE 64
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_UUID_SIZE 36
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_FORMAT_SIZE 32
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_PATH_MAX 256
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define VOLUME_ID_PARTITIONS_MAX 256
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kessenum volume_id_usage {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_UNUSED,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_UNPROBED,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_OTHER,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_FILESYSTEM,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_RAID,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VOLUME_ID_DISKLABEL,
fb77c505254b6e9c925e23e734463e87574f8f40kess VOLUME_ID_CRYPTO,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive};
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestruct volume_id {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive uint8_t label_raw[VOLUME_ID_LABEL_SIZE];
fb77c505254b6e9c925e23e734463e87574f8f40kess size_t label_raw_len;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char label[VOLUME_ID_LABEL_SIZE+1];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive uint8_t uuid_raw[VOLUME_ID_UUID_SIZE];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive size_t uuid_raw_len;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char uuid[VOLUME_ID_UUID_SIZE+1];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive enum volume_id_usage usage_id;
fb77c505254b6e9c925e23e734463e87574f8f40kess char *usage;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *type;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char type_version[VOLUME_ID_FORMAT_SIZE];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess int fd;
fb77c505254b6e9c925e23e734463e87574f8f40kess uint8_t *sbbuf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive size_t sbbuf_len;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive uint8_t *seekbuf;
fb77c505254b6e9c925e23e734463e87574f8f40kess uint64_t seekbuf_off;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess size_t seekbuf_len;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int fd_close:1;
fb77c505254b6e9c925e23e734463e87574f8f40kess};
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern struct volume_id *volume_id_open_fd(int fd);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern struct volume_id *volume_id_open_node(const char *path);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size);
fb77c505254b6e9c925e23e734463e87574f8f40kessextern int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size);
fb77c505254b6e9c925e23e734463e87574f8f40kessextern void volume_id_close(struct volume_id *id);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess/* filesystems */
fb77c505254b6e9c925e23e734463e87574f8f40kessextern int volume_id_probe_cramfs(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_ext(struct volume_id *id, uint64_t off);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_vfat(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_hpfs(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_iso9660(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_jfs(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_minix(struct volume_id *id, uint64_t off);
ef8e89e090461194ecadd31e8796a2c51e0531a2kessextern int volume_id_probe_ntfs(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_ocfs1(struct volume_id *id, uint64_t off);
130d299c4b2b15be45532a176604c71fdc7bea5bndextern int volume_id_probe_ocfs2(struct volume_id *id, uint64_t off);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_romfs(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_sysv(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_udf(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_ufs(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_vxfs(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_xfs(struct volume_id *id, uint64_t off);
003f0c9fda6664daf5092a0e42f65ede20098153sliveextern int volume_id_probe_squashfs(struct volume_id *id, uint64_t off);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* special formats */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_luks(struct volume_id *id, uint64_t off);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* raid */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessextern int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size);
003f0c9fda6664daf5092a0e42f65ede20098153sliveextern int volume_id_probe_lvm1(struct volume_id *id, uint64_t off);
003f0c9fda6664daf5092a0e42f65ede20098153sliveextern int volume_id_probe_lvm2(struct volume_id *id, uint64_t off);
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess/* bios raid */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_intel_software_raid(struct volume_id *id, uint64_t off, uint64_t size);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_highpoint_37x_raid(struct volume_id *id, uint64_t off);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_highpoint_45x_raid(struct volume_id *id, uint64_t off, uint64_t size);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndextern int volume_id_probe_lsi_mega_raid(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_nvidia_raid(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_promise_fasttrack_raid(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_silicon_medley_raid(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveextern int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive