2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
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.
26 #include "volume_id.h"
31 struct ext2_super_block {
32 uint32_t inodes_count;
33 uint32_t blocks_count;
34 uint32_t r_blocks_count;
35 uint32_t free_blocks_count;
36 uint32_t free_inodes_count;
37 uint32_t first_data_block;
38 uint32_t log_block_size;
43 uint32_t feature_compat;
44 uint32_t feature_incompat;
45 uint32_t feature_ro_compat;
47 uint8_t volume_name[16];
48 } __attribute__((__packed__));
50 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
51 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
52 #define EXT_SUPERBLOCK_OFFSET 0x400
54 int volume_id_probe_ext(struct volume_id *id, uint64_t off)
56 struct ext2_super_block *es;
58 dbg("probing at offset 0x%llx", (unsigned long long) off);
60 es = (struct ext2_super_block *) volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200);
64 if (es->magic[0] != 0123 ||
68 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
69 volume_id_set_label_raw(id, es->volume_name, 16);
70 volume_id_set_label_string(id, es->volume_name, 16);
71 volume_id_set_uuid(id, es->uuid, UUID_DCE);
73 if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)