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 library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library 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 GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include <asm/types.h>
38 #include "volume_id.h"
43 struct reiserfs_super_block {
49 __u32 orig_journal_size;
57 } __attribute__((__packed__));
59 struct reiser4_super_block {
65 } __attribute__((__packed__));
67 #define REISERFS1_SUPERBLOCK_OFFSET 0x2000
68 #define REISERFS_SUPERBLOCK_OFFSET 0x10000
70 int volume_id_probe_reiserfs(struct volume_id *id, __u64 off)
72 struct reiserfs_super_block *rs;
73 struct reiser4_super_block *rs4;
76 dbg("probing at offset %llu", off);
78 buf = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
82 rs = (struct reiserfs_super_block *) buf;;
83 if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
84 strcpy(id->type_version, "3.6");
87 if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
88 strcpy(id->type_version, "JR");
92 rs4 = (struct reiser4_super_block *) buf;
93 if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
94 strcpy(id->type_version, "4");
95 volume_id_set_label_raw(id, rs4->label, 16);
96 volume_id_set_label_string(id, rs4->label, 16);
97 volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
101 rs = (struct reiserfs_super_block *) volume_id_get_buffer(id, off + REISERFS1_SUPERBLOCK_OFFSET, 0x200);
105 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
106 strcpy(id->type_version, "3.5");
113 volume_id_set_label_raw(id, rs->label, 16);
114 volume_id_set_label_string(id, rs->label, 16);
115 volume_id_set_uuid(id, rs->uuid, UUID_DCE);
118 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
119 id->type = "reiserfs";