1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include "volume_id_internal.h"
29
30struct reiserfs_super_block {
31 uint32_t blocks_count;
32 uint32_t free_blocks;
33 uint32_t root_block;
34 uint32_t journal_block;
35 uint32_t journal_dev;
36 uint32_t orig_journal_size;
37 uint32_t dummy2[5];
38 uint16_t blocksize;
39 uint16_t dummy3[3];
40 uint8_t magic[12];
41 uint32_t dummy4[5];
42 uint8_t uuid[16];
43 uint8_t label[16];
44} PACKED;
45
46struct reiser4_super_block {
47 uint8_t magic[16];
48 uint16_t dummy[2];
49 uint8_t uuid[16];
50 uint8_t label[16];
51 uint64_t dummy2;
52} PACKED;
53
54#define REISERFS1_SUPERBLOCK_OFFSET 0x2000
55#define REISERFS_SUPERBLOCK_OFFSET 0x10000
56
57int FAST_FUNC volume_id_probe_reiserfs(struct volume_id *id )
58{
59#define off ((uint64_t)0)
60 struct reiserfs_super_block *rs;
61 struct reiser4_super_block *rs4;
62
63 dbg("reiserfs: probing at offset 0x%llx", (unsigned long long) off);
64
65 rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
66 if (rs == NULL)
67 return -1;
68
69 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
70 dbg("reiserfs: ReIsErFs, no label");
71
72 goto found;
73 }
74 if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
75 dbg("reiserfs: ReIsEr2Fs");
76
77 goto found_label;
78 }
79 if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
80 dbg("reiserfs: ReIsEr3Fs");
81
82 goto found_label;
83 }
84
85 rs4 = (struct reiser4_super_block *) rs;
86 if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
87
88
89 volume_id_set_label_string(id, rs4->label, 16);
90 volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
91 dbg("reiserfs: ReIsEr4, label '%s' uuid '%s'", id->label, id->uuid);
92 goto found;
93 }
94
95 rs = volume_id_get_buffer(id, off + REISERFS1_SUPERBLOCK_OFFSET, 0x200);
96 if (rs == NULL)
97 return -1;
98
99 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
100 dbg("reiserfs: ReIsErFs, no label");
101
102 goto found;
103 }
104
105 dbg("reiserfs: no signature found");
106 return -1;
107
108 found_label:
109
110 volume_id_set_label_string(id, rs->label, 16);
111 volume_id_set_uuid(id, rs->uuid, UUID_DCE);
112 dbg("reiserfs: label '%s' uuid '%s'", id->label, id->uuid);
113
114 found:
115
116 IF_FEATURE_BLKID_TYPE(id->type = "reiserfs";)
117
118 return 0;
119}
120