source: MondoRescue/branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/probe.h@ 3320

Last change on this file since 3320 was 3320, checked in by Bruno Cornec, 9 years ago
  • Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in the move to 3.0
  • Property svn:eol-style set to native
File size: 8.7 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * probe.h - constants and on-disk structures for extracting device data
4 *
5 * Copyright (C) 1999 by Andries Brouwer
6 * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
7 * Copyright (C) 2001 by Andreas Dilger
8 *
9 * %Begin-Header%
10 * This file may be redistributed under the terms of the
11 * GNU Lesser General Public License.
12 * %End-Header%
13 */
14#ifndef BLKID_PROBE_H
15#define BLKID_PROBE_H 1
16
17#include <linux/types.h>
18
19struct blkid_magic;
20
21typedef int (*blkid_probe_t)(int fd, blkid_cache cache, blkid_dev dev,
22 const struct blkid_magic *id, unsigned char *buf);
23
24struct blkid_magic {
25 const char *bim_type; /* type name for this magic */
26 long bim_kboff; /* kilobyte offset of superblock */
27 unsigned bim_sboff; /* byte offset within superblock */
28 unsigned bim_len; /* length of magic */
29 const char *bim_magic; /* magic string */
30 blkid_probe_t bim_probe; /* probe function */
31};
32
33/*
34 * Structures for each of the content types we want to extract information
35 * from. We do not necessarily need the magic field here, because we have
36 * already identified the content type before we get this far. It may still
37 * be useful if there are probe functions which handle multiple content types.
38 */
39struct ext2_super_block {
40 __u32 s_inodes_count;
41 __u32 s_blocks_count;
42 __u32 s_r_blocks_count;
43 __u32 s_free_blocks_count;
44 __u32 s_free_inodes_count;
45 __u32 s_first_data_block;
46 __u32 s_log_block_size;
47 __u32 s_dummy3[7];
48 unsigned char s_magic[2];
49 __u16 s_state;
50 __u32 s_dummy5[8];
51 __u32 s_feature_compat;
52 __u32 s_feature_incompat;
53 __u32 s_feature_ro_compat;
54 unsigned char s_uuid[16];
55 char s_volume_name[16];
56};
57#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
58#define EXT3_FEATURE_INCOMPAT_RECOVER 0x00000004
59#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
60
61struct xfs_super_block {
62 unsigned char xs_magic[4];
63 __u32 xs_blocksize;
64 __u64 xs_dblocks;
65 __u64 xs_rblocks;
66 __u32 xs_dummy1[2];
67 unsigned char xs_uuid[16];
68 __u32 xs_dummy2[15];
69 char xs_fname[12];
70 __u32 xs_dummy3[2];
71 __u64 xs_icount;
72 __u64 xs_ifree;
73 __u64 xs_fdblocks;
74};
75
76struct reiserfs_super_block {
77 __u32 rs_blocks_count;
78 __u32 rs_free_blocks;
79 __u32 rs_root_block;
80 __u32 rs_journal_block;
81 __u32 rs_journal_dev;
82 __u32 rs_orig_journal_size;
83 __u32 rs_dummy2[5];
84 __u16 rs_blocksize;
85 __u16 rs_dummy3[3];
86 unsigned char rs_magic[12];
87 __u32 rs_dummy4[5];
88 unsigned char rs_uuid[16];
89 char rs_label[16];
90};
91
92struct jfs_super_block {
93 unsigned char js_magic[4];
94 __u32 js_version;
95 __u64 js_size;
96 __u32 js_bsize;
97 __u32 js_dummy1;
98 __u32 js_pbsize;
99 __u32 js_dummy2[27];
100 unsigned char js_uuid[16];
101 unsigned char js_label[16];
102 unsigned char js_loguuid[16];
103};
104
105struct romfs_super_block {
106 unsigned char ros_magic[8];
107 __u32 ros_dummy1[2];
108 unsigned char ros_volume[16];
109};
110
111struct cramfs_super_block {
112 __u8 magic[4];
113 __u32 size;
114 __u32 flags;
115 __u32 future;
116 __u8 signature[16];
117 struct cramfs_info {
118 __u32 crc;
119 __u32 edition;
120 __u32 blocks;
121 __u32 files;
122 } info;
123 __u8 name[16];
124};
125
126struct swap_id_block {
127/* unsigned char sws_boot[1024]; */
128 __u32 sws_version;
129 __u32 sws_lastpage;
130 __u32 sws_nrbad;
131 unsigned char sws_uuid[16];
132 char sws_volume[16];
133 unsigned char sws_pad[117];
134 __u32 sws_badpg;
135};
136
137/* Yucky misaligned values */
138struct vfat_super_block {
139/* 00*/ unsigned char vs_ignored[3];
140/* 03*/ unsigned char vs_sysid[8];
141/* 0b*/ unsigned char vs_sector_size[2];
142/* 0d*/ __u8 vs_cluster_size;
143/* 0e*/ __u16 vs_reserved;
144/* 10*/ __u8 vs_fats;
145/* 11*/ unsigned char vs_dir_entries[2];
146/* 13*/ unsigned char vs_sectors[2];
147/* 15*/ unsigned char vs_media;
148/* 16*/ __u16 vs_fat_length;
149/* 18*/ __u16 vs_secs_track;
150/* 1a*/ __u16 vs_heads;
151/* 1c*/ __u32 vs_hidden;
152/* 20*/ __u32 vs_total_sect;
153/* 24*/ __u32 vs_fat32_length;
154/* 28*/ __u16 vs_flags;
155/* 2a*/ __u8 vs_version[2];
156/* 2c*/ __u32 vs_root_cluster;
157/* 30*/ __u16 vs_insfo_sector;
158/* 32*/ __u16 vs_backup_boot;
159/* 34*/ __u16 vs_reserved2[6];
160/* 40*/ unsigned char vs_unknown[3];
161/* 43*/ unsigned char vs_serno[4];
162/* 47*/ char vs_label[11];
163/* 52*/ unsigned char vs_magic[8];
164/* 5a*/ unsigned char vs_dummy2[164];
165/*1fe*/ unsigned char vs_pmagic[2];
166};
167
168/* Yucky misaligned values */
169struct msdos_super_block {
170/* 00*/ unsigned char ms_ignored[3];
171/* 03*/ unsigned char ms_sysid[8];
172/* 0b*/ unsigned char ms_sector_size[2];
173/* 0d*/ __u8 ms_cluster_size;
174/* 0e*/ __u16 ms_reserved;
175/* 10*/ __u8 ms_fats;
176/* 11*/ unsigned char ms_dir_entries[2];
177/* 13*/ unsigned char ms_sectors[2];
178/* 15*/ unsigned char ms_media;
179/* 16*/ __u16 ms_fat_length;
180/* 18*/ __u16 ms_secs_track;
181/* 1a*/ __u16 ms_heads;
182/* 1c*/ __u32 ms_hidden;
183/* 20*/ __u32 ms_total_sect;
184/* 24*/ unsigned char ms_unknown[3];
185/* 27*/ unsigned char ms_serno[4];
186/* 2b*/ char ms_label[11];
187/* 36*/ unsigned char ms_magic[8];
188/* 3d*/ unsigned char ms_dummy2[192];
189/*1fe*/ unsigned char ms_pmagic[2];
190};
191
192struct minix_super_block {
193 __u16 ms_ninodes;
194 __u16 ms_nzones;
195 __u16 ms_imap_blocks;
196 __u16 ms_zmap_blocks;
197 __u16 ms_firstdatazone;
198 __u16 ms_log_zone_size;
199 __u32 ms_max_size;
200 unsigned char ms_magic[2];
201 __u16 ms_state;
202 __u32 ms_zones;
203};
204
205struct mdp_superblock_s {
206 __u32 md_magic;
207 __u32 major_version;
208 __u32 minor_version;
209 __u32 patch_version;
210 __u32 gvalid_words;
211 __u32 set_uuid0;
212 __u32 ctime;
213 __u32 level;
214 __u32 size;
215 __u32 nr_disks;
216 __u32 raid_disks;
217 __u32 md_minor;
218 __u32 not_persistent;
219 __u32 set_uuid1;
220 __u32 set_uuid2;
221 __u32 set_uuid3;
222};
223
224struct hfs_super_block {
225 char h_magic[2];
226 char h_dummy[18];
227 __u32 h_blksize;
228};
229
230struct ocfs_volume_header {
231 unsigned char minor_version[4];
232 unsigned char major_version[4];
233 unsigned char signature[128];
234 char mount[128];
235 unsigned char mount_len[2];
236};
237
238struct ocfs_volume_label {
239 unsigned char disk_lock[48];
240 char label[64];
241 unsigned char label_len[2];
242 unsigned char vol_id[16];
243 unsigned char vol_id_len[2];
244};
245
246#define ocfsmajor(o) ((__u32)o.major_version[0] \
247 + (((__u32) o.major_version[1]) << 8) \
248 + (((__u32) o.major_version[2]) << 16) \
249 + (((__u32) o.major_version[3]) << 24))
250#define ocfslabellen(o) ((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
251#define ocfsmountlen(o) ((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
252
253#define OCFS_MAGIC "OracleCFS"
254
255struct ocfs2_super_block {
256 unsigned char signature[8];
257 unsigned char s_dummy1[184];
258 unsigned char s_dummy2[80];
259 char s_label[64];
260 unsigned char s_uuid[16];
261};
262
263#define OCFS2_MIN_BLOCKSIZE 512
264#define OCFS2_MAX_BLOCKSIZE 4096
265
266#define OCFS2_SUPER_BLOCK_BLKNO 2
267
268#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
269
270struct oracle_asm_disk_label {
271 char dummy[32];
272 char dl_tag[8];
273 char dl_id[24];
274};
275
276#define ORACLE_ASM_DISK_LABEL_MARKED "ORCLDISK"
277#define ORACLE_ASM_DISK_LABEL_OFFSET 32
278
279#define ISODCL(from, to) (to - from + 1)
280struct iso_volume_descriptor {
281 char type[ISODCL(1,1)]; /* 711 */
282 char id[ISODCL(2,6)];
283 char version[ISODCL(7,7)];
284 char data[ISODCL(8,2048)];
285};
286
287/*
288 * Byte swap functions
289 */
290#ifdef __GNUC__
291#define _INLINE_ static __inline__
292#else /* For Watcom C */
293#define _INLINE_ static inline
294#endif
295
296static __u16 blkid_swab16(__u16 val);
297static __u32 blkid_swab32(__u32 val);
298static __u64 blkid_swab64(__u64 val);
299
300#if ((defined __GNUC__) && \
301 (defined(__i386__) || defined(__i486__) || defined(__i586__)))
302
303#define _BLKID_HAVE_ASM_BITOPS_
304
305_INLINE_ __u32 blkid_swab32(__u32 val)
306{
307#ifdef EXT2FS_REQUIRE_486
308 __asm__("bswap %0" : "=r" (val) : "0" (val));
309#else
310 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
311 "rorl $16,%0\n\t" /* swap words */
312 "xchgb %b0,%h0" /* swap higher bytes */
313 :"=q" (val)
314 : "0" (val));
315#endif
316 return val;
317}
318
319_INLINE_ __u16 blkid_swab16(__u16 val)
320{
321 __asm__("xchgb %b0,%h0" /* swap bytes */
322 : "=q" (val)
323 : "0" (val));
324 return val;
325}
326
327_INLINE_ __u64 blkid_swab64(__u64 val)
328{
329 return blkid_swab32(val >> 32) |
330 ( ((__u64)blkid_swab32((__u32)val)) << 32 );
331}
332#endif
333
334#if !defined(_BLKID_HAVE_ASM_BITOPS_)
335
336_INLINE_ __u16 blkid_swab16(__u16 val)
337{
338 return (val >> 8) | (val << 8);
339}
340
341_INLINE_ __u32 blkid_swab32(__u32 val)
342{
343 return (val>>24) | ((val>>8) & 0xFF00) |
344 ((val<<8) & 0xFF0000) | (val<<24);
345}
346
347_INLINE_ __u64 blkid_swab64(__u64 val)
348{
349 return blkid_swab32(val >> 32) |
350 ( ((__u64)blkid_swab32((__u32)val)) << 32 );
351}
352#endif
353
354
355
356#if __BYTE_ORDER == __BIG_ENDIAN
357#define blkid_le16(x) blkid_swab16(x)
358#define blkid_le32(x) blkid_swab32(x)
359#define blkid_le64(x) blkid_swab64(x)
360#define blkid_be16(x) (x)
361#define blkid_be32(x) (x)
362#define blkid_be64(x) (x)
363#else
364#define blkid_le16(x) (x)
365#define blkid_le32(x) (x)
366#define blkid_le64(x) (x)
367#define blkid_be16(x) blkid_swab16(x)
368#define blkid_be32(x) blkid_swab32(x)
369#define blkid_be64(x) blkid_swab64(x)
370#endif
371
372#undef _INLINE_
373
374#endif /* _BLKID_PROBE_H */
Note: See TracBrowser for help on using the repository browser.