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