2
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
4
* Inspired by libvolume_id by
5
* Kay Sievers <kay.sievers@vrfy.org>
7
* This file may be redistributed under the terms of the
8
* GNU Lesser General Public License.
21
struct ufs_super_block {
44
uint32_t fs_maxcontig;
46
uint32_t fs_fragshift;
55
uint32_t fs_npsect_state;
56
uint32_t fs_interleave;
57
uint32_t fs_trackskew;
84
uint32_t fs_maxcluster;
86
uint16_t fs_opostbl[16][8];
90
uint8_t fs_volname[32];
95
uint32_t fs_contigdirs;
97
uint32_t fs_maxcluster;
101
int64_t fs_sparecon64[17];
102
int64_t fs_sblockloc;
103
struct ufs2_csum_total {
108
uint64_t cs_numclusters;
109
uint64_t cs_spare[3];
118
int64_t fs_pendingblocks;
119
int32_t fs_pendinginodes;
124
int32_t fs_sparecon[53];
126
int32_t fs_sparecon2[1];
128
uint32_t fs_qbmask[2];
129
uint32_t fs_qfmask[2];
132
int32_t fs_sparecon[53];
134
int32_t fs_sparecon2[1];
136
uint32_t fs_qbmask[2];
137
uint32_t fs_qfmask[2];
140
int32_t fs_sparecon[50];
141
int32_t fs_contigsumsize;
142
int32_t fs_maxsymlinklen;
144
uint32_t fs_maxfilesize[2];
145
uint32_t fs_qbmask[2];
146
uint32_t fs_qfmask[2];
150
int32_t fs_postblformat;
152
int32_t fs_postbloff;
158
#define UFS_MAGIC 0x00011954
159
#define UFS2_MAGIC 0x19540119
160
#define UFS_MAGIC_FEA 0x00195612
161
#define UFS_MAGIC_LFN 0x00095014
163
static int probe_ufs(blkid_probe pr, const struct blkid_idmag *mag)
165
int offsets[] = { 0, 8, 64, 256 };
166
int mags[] = { UFS2_MAGIC, UFS_MAGIC, UFS_MAGIC_FEA, UFS_MAGIC_LFN };
169
struct ufs_super_block *ufs;
171
for (i = 0; i < ARRAY_SIZE(offsets); i++) {
172
uint32_t magLE, magBE;
175
ufs = (struct ufs_super_block *)
176
blkid_probe_get_buffer(pr,
178
sizeof(struct ufs_super_block));
182
magBE = be32_to_cpu(ufs->fs_magic);
183
magLE = le32_to_cpu(ufs->fs_magic);
185
for (y = 0; y < ARRAY_SIZE(mags); y++) {
186
if (magLE == mags[y] || magBE == mags[y]) {
196
if (magic == UFS2_MAGIC) {
197
blkid_probe_set_version(pr, "2");
198
blkid_probe_set_label(pr, ufs->fs_u11.fs_u2.fs_volname,
199
sizeof(ufs->fs_u11.fs_u2.fs_volname));
201
blkid_probe_set_version(pr, "1");
207
* According to libvolume_id the UFS superblock could be on four positions.
208
* The original libblkid has checked one position (.kboff=8) only.
210
* We know four UFS magic strings and UFS could be both little-endian and
211
* big-endian. ... so we have:
213
* 4 position * 4 string * 2 version = 32 magic strings
215
* It seems simpler to check for these string in probing function that hardcode
216
* all in the .magic array.
218
const struct blkid_idinfo ufs_idinfo =
221
.usage = BLKID_USAGE_FILESYSTEM,
222
.probefunc = probe_ufs,
223
.magics = BLKID_NONE_MAGIC