2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 #include "libvolume_id.h"
33 #include "libvolume_id-private.h"
35 struct btrfs_super_block {
45 uint64_t log_root_transid;
48 uint64_t root_dir_objectid;
54 uint32_t sys_chunk_array_size;
55 uint64_t chunk_root_generation;
56 uint64_t compat_flags;
57 uint64_t compat_ro_flags;
58 uint64_t incompat_flags;
61 uint8_t chunk_root_level;
62 uint8_t log_root_level;
63 struct btrfs_dev_item {
72 uint64_t start_offset;
82 int volume_id_probe_btrfs(struct volume_id *id, uint64_t off, uint64_t size)
85 struct btrfs_super_block *bfs;
87 info("probing at offset 0x%" PRIx64 ", size 0x%" PRIx64 "\n", off, size);
89 buf = volume_id_get_buffer(id, off + 0x10000, 0x200);
92 bfs = (struct btrfs_super_block *)buf;
93 if (memcmp(bfs->magic, "_BHRfS_M", 8) != 0)
95 volume_id_set_uuid(id, bfs->fsid, 0, UUID_DCE);
96 volume_id_set_uuid_sub(id, bfs->dev_item.uuid, 0, UUID_DCE);
97 volume_id_set_label_raw(id, bfs->label, 256);
98 volume_id_set_label_string(id, bfs->label, 256);
99 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);