2
* Copyright (C) 1999, 2001 by Andries Brouwer
3
* Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
4
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
6
* This file may be redistributed under the terms of the
7
* GNU Lesser General Public License.
15
#include "superblocks.h"
17
struct ocfs_volume_header {
18
unsigned char minor_version[4];
19
unsigned char major_version[4];
20
unsigned char signature[128];
22
unsigned char mount_len[2];
23
} __attribute__((packed));
25
struct ocfs_volume_label {
26
unsigned char disk_lock[48];
28
unsigned char label_len[2];
29
unsigned char vol_id[16];
30
unsigned char vol_id_len[2];
31
} __attribute__((packed));
33
#define ocfsmajor(o) ( (uint32_t) o.major_version[0] \
34
+ (((uint32_t) o.major_version[1]) << 8) \
35
+ (((uint32_t) o.major_version[2]) << 16) \
36
+ (((uint32_t) o.major_version[3]) << 24))
38
#define ocfsminor(o) ( (uint32_t) o.minor_version[0] \
39
+ (((uint32_t) o.minor_version[1]) << 8) \
40
+ (((uint32_t) o.minor_version[2]) << 16) \
41
+ (((uint32_t) o.minor_version[3]) << 24))
43
#define ocfslabellen(o) ((uint32_t)o.label_len[0] + (((uint32_t) o.label_len[1]) << 8))
44
#define ocfsmountlen(o) ((uint32_t)o.mount_len[0] + (((uint32_t) o.mount_len[1]) << 8))
46
struct ocfs2_super_block {
47
uint8_t i_signature[8];
48
uint32_t i_generation;
49
int16_t i_suballoc_slot;
50
uint16_t i_suballoc_bit;
57
uint16_t i_links_count;
64
uint64_t i_last_eb_blk;
65
uint32_t i_fs_generation;
66
uint32_t i_atime_nsec;
67
uint32_t i_ctime_nsec;
68
uint32_t i_mtime_nsec;
69
uint64_t i_reserved1[9];
71
uint16_t s_major_rev_level;
72
uint16_t s_minor_rev_level;
74
int16_t s_max_mnt_count;
77
uint32_t s_checkinterval;
79
uint32_t s_creator_os;
80
uint32_t s_feature_compat;
81
uint32_t s_feature_incompat;
82
uint32_t s_feature_ro_compat;
83
uint64_t s_root_blkno;
84
uint64_t s_system_dir_blkno;
85
uint32_t s_blocksize_bits;
86
uint32_t s_clustersize_bits;
90
uint64_t s_first_cluster_group;
93
} __attribute__((packed));
95
struct oracle_asm_disk_label {
99
} __attribute__((packed));
101
static int probe_ocfs(blkid_probe pr, const struct blkid_idmag *mag)
104
struct ocfs_volume_header ovh;
105
struct ocfs_volume_label ovl;
109
buf = blkid_probe_get_buffer(pr, mag->kboff << 10,
110
sizeof(struct ocfs_volume_header));
113
memcpy(&ovh, buf, sizeof(ovh));
116
buf = blkid_probe_get_buffer(pr, (mag->kboff << 10) + 512,
117
sizeof(struct ocfs_volume_label));
120
memcpy(&ovl, buf, sizeof(ovl));
122
maj = ocfsmajor(ovh);
123
min = ocfsminor(ovh);
126
blkid_probe_set_value(pr, "SEC_TYPE",
127
(unsigned char *) "ocfs1", sizeof("ocfs1"));
129
blkid_probe_set_value(pr, "SEC_TYPE",
130
(unsigned char *) "ntocfs", sizeof("ntocfs"));
132
blkid_probe_set_label(pr, (unsigned char *) ovl.label,
134
blkid_probe_set_value(pr, "MOUNT", (unsigned char *) ovh.mount,
136
blkid_probe_set_uuid(pr, ovl.vol_id);
137
blkid_probe_sprintf_version(pr, "%u.%u", maj, min);
141
static int probe_ocfs2(blkid_probe pr, const struct blkid_idmag *mag)
143
struct ocfs2_super_block *osb;
145
osb = blkid_probe_get_sb(pr, mag, struct ocfs2_super_block);
149
blkid_probe_set_label(pr, (unsigned char *) osb->s_label, sizeof(osb->s_label));
150
blkid_probe_set_uuid(pr, osb->s_uuid);
152
blkid_probe_sprintf_version(pr, "%u.%u",
153
le16_to_cpu(osb->s_major_rev_level),
154
le16_to_cpu(osb->s_minor_rev_level));
159
static int probe_oracleasm(blkid_probe pr, const struct blkid_idmag *mag)
161
struct oracle_asm_disk_label *dl;
163
dl = blkid_probe_get_sb(pr, mag, struct oracle_asm_disk_label);
167
blkid_probe_set_label(pr, (unsigned char *) dl->dl_id, sizeof(dl->dl_id));
172
const struct blkid_idinfo ocfs_idinfo =
175
.usage = BLKID_USAGE_FILESYSTEM,
176
.probefunc = probe_ocfs,
177
.minsz = 108 * 1024 * 1024,
180
{ .magic = "OracleCFS", .len = 9, .kboff = 8 },
185
const struct blkid_idinfo ocfs2_idinfo =
188
.usage = BLKID_USAGE_FILESYSTEM,
189
.probefunc = probe_ocfs2,
190
.minsz = 108 * 1024 * 1024,
193
{ .magic = "OCFSV2", .len = 6, .kboff = 1 },
194
{ .magic = "OCFSV2", .len = 6, .kboff = 2 },
195
{ .magic = "OCFSV2", .len = 6, .kboff = 4 },
196
{ .magic = "OCFSV2", .len = 6, .kboff = 8 },
201
/* Oracle ASM (Automatic Storage Management) */
202
const struct blkid_idinfo oracleasm_idinfo =
205
.usage = BLKID_USAGE_FILESYSTEM,
206
.probefunc = probe_oracleasm,
209
{ .magic = "ORCLDISK", .len = 8, .sboff = 32 },