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 {
47 uint64_t root_dir_objectid;
53 uint32_t sys_chunk_array_size;
55 uint8_t chunk_root_level;
56 uint8_t log_root_level;
57 struct btrfs_dev_item {
73 int volume_id_probe_btrfs(struct volume_id *id, uint64_t off, uint64_t size)
76 struct btrfs_super_block *bfs;
78 info("probing at offset 0x%llx, size 0x%llx\n",
79 (unsigned long long)off, (unsigned long long)size);
81 buf = volume_id_get_buffer(id, off + 0x4000, 0x200);
84 bfs = (struct btrfs_super_block *)buf;
85 if (memcmp(bfs->magic, "_B9RfS_M", 8) != 0)
87 volume_id_set_uuid(id, bfs->fsid, 0, UUID_DCE);
88 volume_id_set_label_raw(id, bfs->label, 256);
89 volume_id_set_label_string(id, bfs->label, 256);
90 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);