2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
5 * Copyright (C) 2005 Tobias Klauser <tklauser@access.unizh.ch>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * 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 reiserfs_super_block {
36 uint32_t blocks_count;
39 uint32_t journal_block;
41 uint32_t orig_journal_size;
51 struct reiser4_super_block {
59 #define REISERFS1_SUPERBLOCK_OFFSET 0x2000
60 #define REISERFS_SUPERBLOCK_OFFSET 0x10000
62 int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off, uint64_t size)
64 struct reiserfs_super_block *rs;
65 struct reiser4_super_block *rs4;
68 info("probing at offset 0x%" PRIx64 "\n", off);
70 buf = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
74 rs = (struct reiserfs_super_block *) buf;
75 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
76 strcpy(id->type_version, "3.5");
77 id->type = "reiserfs";
80 if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
81 strcpy(id->type_version, "3.6");
82 id->type = "reiserfs";
85 if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
86 strcpy(id->type_version, "JR");
87 id->type = "reiserfs";
91 rs4 = (struct reiser4_super_block *) buf;
92 if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
93 strcpy(id->type_version, "4");
94 volume_id_set_label_raw(id, rs4->label, 16);
95 volume_id_set_label_string(id, rs4->label, 16);
96 volume_id_set_uuid(id, rs4->uuid, 0, UUID_DCE);
101 buf = volume_id_get_buffer(id, off + REISERFS1_SUPERBLOCK_OFFSET, 0x200);
105 rs = (struct reiserfs_super_block *) buf;
106 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
107 strcpy(id->type_version, "3.5");
108 id->type = "reiserfs";
115 volume_id_set_label_raw(id, rs->label, 16);
116 volume_id_set_label_string(id, rs->label, 16);
117 volume_id_set_uuid(id, rs->uuid, 0, UUID_DCE);
120 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);