• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * probe.h - constants and on-disk structures for extracting device data
3  *
4  * Copyright (C) 1999 by Andries Brouwer
5  * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
6  * Copyright (C) 2001 by Andreas Dilger
7  *
8  * %Begin-Header%
9  * This file may be redistributed under the terms of the
10  * GNU Lesser General Public License.
11  * %End-Header%
12  */
13 
14 #ifndef _BLKID_PROBE_H
15 #define _BLKID_PROBE_H
16 
17 #include <stdint.h>
18 
19 #include <blkid/blkid_types.h>
20 
21 struct blkid_magic;
22 
23 #define SB_BUFFER_SIZE		0x11000
24 
25 struct blkid_probe {
26 	int			fd;
27 	blkid_cache		cache;
28 	blkid_dev		dev;
29 	unsigned char		*sbbuf;
30 	size_t			sb_valid;
31 	unsigned char		*buf;
32 	size_t			buf_max;
33 };
34 
35 typedef int (*blkid_probe_t)(struct blkid_probe *probe,
36 			     struct blkid_magic *id, unsigned char *buf);
37 
38 struct blkid_magic {
39 	const char	*bim_type;	/* type name for this magic */
40 	long		bim_kboff;	/* kilobyte offset of superblock */
41 	unsigned	bim_sboff;	/* byte offset within superblock */
42 	unsigned	bim_len;	/* length of magic */
43 	const char	*bim_magic;	/* magic string */
44 	blkid_probe_t	bim_probe;	/* probe function */
45 };
46 
47 /*
48  * Structures for each of the content types we want to extract information
49  * from.  We do not necessarily need the magic field here, because we have
50  * already identified the content type before we get this far.  It may still
51  * be useful if there are probe functions which handle multiple content types.
52  */
53 struct ext2_super_block {
54 	__u32		s_inodes_count;
55 	__u32		s_blocks_count;
56 	__u32		s_r_blocks_count;
57 	__u32		s_free_blocks_count;
58 	__u32		s_free_inodes_count;
59 	__u32		s_first_data_block;
60 	__u32		s_log_block_size;
61 	__u32		s_dummy3[7];
62 	unsigned char	s_magic[2];
63 	__u16		s_state;
64 	__u32		s_dummy5[8];
65 	__u32		s_feature_compat;
66 	__u32		s_feature_incompat;
67 	__u32		s_feature_ro_compat;
68 	unsigned char   s_uuid[16];
69 	char	   s_volume_name[16];
70 	char	s_last_mounted[64];
71 	__u32	s_algorithm_usage_bitmap;
72 	__u8	s_prealloc_blocks;
73 	__u8	s_prealloc_dir_blocks;
74 	__u16	s_reserved_gdt_blocks;
75 	__u8	s_journal_uuid[16];
76 	__u32	s_journal_inum;
77 	__u32	s_journal_dev;
78 	__u32	s_last_orphan;
79 	__u32	s_hash_seed[4];
80 	__u8	s_def_hash_version;
81 	__u8	s_jnl_backup_type;
82 	__u16	s_reserved_word_pad;
83 	__u32	s_default_mount_opts;
84 	__u32	s_first_meta_bg;
85 	__u32	s_mkfs_time;
86 	__u32	s_jnl_blocks[17];
87 	__u32	s_blocks_count_hi;
88 	__u32	s_r_blocks_count_hi;
89 	__u32	s_free_blocks_hi;
90 	__u16	s_min_extra_isize;
91 	__u16	s_want_extra_isize;
92 	__u32	s_flags;
93 	__u16   s_raid_stride;
94 	__u16   s_mmp_interval;
95 	__u64   s_mmp_block;
96 	__u32   s_raid_stripe_width;
97 	__u32   s_reserved[163];
98 };
99 
100 /* for s_flags */
101 #define EXT2_FLAGS_TEST_FILESYS		0x0004
102 
103 /* for s_feature_compat */
104 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL		0x0004
105 
106 /* for s_feature_ro_compat */
107 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
108 #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
109 #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
110 #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE	0x0008
111 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM		0x0010
112 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK	0x0020
113 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE	0x0040
114 #define EXT4_FEATURE_RO_COMPAT_QUOTA		0x0100
115 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
116 
117 /* for s_feature_incompat */
118 #define EXT2_FEATURE_INCOMPAT_FILETYPE		0x0002
119 #define EXT3_FEATURE_INCOMPAT_RECOVER		0x0004
120 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008
121 #define EXT2_FEATURE_INCOMPAT_META_BG		0x0010
122 #define EXT4_FEATURE_INCOMPAT_EXTENTS		0x0040 /* extents support */
123 #define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
124 #define EXT4_FEATURE_INCOMPAT_MMP		0x0100
125 #define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
126 
127 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
128 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
129 					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
130 #define EXT2_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE| \
131 					 EXT2_FEATURE_INCOMPAT_META_BG)
132 #define EXT2_FEATURE_INCOMPAT_UNSUPPORTED	~EXT2_FEATURE_INCOMPAT_SUPP
133 #define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED	~EXT2_FEATURE_RO_COMPAT_SUPP
134 
135 #define EXT3_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
136 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
137 					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
138 #define EXT3_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE| \
139 					 EXT3_FEATURE_INCOMPAT_RECOVER| \
140 					 EXT2_FEATURE_INCOMPAT_META_BG)
141 #define EXT3_FEATURE_INCOMPAT_UNSUPPORTED	~EXT3_FEATURE_INCOMPAT_SUPP
142 #define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED	~EXT3_FEATURE_RO_COMPAT_SUPP
143 
144 
145 struct xfs_super_block {
146 	unsigned char	xs_magic[4];
147 	__u32		xs_blocksize;
148 	__u64		xs_dblocks;
149 	__u64		xs_rblocks;
150 	__u32		xs_dummy1[2];
151 	unsigned char	xs_uuid[16];
152 	__u32		xs_dummy2[15];
153 	char		xs_fname[12];
154 	__u32		xs_dummy3[2];
155 	__u64		xs_icount;
156 	__u64		xs_ifree;
157 	__u64		xs_fdblocks;
158 };
159 
160 struct reiserfs_super_block {
161 	__u32		rs_blocks_count;
162 	__u32		rs_free_blocks;
163 	__u32		rs_root_block;
164 	__u32		rs_journal_block;
165 	__u32		rs_journal_dev;
166 	__u32		rs_orig_journal_size;
167 	__u32		rs_dummy2[5];
168 	__u16		rs_blocksize;
169 	__u16		rs_dummy3[3];
170 	unsigned char	rs_magic[12];
171 	__u32		rs_dummy4[5];
172 	unsigned char	rs_uuid[16];
173 	char		rs_label[16];
174 };
175 
176 struct reiser4_super_block {
177 	unsigned char	rs4_magic[16];
178 	__u16		rs4_dummy[2];
179 	unsigned char	rs4_uuid[16];
180 	unsigned char	rs4_label[16];
181 	__u64		rs4_dummy2;
182 };
183 
184 struct jfs_super_block {
185 	unsigned char	js_magic[4];
186 	__u32		js_version;
187 	__u64		js_size;
188 	__u32		js_bsize;	/* 4: aggregate block size in bytes */
189 	__u16		js_l2bsize;	/* 2: log2 of s_bsize */
190 	__u16		js_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
191 	__u32		js_pbsize;	/* 4: hardware/LVM block size in bytes */
192 	__u16		js_l2pbsize;	/* 2: log2 of s_pbsize */
193 	__u16 		js_pad;		/* 2: padding necessary for alignment */
194 	__u32		js_dummy2[26];
195 	unsigned char	js_uuid[16];
196 	unsigned char	js_label[16];
197 	unsigned char	js_loguuid[16];
198 };
199 
200 struct romfs_super_block {
201 	unsigned char	ros_magic[8];
202 	__u32		ros_dummy1[2];
203 	unsigned char	ros_volume[16];
204 };
205 
206 struct cramfs_super_block {
207 	__u8		magic[4];
208 	__u32		size;
209 	__u32		flags;
210 	__u32		future;
211 	__u8		signature[16];
212 	struct cramfs_info {
213 		__u32		crc;
214 		__u32		edition;
215 		__u32		blocks;
216 		__u32		files;
217 	} info;
218 	__u8		name[16];
219 };
220 
221 struct swap_id_block {
222 /*	unsigned char	sws_boot[1024]; */
223 	__u32		sws_version;
224 	__u32		sws_lastpage;
225 	__u32		sws_nrbad;
226 	unsigned char	sws_uuid[16];
227 	char		sws_volume[16];
228 	unsigned char	sws_pad[117];
229 	__u32		sws_badpg;
230 };
231 
232 /* Yucky misaligned values */
233 struct vfat_super_block {
234 /* 00*/	unsigned char	vs_ignored[3];
235 /* 03*/	unsigned char	vs_sysid[8];
236 /* 0b*/	unsigned char	vs_sector_size[2];
237 /* 0d*/	__u8		vs_cluster_size;
238 /* 0e*/	__u16		vs_reserved;
239 /* 10*/	__u8		vs_fats;
240 /* 11*/	unsigned char	vs_dir_entries[2];
241 /* 13*/	unsigned char	vs_sectors[2];
242 /* 15*/	unsigned char	vs_media;
243 /* 16*/	__u16		vs_fat_length;
244 /* 18*/	__u16		vs_secs_track;
245 /* 1a*/	__u16		vs_heads;
246 /* 1c*/	__u32		vs_hidden;
247 /* 20*/	__u32		vs_total_sect;
248 /* 24*/	__u32		vs_fat32_length;
249 /* 28*/	__u16		vs_flags;
250 /* 2a*/	__u8		vs_version[2];
251 /* 2c*/	__u32		vs_root_cluster;
252 /* 30*/	__u16		vs_insfo_sector;
253 /* 32*/	__u16		vs_backup_boot;
254 /* 34*/	__u16		vs_reserved2[6];
255 /* 40*/	unsigned char	vs_unknown[3];
256 /* 43*/	unsigned char	vs_serno[4];
257 /* 47*/	unsigned char	vs_label[11];
258 /* 52*/	unsigned char   vs_magic[8];
259 /* 5a*/	unsigned char	vs_dummy2[164];
260 /*1fe*/	unsigned char	vs_pmagic[2];
261 };
262 
263 /* Yucky misaligned values */
264 struct msdos_super_block {
265 /* 00*/	unsigned char	ms_ignored[3];
266 /* 03*/	unsigned char	ms_sysid[8];
267 /* 0b*/	unsigned char	ms_sector_size[2];
268 /* 0d*/	__u8		ms_cluster_size;
269 /* 0e*/	__u16		ms_reserved;
270 /* 10*/	__u8		ms_fats;
271 /* 11*/	unsigned char	ms_dir_entries[2];
272 /* 13*/	unsigned char	ms_sectors[2];
273 /* 15*/	unsigned char	ms_media;
274 /* 16*/	__u16		ms_fat_length;
275 /* 18*/	__u16		ms_secs_track;
276 /* 1a*/	__u16		ms_heads;
277 /* 1c*/	__u32		ms_hidden;
278 /* 20*/	__u32		ms_total_sect;
279 /* 24*/	unsigned char	ms_unknown[3];
280 /* 27*/	unsigned char	ms_serno[4];
281 /* 2b*/	unsigned char	ms_label[11];
282 /* 36*/	unsigned char   ms_magic[8];
283 /* 3d*/	unsigned char	ms_dummy2[192];
284 /*1fe*/	unsigned char	ms_pmagic[2];
285 };
286 
287 struct vfat_dir_entry {
288 	__u8	name[11];
289 	__u8	attr;
290 	__u16	time_creat;
291 	__u16	date_creat;
292 	__u16	time_acc;
293 	__u16	date_acc;
294 	__u16	cluster_high;
295 	__u16	time_write;
296 	__u16	date_write;
297 	__u16	cluster_low;
298 	__u32	size;
299 };
300 
301 /* maximum number of clusters */
302 #define FAT12_MAX 0xFF4
303 #define FAT16_MAX 0xFFF4
304 #define FAT32_MAX 0x0FFFFFF6
305 
306 struct minix_super_block {
307 	__u16		ms_ninodes;
308 	__u16		ms_nzones;
309 	__u16		ms_imap_blocks;
310 	__u16		ms_zmap_blocks;
311 	__u16		ms_firstdatazone;
312 	__u16		ms_log_zone_size;
313 	__u32		ms_max_size;
314 	unsigned char	ms_magic[2];
315 	__u16		ms_state;
316 	__u32		ms_zones;
317 };
318 
319 struct mdp_superblock_s {
320 	__u32 md_magic;
321 	__u32 major_version;
322 	__u32 minor_version;
323 	__u32 patch_version;
324 	__u32 gvalid_words;
325 	__u32 set_uuid0;
326 	__u32 ctime;
327 	__u32 level;
328 	__u32 size;
329 	__u32 nr_disks;
330 	__u32 raid_disks;
331 	__u32 md_minor;
332 	__u32 not_persistent;
333 	__u32 set_uuid1;
334 	__u32 set_uuid2;
335 	__u32 set_uuid3;
336 };
337 
338 struct hfs_super_block {
339 	char	h_magic[2];
340 	char	h_dummy[18];
341 	__u32	h_blksize;
342 };
343 
344 struct ocfs_volume_header {
345 	unsigned char	minor_version[4];
346 	unsigned char	major_version[4];
347 	unsigned char	signature[128];
348 	char		mount[128];
349 	unsigned char   mount_len[2];
350 };
351 
352 struct ocfs_volume_label {
353 	unsigned char	disk_lock[48];
354 	char		label[64];
355 	unsigned char	label_len[2];
356 	unsigned char  vol_id[16];
357 	unsigned char  vol_id_len[2];
358 };
359 
360 #define ocfsmajor(o) ((__u32)o.major_version[0] \
361                    + (((__u32) o.major_version[1]) << 8) \
362                    + (((__u32) o.major_version[2]) << 16) \
363                    + (((__u32) o.major_version[3]) << 24))
364 #define ocfslabellen(o)	((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
365 #define ocfsmountlen(o)	((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
366 
367 #define OCFS_MAGIC "OracleCFS"
368 
369 struct ocfs2_super_block {
370 	unsigned char  signature[8];
371 	unsigned char  s_dummy1[184];
372 	unsigned char  s_dummy2[80];
373 	char	       s_label[64];
374 	unsigned char  s_uuid[16];
375 };
376 
377 #define OCFS2_MIN_BLOCKSIZE             512
378 #define OCFS2_MAX_BLOCKSIZE             4096
379 
380 #define OCFS2_SUPER_BLOCK_BLKNO         2
381 
382 #define OCFS2_SUPER_BLOCK_SIGNATURE     "OCFSV2"
383 
384 struct oracle_asm_disk_label {
385 	char dummy[32];
386 	char dl_tag[8];
387 	char dl_id[24];
388 };
389 
390 #define ORACLE_ASM_DISK_LABEL_MARKED    "ORCLDISK"
391 #define ORACLE_ASM_DISK_LABEL_OFFSET    32
392 
393 struct iso_volume_descriptor {
394 	unsigned char	vd_type;
395 	unsigned char	vd_id[5];
396 	unsigned char	vd_version;
397 	unsigned char	flags;
398 	unsigned char	system_id[32];
399 	unsigned char	volume_id[32];
400 	unsigned char	unused[8];
401 	unsigned char	space_size[8];
402 	unsigned char	escape_sequences[8];
403 };
404 
405 /* Common gfs/gfs2 constants: */
406 #define GFS_MAGIC               0x01161970
407 #define GFS_DEFAULT_BSIZE       4096
408 #define GFS_SUPERBLOCK_OFFSET	(0x10 * GFS_DEFAULT_BSIZE)
409 #define GFS_METATYPE_SB         1
410 #define GFS_FORMAT_SB           100
411 #define GFS_LOCKNAME_LEN        64
412 
413 /* gfs1 constants: */
414 #define GFS_FORMAT_FS           1309
415 #define GFS_FORMAT_MULTI        1401
416 /* gfs2 constants: */
417 #define GFS2_FORMAT_FS          1801
418 #define GFS2_FORMAT_MULTI       1900
419 
420 struct gfs2_meta_header {
421 	__u32 mh_magic;
422 	__u32 mh_type;
423 	__u64 __pad0;          /* Was generation number in gfs1 */
424 	__u32 mh_format;
425 	__u32 __pad1;          /* Was incarnation number in gfs1 */
426 };
427 
428 struct gfs2_inum {
429 	__u64 no_formal_ino;
430 	__u64 no_addr;
431 };
432 
433 struct gfs2_sb {
434 	struct gfs2_meta_header sb_header;
435 
436 	__u32 sb_fs_format;
437 	__u32 sb_multihost_format;
438 	__u32  __pad0;  /* Was superblock flags in gfs1 */
439 
440 	__u32 sb_bsize;
441 	__u32 sb_bsize_shift;
442 	__u32 __pad1;   /* Was journal segment size in gfs1 */
443 
444 	struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
445 	struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
446 	struct gfs2_inum sb_root_dir;
447 
448 	char sb_lockproto[GFS_LOCKNAME_LEN];
449 	char sb_locktable[GFS_LOCKNAME_LEN];
450 	/* In gfs1, quota and license dinodes followed */
451 };
452 
453 struct ntfs_super_block {
454 	__u8	jump[3];
455 	__u8	oem_id[8];
456 	__u8	bios_parameter_block[25];
457 	__u16	unused[2];
458 	__u64	number_of_sectors;
459 	__u64	mft_cluster_location;
460 	__u64	mft_mirror_cluster_location;
461 	__s8	cluster_per_mft_record;
462 	__u8	reserved1[3];
463 	__s8	cluster_per_index_record;
464 	__u8	reserved2[3];
465 	__u64	volume_serial;
466 	__u16	checksum;
467 };
468 
469 struct master_file_table_record {
470 	__u32	magic;
471 	__u16	usa_ofs;
472 	__u16	usa_count;
473 	__u64	lsn;
474 	__u16	sequence_number;
475 	__u16	link_count;
476 	__u16	attrs_offset;
477 	__u16	flags;
478 	__u32	bytes_in_use;
479 	__u32	bytes_allocated;
480 } __attribute__((__packed__));
481 
482 struct file_attribute {
483 	__u32	type;
484 	__u32	len;
485 	__u8	non_resident;
486 	__u8	name_len;
487 	__u16	name_offset;
488 	__u16	flags;
489 	__u16	instance;
490 	__u32	value_len;
491 	__u16	value_offset;
492 } __attribute__((__packed__));
493 
494 #define MFT_RECORD_VOLUME			3
495 #define MFT_RECORD_ATTR_VOLUME_NAME		0x60
496 #define MFT_RECORD_ATTR_VOLUME_INFO		0x70
497 #define MFT_RECORD_ATTR_OBJECT_ID		0x40
498 #define MFT_RECORD_ATTR_END			0xffffffffu
499 
500 /* HFS / HFS+ */
501 struct hfs_finder_info {
502         __u32        boot_folder;
503         __u32        start_app;
504         __u32        open_folder;
505         __u32        os9_folder;
506         __u32        reserved;
507         __u32        osx_folder;
508         __u8         id[8];
509 } __attribute__((packed));
510 
511 struct hfs_mdb {
512         __u8         signature[2];
513         __u32        cr_date;
514         __u32        ls_Mod;
515         __u16        atrb;
516         __u16        nm_fls;
517         __u16        vbm_st;
518         __u16        alloc_ptr;
519         __u16        nm_al_blks;
520         __u32        al_blk_size;
521         __u32        clp_size;
522         __u16        al_bl_st;
523         __u32        nxt_cnid;
524         __u16        free_bks;
525         __u8         label_len;
526         __u8         label[27];
527         __u32        vol_bkup;
528         __u16        vol_seq_num;
529         __u32        wr_cnt;
530         __u32        xt_clump_size;
531         __u32        ct_clump_size;
532         __u16        num_root_dirs;
533         __u32        file_count;
534         __u32        dir_count;
535         struct hfs_finder_info finder_info;
536         __u8         embed_sig[2];
537         __u16        embed_startblock;
538         __u16        embed_blockcount;
539 } __attribute__((packed));
540 
541 
542 #define HFS_NODE_LEAF			0xff
543 #define HFSPLUS_POR_CNID		1
544 
545 struct hfsplus_bnode_descriptor {
546 	__u32		next;
547 	__u32		prev;
548 	__u8		type;
549 	__u8		height;
550 	__u16		num_recs;
551 	__u16		reserved;
552 } __attribute__((packed));
553 
554 struct hfsplus_bheader_record {
555 	__u16		depth;
556 	__u32		root;
557 	__u32		leaf_count;
558 	__u32		leaf_head;
559 	__u32		leaf_tail;
560 	__u16		node_size;
561 } __attribute__((packed));
562 
563 struct hfsplus_catalog_key {
564 	__u16	key_len;
565 	__u32	parent_id;
566 	__u16	unicode_len;
567 	__u8		unicode[255 * 2];
568 } __attribute__((packed));
569 
570 struct hfsplus_extent {
571 	__u32		start_block;
572 	__u32		block_count;
573 } __attribute__((packed));
574 
575 #define HFSPLUS_EXTENT_COUNT		8
576 struct hfsplus_fork {
577 	__u64		total_size;
578 	__u32		clump_size;
579 	__u32		total_blocks;
580 	struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
581 } __attribute__((packed));
582 
583 struct hfsplus_vol_header {
584 	__u8		signature[2];
585 	__u16		version;
586 	__u32		attributes;
587 	__u32		last_mount_vers;
588 	__u32		reserved;
589 	__u32		create_date;
590 	__u32		modify_date;
591 	__u32		backup_date;
592 	__u32		checked_date;
593 	__u32		file_count;
594 	__u32		folder_count;
595 	__u32		blocksize;
596 	__u32		total_blocks;
597 	__u32		free_blocks;
598 	__u32		next_alloc;
599 	__u32		rsrc_clump_sz;
600 	__u32		data_clump_sz;
601 	__u32		next_cnid;
602 	__u32		write_count;
603 	__u64		encodings_bmp;
604 	struct hfs_finder_info finder_info;
605 	struct hfsplus_fork alloc_file;
606 	struct hfsplus_fork ext_file;
607 	struct hfsplus_fork cat_file;
608 	struct hfsplus_fork attr_file;
609 	struct hfsplus_fork start_file;
610 }  __attribute__((packed));
611 
612 
613 /* this is lvm's label_header & pv_header combined. */
614 
615 #define LVM2_ID_LEN 32
616 
617 struct lvm2_pv_label_header {
618 	/* label_header */
619 	__u8	id[8];		/* LABELONE */
620 	__u64	sector_xl;	/* Sector number of this label */
621 	__u32	crc_xl;		/* From next field to end of sector */
622 	__u32	offset_xl;	/* Offset from start of struct to contents */
623 	__u8	type[8];	/* LVM2 001 */
624 	/* pv_header */
625 	__u8	pv_uuid[LVM2_ID_LEN];
626 } __attribute__ ((packed));
627 
628 
629 /*
630  * this is a very generous portion of the super block, giving us
631  * room to translate 14 chunks with 3 stripes each.
632  */
633 #define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
634 #define BTRFS_LABEL_SIZE 256
635 #define BTRFS_UUID_SIZE 16
636 #define BTRFS_FSID_SIZE 16
637 #define BTRFS_CSUM_SIZE 32
638 
639 struct btrfs_dev_item {
640 	/* the internal btrfs device id */
641 	__u64 devid;
642 
643 	/* size of the device */
644 	__u64 total_bytes;
645 
646 	/* bytes used */
647 	__u64 bytes_used;
648 
649 	/* optimal io alignment for this device */
650 	__u32 io_align;
651 
652 	/* optimal io width for this device */
653 	__u32 io_width;
654 
655 	/* minimal io size for this device */
656 	__u32 sector_size;
657 
658 	/* type and info about this device */
659 	__u64 type;
660 
661 	/* expected generation for this device */
662 	__u64 generation;
663 
664 	/*
665 	 * starting byte of this partition on the device,
666 	 * to allow for stripe alignment in the future
667 	 */
668 	__u64 start_offset;
669 
670 	/* grouping information for allocation decisions */
671 	__u32 dev_group;
672 
673 	/* seek speed 0-100 where 100 is fastest */
674 	__u8 seek_speed;
675 
676 	/* bandwidth 0-100 where 100 is fastest */
677 	__u8 bandwidth;
678 
679 	/* btrfs generated uuid for this device */
680 	__u8 uuid[BTRFS_UUID_SIZE];
681 
682 	/* uuid of FS who owns this device */
683 	__u8 fsid[BTRFS_UUID_SIZE];
684 } __attribute__ ((__packed__));
685 
686 /*
687  * the super block basically lists the main trees of the FS
688  * it currently lacks any block count etc etc
689  */
690 struct btrfs_super_block {
691 	__u8 csum[BTRFS_CSUM_SIZE];
692 	/* the first 3 fields must match struct btrfs_header */
693 	__u8 fsid[BTRFS_FSID_SIZE];    /* FS specific uuid */
694 	__u64 bytenr; /* this block number */
695 	__u64 flags;
696 
697 	/* allowed to be different from the btrfs_header from here own down */
698 	__u64 magic;
699 	__u64 generation;
700 	__u64 root;
701 	__u64 chunk_root;
702 	__u64 log_root;
703 
704 	/* this will help find the new super based on the log root */
705 	__u64 log_root_transid;
706 	__u64 total_bytes;
707 	__u64 bytes_used;
708 	__u64 root_dir_objectid;
709 	__u64 num_devices;
710 	__u32 sectorsize;
711 	__u32 nodesize;
712 	__u32 leafsize;
713 	__u32 stripesize;
714 	__u32 sys_chunk_array_size;
715 	__u64 chunk_root_generation;
716 	__u64 compat_flags;
717 	__u64 compat_ro_flags;
718 	__u64 incompat_flags;
719 	__u16 csum_type;
720 	__u8 root_level;
721 	__u8 chunk_root_level;
722 	__u8 log_root_level;
723 	struct btrfs_dev_item dev_item;
724 
725 	char label[BTRFS_LABEL_SIZE];
726 
727 	/* future expansion */
728 	__u64 reserved[32];
729 	__u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
730 } __attribute__ ((__packed__));
731 
732 #define F2FS_MAX_EXTENSION      64  /* # of extension entries */
733 
734 struct f2fs_super_block {
735     __u32 magic;           /* Magic Number */
736     __u16 major_ver;       /* Major Version */
737     __u16 minor_ver;       /* Minor Version */
738     __u32 log_sectorsize;      /* log2 sector size in bytes */
739     __u32 log_sectors_per_block;   /* log2 # of sectors per block */
740     __u32 log_blocksize;       /* log2 block size in bytes */
741     __u32 log_blocks_per_seg;  /* log2 # of blocks per segment */
742     __u32 segs_per_sec;        /* # of segments per section */
743     __u32 secs_per_zone;       /* # of sections per zone */
744     __u32 checksum_offset;     /* checksum offset inside super block */
745     __u64 block_count;     /* total # of user blocks */
746     __u32 section_count;       /* total # of sections */
747     __u32 segment_count;       /* total # of segments */
748     __u32 segment_count_ckpt;  /* # of segments for checkpoint */
749     __u32 segment_count_sit;   /* # of segments for SIT */
750     __u32 segment_count_nat;   /* # of segments for NAT */
751     __u32 segment_count_ssa;   /* # of segments for SSA */
752     __u32 segment_count_main;  /* # of segments for main area */
753     __u32 segment0_blkaddr;    /* start block address of segment 0 */
754     __u32 cp_blkaddr;      /* start block address of checkpoint */
755     __u32 sit_blkaddr;     /* start block address of SIT */
756     __u32 nat_blkaddr;     /* start block address of NAT */
757     __u32 ssa_blkaddr;     /* start block address of SSA */
758     __u32 main_blkaddr;        /* start block address of main area */
759     __u32 root_ino;        /* root inode number */
760     __u32 node_ino;        /* node inode number */
761     __u32 meta_ino;        /* meta inode number */
762     __u8 uuid[16];          /* 128-bit uuid for volume */
763     __u16 volume_name[512];    /* volume name */
764     __u32 extension_count;     /* # of extensions below */
765     __u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
766 } __attribute__((__packed__));
767 
768 struct exfat_super_block {
769     uint8_t jump[3];
770     uint8_t oem_name[8];
771     uint8_t __unused1[53];
772     uint64_t block_start;
773     uint64_t block_count;
774     uint32_t fat_block_start;
775     uint32_t fat_block_count;
776     uint32_t cluster_block_start;
777     uint32_t cluster_count;
778     uint32_t rootdir_cluster;
779     uint8_t volume_serial[4];
780     struct {
781         uint8_t vermin;
782         uint8_t vermaj;
783     } version;
784     uint16_t volume_state;
785     uint8_t block_bits;
786     uint8_t bpc_bits;
787     uint8_t fat_count;
788     uint8_t drive_no;
789     uint8_t allocated_percent;
790 } __attribute__((__packed__));
791 
792 struct exfat_entry_label {
793     uint8_t type;
794     uint8_t length;
795     uint8_t name[30];
796 } __attribute__((__packed__));
797 
798 #define BLOCK_SIZE(sb)   (1 << (sb)->block_bits)
799 #define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
800 
801 #define EXFAT_FIRST_DATA_CLUSTER 2
802 #define EXFAT_LAST_DATA_CLUSTER  0xffffff6
803 #define EXFAT_ENTRY_SIZE         32
804 
805 #define EXFAT_ENTRY_EOD   0x00
806 #define EXFAT_ENTRY_LABEL 0x83
807 
808 /*
809  * Byte swap functions
810  */
811 #ifdef __GNUC__
812 #define _INLINE_ static __inline__
813 #else				/* For Watcom C */
814 #define _INLINE_ static inline
815 #endif
816 
blkid_swab16(__u16 val)817 _INLINE_  __u16 blkid_swab16(__u16 val)
818 {
819 	return (val >> 8) | (val << 8);
820 }
821 
blkid_swab32(__u32 val)822 _INLINE_ __u32 blkid_swab32(__u32 val)
823 {
824 	return ((val>>24) | ((val>>8)&0xFF00) |
825 		((val<<8)&0xFF0000) | (val<<24));
826 }
827 
blkid_swab64(__u64 val)828 _INLINE_ __u64 blkid_swab64(__u64 val)
829 {
830 	return (blkid_swab32(val >> 32) |
831 		(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
832 }
833 
834 #ifdef WORDS_BIGENDIAN
835 #define blkid_le16(x) blkid_swab16(x)
836 #define blkid_le32(x) blkid_swab32(x)
837 #define blkid_le64(x) blkid_swab64(x)
838 #define blkid_be16(x) (x)
839 #define blkid_be32(x) (x)
840 #define blkid_be64(x) (x)
841 #else
842 #define blkid_le16(x) (x)
843 #define blkid_le32(x) (x)
844 #define blkid_le64(x) (x)
845 #define blkid_be16(x) blkid_swab16(x)
846 #define blkid_be32(x) blkid_swab32(x)
847 #define blkid_be64(x) blkid_swab64(x)
848 #endif
849 
850 #undef _INLINE_
851 
852 #endif /* _BLKID_PROBE_H */
853