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"
38 #include "../logging.h"
42 #define UFS_MAGIC 0x00011954
43 #define UFS2_MAGIC 0x19540119
44 #define UFS_MAGIC_FEA 0x00195612
45 #define UFS_MAGIC_LFN 0x00095014
47 int volume_id_probe_ufs(struct volume_id *id, __u64 off)
49 struct ufs_super_block {
83 __u32 fs_npsect_state;
102 } __attribute__((__packed__)) fs_cstotal;
114 __u16 fs_opostbl[16][8];
115 } __attribute__((__packed__)) fs_u1;
129 __s64 fs_sparecon64[17];
131 struct ufs2_csum_total {
136 __u64 cs_numclusters;
138 } __attribute__((__packed__)) fs_cstotal;
142 } __attribute__((__packed__)) fs_time;
146 __s64 fs_pendingblocks;
147 __s32 fs_pendinginodes;
148 } __attribute__((__packed__)) fs_u2;
152 __s32 fs_sparecon[53];
154 __s32 fs_sparecon2[1];
158 } __attribute__((__packed__)) fs_sun;
160 __s32 fs_sparecon[53];
162 __s32 fs_sparecon2[1];
166 } __attribute__((__packed__)) fs_sunx86;
168 __s32 fs_sparecon[50];
169 __s32 fs_contigsumsize;
170 __s32 fs_maxsymlinklen;
172 __u32 fs_maxfilesize[2];
176 } __attribute__((__packed__)) fs_44;
178 __s32 fs_postblformat;
184 } __attribute__((__packed__)) *ufs;
188 int offsets[] = {0, 8, 64, 256, -1};
190 for (i = 0; offsets[i] >= 0; i++) {
191 ufs = (struct ufs_super_block *) volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800);
195 dbg("offset 0x%x", offsets[i] * 0x400);
196 magic = be32_to_cpu(ufs->fs_magic);
197 if ((magic == UFS_MAGIC) ||
198 (magic == UFS2_MAGIC) ||
199 (magic == UFS_MAGIC_FEA) ||
200 (magic == UFS_MAGIC_LFN)) {
201 dbg("magic 0x%08x(be)", magic);
204 magic = le32_to_cpu(ufs->fs_magic);
205 if ((magic == UFS_MAGIC) ||
206 (magic == UFS2_MAGIC) ||
207 (magic == UFS_MAGIC_FEA) ||
208 (magic == UFS_MAGIC_LFN)) {
209 dbg("magic 0x%08x(le)", magic);
216 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);