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