2 * probe.h - constants and on-disk structures for extracting device data
4 * Copyright (C) 1999 by Andries Brouwer
5 * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
6 * Copyright (C) 2001 by Andreas Dilger
9 * This file may be redistributed under the terms of the
10 * GNU Lesser General Public License.
14 #ifndef _BLKID_PROBE_H
15 #define _BLKID_PROBE_H
17 #include <blkid/blkid_types.h>
21 #define SB_BUFFER_SIZE 0x11000
33 typedef int (*blkid_probe_t)(struct blkid_probe *probe,
34 struct blkid_magic *id, unsigned char *buf);
37 const char *bim_type; /* type name for this magic */
38 long bim_kboff; /* kilobyte offset of superblock */
39 unsigned bim_sboff; /* byte offset within superblock */
40 unsigned bim_len; /* length of magic */
41 const char *bim_magic; /* magic string */
42 blkid_probe_t bim_probe; /* probe function */
46 * Structures for each of the content types we want to extract information
47 * from. We do not necessarily need the magic field here, because we have
48 * already identified the content type before we get this far. It may still
49 * be useful if there are probe functions which handle multiple content types.
51 struct ext2_super_block {
54 __u32 s_r_blocks_count;
55 __u32 s_free_blocks_count;
56 __u32 s_free_inodes_count;
57 __u32 s_first_data_block;
58 __u32 s_log_block_size;
60 unsigned char s_magic[2];
63 __u32 s_feature_compat;
64 __u32 s_feature_incompat;
65 __u32 s_feature_ro_compat;
66 unsigned char s_uuid[16];
67 char s_volume_name[16];
68 char s_last_mounted[64];
69 __u32 s_algorithm_usage_bitmap;
70 __u8 s_prealloc_blocks;
71 __u8 s_prealloc_dir_blocks;
72 __u16 s_reserved_gdt_blocks;
73 __u8 s_journal_uuid[16];
78 __u8 s_def_hash_version;
79 __u8 s_jnl_backup_type;
80 __u16 s_reserved_word_pad;
81 __u32 s_default_mount_opts;
82 __u32 s_first_meta_bg;
84 __u32 s_jnl_blocks[17];
85 __u32 s_reserved[172];
87 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
88 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x00000004
89 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
91 struct xfs_super_block {
92 unsigned char xs_magic[4];
97 unsigned char xs_uuid[16];
106 struct reiserfs_super_block {
107 __u32 rs_blocks_count;
108 __u32 rs_free_blocks;
110 __u32 rs_journal_block;
111 __u32 rs_journal_dev;
112 __u32 rs_orig_journal_size;
116 unsigned char rs_magic[12];
118 unsigned char rs_uuid[16];
122 struct reiser4_super_block {
123 unsigned char rs4_magic[16];
125 unsigned char rs4_uuid[16];
126 unsigned char rs4_label[16];
130 struct jfs_super_block {
131 unsigned char js_magic[4];
138 unsigned char js_uuid[16];
139 unsigned char js_label[16];
140 unsigned char js_loguuid[16];
143 struct romfs_super_block {
144 unsigned char ros_magic[8];
146 unsigned char ros_volume[16];
149 struct cramfs_super_block {
164 struct swap_id_block {
165 /* unsigned char sws_boot[1024]; */
169 unsigned char sws_uuid[16];
171 unsigned char sws_pad[117];
175 /* Yucky misaligned values */
176 struct vfat_super_block {
177 /* 00*/ unsigned char vs_ignored[3];
178 /* 03*/ unsigned char vs_sysid[8];
179 /* 0b*/ unsigned char vs_sector_size[2];
180 /* 0d*/ __u8 vs_cluster_size;
181 /* 0e*/ __u16 vs_reserved;
182 /* 10*/ __u8 vs_fats;
183 /* 11*/ unsigned char vs_dir_entries[2];
184 /* 13*/ unsigned char vs_sectors[2];
185 /* 15*/ unsigned char vs_media;
186 /* 16*/ __u16 vs_fat_length;
187 /* 18*/ __u16 vs_secs_track;
188 /* 1a*/ __u16 vs_heads;
189 /* 1c*/ __u32 vs_hidden;
190 /* 20*/ __u32 vs_total_sect;
191 /* 24*/ __u32 vs_fat32_length;
192 /* 28*/ __u16 vs_flags;
193 /* 2a*/ __u8 vs_version[2];
194 /* 2c*/ __u32 vs_root_cluster;
195 /* 30*/ __u16 vs_insfo_sector;
196 /* 32*/ __u16 vs_backup_boot;
197 /* 34*/ __u16 vs_reserved2[6];
198 /* 40*/ unsigned char vs_unknown[3];
199 /* 43*/ unsigned char vs_serno[4];
200 /* 47*/ unsigned char vs_label[11];
201 /* 52*/ unsigned char vs_magic[8];
202 /* 5a*/ unsigned char vs_dummy2[164];
203 /*1fe*/ unsigned char vs_pmagic[2];
206 /* Yucky misaligned values */
207 struct msdos_super_block {
208 /* 00*/ unsigned char ms_ignored[3];
209 /* 03*/ unsigned char ms_sysid[8];
210 /* 0b*/ unsigned char ms_sector_size[2];
211 /* 0d*/ __u8 ms_cluster_size;
212 /* 0e*/ __u16 ms_reserved;
213 /* 10*/ __u8 ms_fats;
214 /* 11*/ unsigned char ms_dir_entries[2];
215 /* 13*/ unsigned char ms_sectors[2];
216 /* 15*/ unsigned char ms_media;
217 /* 16*/ __u16 ms_fat_length;
218 /* 18*/ __u16 ms_secs_track;
219 /* 1a*/ __u16 ms_heads;
220 /* 1c*/ __u32 ms_hidden;
221 /* 20*/ __u32 ms_total_sect;
222 /* 24*/ unsigned char ms_unknown[3];
223 /* 27*/ unsigned char ms_serno[4];
224 /* 2b*/ unsigned char ms_label[11];
225 /* 36*/ unsigned char ms_magic[8];
226 /* 3d*/ unsigned char ms_dummy2[192];
227 /*1fe*/ unsigned char ms_pmagic[2];
230 struct vfat_dir_entry {
244 /* maximum number of clusters */
245 #define FAT12_MAX 0xFF4
246 #define FAT16_MAX 0xFFF4
247 #define FAT32_MAX 0x0FFFFFF6
249 struct minix_super_block {
252 __u16 ms_imap_blocks;
253 __u16 ms_zmap_blocks;
254 __u16 ms_firstdatazone;
255 __u16 ms_log_zone_size;
257 unsigned char ms_magic[2];
262 struct mdp_superblock_s {
275 __u32 not_persistent;
281 struct hfs_super_block {
287 struct ocfs_volume_header {
288 unsigned char minor_version[4];
289 unsigned char major_version[4];
290 unsigned char signature[128];
292 unsigned char mount_len[2];
295 struct ocfs_volume_label {
296 unsigned char disk_lock[48];
298 unsigned char label_len[2];
299 unsigned char vol_id[16];
300 unsigned char vol_id_len[2];
303 #define ocfsmajor(o) ((__u32)o.major_version[0] \
304 + (((__u32) o.major_version[1]) << 8) \
305 + (((__u32) o.major_version[2]) << 16) \
306 + (((__u32) o.major_version[3]) << 24))
307 #define ocfslabellen(o) ((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
308 #define ocfsmountlen(o) ((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
310 #define OCFS_MAGIC "OracleCFS"
312 struct ocfs2_super_block {
313 unsigned char signature[8];
314 unsigned char s_dummy1[184];
315 unsigned char s_dummy2[80];
317 unsigned char s_uuid[16];
320 #define OCFS2_MIN_BLOCKSIZE 512
321 #define OCFS2_MAX_BLOCKSIZE 4096
323 #define OCFS2_SUPER_BLOCK_BLKNO 2
325 #define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
327 struct oracle_asm_disk_label {
333 #define ORACLE_ASM_DISK_LABEL_MARKED "ORCLDISK"
334 #define ORACLE_ASM_DISK_LABEL_OFFSET 32
336 struct iso_volume_descriptor {
337 unsigned char vd_type;
338 unsigned char vd_id[5];
339 unsigned char vd_version;
341 unsigned char system_id[32];
342 unsigned char volume_id[32];
343 unsigned char unused[8];
344 unsigned char space_size[8];
345 unsigned char escape_sequences[8];
349 * Byte swap functions
352 #define _INLINE_ static __inline__
353 #else /* For Watcom C */
354 #define _INLINE_ static inline
357 static __u16 blkid_swab16(__u16 val);
358 static __u32 blkid_swab32(__u32 val);
359 static __u64 blkid_swab64(__u64 val);
361 #if ((defined __GNUC__) && \
362 (defined(__i386__) || defined(__i486__) || defined(__i586__)))
364 #define _BLKID_HAVE_ASM_BITOPS_
366 _INLINE_ __u32 blkid_swab32(__u32 val)
368 #ifdef EXT2FS_REQUIRE_486
369 __asm__("bswap %0" : "=r" (val) : "0" (val));
371 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
372 "rorl $16,%0\n\t" /* swap words */
373 "xchgb %b0,%h0" /* swap higher bytes */
380 _INLINE_ __u16 blkid_swab16(__u16 val)
382 __asm__("xchgb %b0,%h0" /* swap bytes */ \
388 _INLINE_ __u64 blkid_swab64(__u64 val)
390 return (blkid_swab32(val >> 32) |
391 (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
395 #if !defined(_BLKID_HAVE_ASM_BITOPS_)
397 _INLINE_ __u16 blkid_swab16(__u16 val)
399 return (val >> 8) | (val << 8);
402 _INLINE_ __u32 blkid_swab32(__u32 val)
404 return ((val>>24) | ((val>>8)&0xFF00) |
405 ((val<<8)&0xFF0000) | (val<<24));
408 _INLINE_ __u64 blkid_swab64(__u64 val)
410 return (blkid_swab32(val >> 32) |
411 (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
417 #if __BYTE_ORDER == __BIG_ENDIAN
418 #define blkid_le16(x) blkid_swab16(x)
419 #define blkid_le32(x) blkid_swab32(x)
420 #define blkid_le64(x) blkid_swab64(x)
421 #define blkid_be16(x) (x)
422 #define blkid_be32(x) (x)
423 #define blkid_be64(x) (x)
425 #define blkid_le16(x) (x)
426 #define blkid_le32(x) (x)
427 #define blkid_le64(x) (x)
428 #define blkid_be16(x) blkid_swab16(x)
429 #define blkid_be32(x) blkid_swab32(x)
430 #define blkid_be64(x) blkid_swab64(x)
435 #endif /* _BLKID_PROBE_H */