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 <linux/types.h>
21 typedef int (*blkid_probe_t)(int fd, blkid_cache cache, blkid_dev dev,
22 const struct blkid_magic *id, unsigned char *buf);
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 */
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.
39 struct ext2_super_block {
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;
48 unsigned char s_magic[2];
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];
57 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
58 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x00000004
59 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
61 struct xfs_super_block {
62 unsigned char xs_magic[4];
67 unsigned char xs_uuid[16];
76 struct reiserfs_super_block {
77 __u32 rs_blocks_count;
80 __u32 rs_journal_block;
82 __u32 rs_orig_journal_size;
86 unsigned char rs_magic[12];
88 unsigned char rs_uuid[16];
92 struct jfs_super_block {
93 unsigned char js_magic[4];
100 unsigned char js_uuid[16];
101 unsigned char js_label[16];
102 unsigned char js_loguuid[16];
105 struct romfs_super_block {
106 unsigned char ros_magic[8];
108 unsigned char ros_volume[16];
111 struct swap_id_block {
112 /* unsigned char sws_boot[1024]; */
116 unsigned char sws_uuid[16];
117 unsigned char sws_volume[16];
118 unsigned char sws_pad[117];
122 /* Yucky misaligned values */
123 struct vfat_super_block {
124 /* 00*/ unsigned char vs_ignored[3];
125 /* 03*/ unsigned char vs_sysid[8];
126 /* 0b*/ unsigned char vs_sector_size[2];
127 /* 0d*/ __u8 vs_cluster_size;
128 /* 0e*/ __u16 vs_reserved;
129 /* 10*/ __u8 vs_fats;
130 /* 11*/ unsigned char vs_dir_entries[2];
131 /* 13*/ unsigned char vs_sectors[2];
132 /* 15*/ unsigned char vs_media;
133 /* 16*/ __u16 vs_fat_length;
134 /* 18*/ __u16 vs_secs_track;
135 /* 1a*/ __u16 vs_heads;
136 /* 1c*/ __u32 vs_hidden;
137 /* 20*/ __u32 vs_total_sect;
138 /* 24*/ __u32 vs_fat32_length;
139 /* 28*/ __u16 vs_flags;
140 /* 2a*/ __u8 vs_version[2];
141 /* 2c*/ __u32 vs_root_cluster;
142 /* 30*/ __u16 vs_insfo_sector;
143 /* 32*/ __u16 vs_backup_boot;
144 /* 34*/ __u16 vs_reserved2[6];
145 /* 40*/ unsigned char vs_unknown[3];
146 /* 43*/ unsigned char vs_serno[4];
147 /* 47*/ char vs_label[11];
148 /* 52*/ unsigned char vs_magic[8];
149 /* 5a*/ unsigned char vs_dummy2[164];
150 /*1fe*/ unsigned char vs_pmagic[2];
153 /* Yucky misaligned values */
154 struct msdos_super_block {
155 /* 00*/ unsigned char ms_ignored[3];
156 /* 03*/ unsigned char ms_sysid[8];
157 /* 0b*/ unsigned char ms_sector_size[2];
158 /* 0d*/ __u8 ms_cluster_size;
159 /* 0e*/ __u16 ms_reserved;
160 /* 10*/ __u8 ms_fats;
161 /* 11*/ unsigned char ms_dir_entries[2];
162 /* 13*/ unsigned char ms_sectors[2];
163 /* 15*/ unsigned char ms_media;
164 /* 16*/ __u16 ms_fat_length;
165 /* 18*/ __u16 ms_secs_track;
166 /* 1a*/ __u16 ms_heads;
167 /* 1c*/ __u32 ms_hidden;
168 /* 20*/ __u32 ms_total_sect;
169 /* 24*/ unsigned char ms_unknown[3];
170 /* 27*/ unsigned char ms_serno[4];
171 /* 2b*/ char ms_label[11];
172 /* 36*/ unsigned char ms_magic[8];
173 /* 3d*/ unsigned char ms_dummy2[192];
174 /*1fe*/ unsigned char ms_pmagic[2];
177 struct minix_super_block {
180 __u16 ms_imap_blocks;
181 __u16 ms_zmap_blocks;
182 __u16 ms_firstdatazone;
183 __u16 ms_log_zone_size;
185 unsigned char ms_magic[2];
190 struct mdp_superblock_s {
203 __u32 not_persistent;
209 struct hfs_super_block {
215 struct ocfs_volume_header {
216 unsigned char minor_version[4];
217 unsigned char major_version[4];
218 unsigned char signature[128];
219 unsigned char mount[128];
220 unsigned char mount_len[2];
223 struct ocfs_volume_label {
224 unsigned char disk_lock[48];
225 unsigned char label[64];
226 unsigned char label_len[2];
227 unsigned char vol_id[16];
228 unsigned char vol_id_len[2];
231 #define ocfsmajor(o) ((__u32)o.major_version[0] \
232 + (((__u32) o.major_version[1]) << 8) \
233 + (((__u32) o.major_version[2]) << 16) \
234 + (((__u32) o.major_version[3]) << 24))
235 #define ocfslabellen(o) ((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
236 #define ocfsmountlen(o) ((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
238 #define OCFS_MAGIC "OracleCFS"
240 struct ocfs2_super_block {
241 unsigned char signature[8];
242 unsigned char s_dummy1[184];
243 unsigned char s_dummy2[80];
244 unsigned char s_label[64];
245 unsigned char s_uuid[16];
248 #define OCFS2_MIN_BLOCKSIZE 512
249 #define OCFS2_MAX_BLOCKSIZE 4096
251 #define OCFS2_SUPER_BLOCK_BLKNO 2
253 #define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
255 struct oracle_asm_disk_label {
261 #define ORACLE_ASM_DISK_LABEL_MARKED "ORCLDISK"
262 #define ORACLE_ASM_DISK_LABEL_OFFSET 32
264 #define ISODCL(from, to) (to - from + 1)
265 struct iso_volume_descriptor {
266 char type[ISODCL(1,1)]; /* 711 */
267 char id[ISODCL(2,6)];
268 char version[ISODCL(7,7)];
269 char data[ISODCL(8,2048)];
273 * Byte swap functions
276 #define _INLINE_ static __inline__
277 #else /* For Watcom C */
278 #define _INLINE_ static inline
281 static __u16 blkid_swab16(__u16 val);
282 static __u32 blkid_swab32(__u32 val);
283 static __u64 blkid_swab64(__u64 val);
285 #if ((defined __GNUC__) && \
286 (defined(__i386__) || defined(__i486__) || defined(__i586__)))
288 #define _BLKID_HAVE_ASM_BITOPS_
290 _INLINE_ __u32 blkid_swab32(__u32 val)
292 #ifdef EXT2FS_REQUIRE_486
293 __asm__("bswap %0" : "=r" (val) : "0" (val));
295 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
296 "rorl $16,%0\n\t" /* swap words */
297 "xchgb %b0,%h0" /* swap higher bytes */
304 _INLINE_ __u16 blkid_swab16(__u16 val)
306 __asm__("xchgb %b0,%h0" /* swap bytes */ \
312 _INLINE_ __u64 blkid_swab64(__u64 val)
314 return (blkid_swab32(val >> 32) |
315 (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
319 #if !defined(_BLKID_HAVE_ASM_BITOPS_)
321 _INLINE_ __u16 blkid_swab16(__u16 val)
323 return (val >> 8) | (val << 8);
326 _INLINE_ __u32 blkid_swab32(__u32 val)
328 return ((val>>24) | ((val>>8)&0xFF00) |
329 ((val<<8)&0xFF0000) | (val<<24));
332 _INLINE_ __u64 blkid_swab64(__u64 val)
334 return (blkid_swab32(val >> 32) |
335 (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
341 #if __BYTE_ORDER == __BIG_ENDIAN
342 #define blkid_le16(x) blkid_swab16(x)
343 #define blkid_le32(x) blkid_swab32(x)
344 #define blkid_le64(x) blkid_swab64(x)
345 #define blkid_be16(x) (x)
346 #define blkid_be32(x) (x)
347 #define blkid_be64(x) (x)
349 #define blkid_le16(x) (x)
350 #define blkid_le32(x) (x)
351 #define blkid_le64(x) (x)
352 #define blkid_be16(x) blkid_swab16(x)
353 #define blkid_be32(x) blkid_swab32(x)
354 #define blkid_be64(x) blkid_swab64(x)
359 #endif /* _BLKID_PROBE_H */