2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <asm/types.h>
37 #include "volume_id.h"
42 struct ufs_super_block {
76 __u32 fs_npsect_state;
95 } __attribute__((__packed__)) fs_cstotal;
107 __u16 fs_opostbl[16][8];
108 } __attribute__((__packed__)) fs_u1;
122 __s64 fs_sparecon64[17];
124 struct ufs2_csum_total {
129 __u64 cs_numclusters;
131 } __attribute__((__packed__)) fs_cstotal;
135 } __attribute__((__packed__)) fs_time;
139 __s64 fs_pendingblocks;
140 __s32 fs_pendinginodes;
141 } __attribute__((__packed__)) fs_u2;
145 __s32 fs_sparecon[53];
147 __s32 fs_sparecon2[1];
151 } __attribute__((__packed__)) fs_sun;
153 __s32 fs_sparecon[53];
155 __s32 fs_sparecon2[1];
159 } __attribute__((__packed__)) fs_sunx86;
161 __s32 fs_sparecon[50];
162 __s32 fs_contigsumsize;
163 __s32 fs_maxsymlinklen;
165 __u32 fs_maxfilesize[2];
169 } __attribute__((__packed__)) fs_44;
171 __s32 fs_postblformat;
177 } __attribute__((__packed__));
179 #define UFS_MAGIC 0x00011954
180 #define UFS2_MAGIC 0x19540119
181 #define UFS_MAGIC_FEA 0x00195612
182 #define UFS_MAGIC_LFN 0x00095014
184 int volume_id_probe_ufs(struct volume_id *id, __u64 off)
188 struct ufs_super_block *ufs;
189 int offsets[] = {0, 8, 64, 256, -1};
191 dbg("probing at offset %llu", off);
193 for (i = 0; offsets[i] >= 0; i++) {
194 ufs = (struct ufs_super_block *) volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800);
198 dbg("offset 0x%x", offsets[i] * 0x400);
199 magic = be32_to_cpu(ufs->fs_magic);
200 if ((magic == UFS_MAGIC) ||
201 (magic == UFS2_MAGIC) ||
202 (magic == UFS_MAGIC_FEA) ||
203 (magic == UFS_MAGIC_LFN)) {
204 dbg("magic 0x%08x(be)", magic);
207 magic = le32_to_cpu(ufs->fs_magic);
208 if ((magic == UFS_MAGIC) ||
209 (magic == UFS2_MAGIC) ||
210 (magic == UFS_MAGIC_FEA) ||
211 (magic == UFS_MAGIC_LFN)) {
212 dbg("magic 0x%08x(le)", magic);
219 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);