blob: 9bf47a57688de92819a73c4b3713369b4e4eeef7 [file] [log] [blame]
bigbiff7b4c7a62015-01-01 19:44:14 -05001#ifndef UTIL_LINUX_PT_BSD_H
2#define UTIL_LINUX_PT_BSD_H
3
4#define BSD_MAXPARTITIONS 16
5#define BSD_FS_UNUSED 0
6
7#ifndef BSD_DISKMAGIC
8# define BSD_DISKMAGIC ((uint32_t) 0x82564557)
9#endif
10
11#define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
12
13#if defined (__alpha__) || defined (__powerpc__) || \
14 defined (__ia64__) || defined (__hppa__)
15# define BSD_LABELSECTOR 0
16# define BSD_LABELOFFSET 64
17#else
18# define BSD_LABELSECTOR 1
19# define BSD_LABELOFFSET 0
20#endif
21
22#define BSD_BBSIZE 8192 /* size of boot area, with label */
23#define BSD_SBSIZE 8192 /* max size of fs superblock */
24
25struct bsd_disklabel {
26 uint32_t d_magic; /* the magic number */
27 int16_t d_type; /* drive type */
28 int16_t d_subtype; /* controller/d_type specific */
29 char d_typename[16]; /* type name, e.g. "eagle" */
30 char d_packname[16]; /* pack identifier */
31
32 /* disk geometry: */
33 uint32_t d_secsize; /* # of bytes per sector */
34 uint32_t d_nsectors; /* # of data sectors per track */
35 uint32_t d_ntracks; /* # of tracks per cylinder */
36 uint32_t d_ncylinders; /* # of data cylinders per unit */
37 uint32_t d_secpercyl; /* # of data sectors per cylinder */
38 uint32_t d_secperunit; /* # of data sectors per unit */
39
40 /*
41 * Spares (bad sector replacements) below
42 * are not counted in d_nsectors or d_secpercyl.
43 * Spare sectors are assumed to be physical sectors
44 * which occupy space at the end of each track and/or cylinder.
45 */
46 uint16_t d_sparespertrack; /* # of spare sectors per track */
47 uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
48
49 /*
50 * Alternate cylinders include maintenance, replacement,
51 * configuration description areas, etc.
52 */
53 uint32_t d_acylinders; /* # of alt. cylinders per unit */
54
55 /* hardware characteristics: */
56 /*
57 * d_interleave, d_trackskew and d_cylskew describe perturbations
58 * in the media format used to compensate for a slow controller.
59 * Interleave is physical sector interleave, set up by the formatter
60 * or controller when formatting. When interleaving is in use,
61 * logically adjacent sectors are not physically contiguous,
62 * but instead are separated by some number of sectors.
63 * It is specified as the ratio of physical sectors traversed
64 * per logical sector. Thus an interleave of 1:1 implies contiguous
65 * layout, while 2:1 implies that logical sector 0 is separated
66 * by one sector from logical sector 1.
67 * d_trackskew is the offset of sector 0 on track N
68 * relative to sector 0 on track N-1 on the same cylinder.
69 * Finally, d_cylskew is the offset of sector 0 on cylinder N
70 * relative to sector 0 on cylinder N-1.
71 */
72 uint16_t d_rpm; /* rotational speed */
73 uint16_t d_interleave; /* hardware sector interleave */
74 uint16_t d_trackskew; /* sector 0 skew, per track */
75 uint16_t d_cylskew; /* sector 0 skew, per cylinder */
76 uint32_t d_headswitch; /* head switch time, usec */
77 uint32_t d_trkseek; /* track-to-track seek, usec */
78 uint32_t d_flags; /* generic flags */
79 uint32_t d_drivedata[5]; /* drive-type specific information */
80 uint32_t d_spare[5]; /* reserved for future use */
81 uint32_t d_magic2; /* the magic number (again) */
82 uint16_t d_checksum; /* xor of data incl. partitions */
83
84 /* filesystem and partition information: */
85 uint16_t d_npartitions; /* number of partitions in following */
86 uint32_t d_bbsize; /* size of boot area at sn0, bytes */
87 uint32_t d_sbsize; /* max size of fs superblock, bytes */
88
89 struct bsd_partition { /* the partition table */
90 uint32_t p_size; /* number of sectors in partition */
91 uint32_t p_offset; /* starting sector */
92 uint32_t p_fsize; /* filesystem basic fragment size */
93 uint8_t p_fstype; /* filesystem type, see below */
94 uint8_t p_frag; /* filesystem fragments per block */
95 uint16_t p_cpg; /* filesystem cylinders per group */
96 } __attribute__((packed)) d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
97} __attribute__((packed));
98
99
100/* d_type values: */
101#define BSD_DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
102#define BSD_DTYPE_MSCP 2 /* MSCP */
103#define BSD_DTYPE_DEC 3 /* other DEC (rk, rl) */
104#define BSD_DTYPE_SCSI 4 /* SCSI */
105#define BSD_DTYPE_ESDI 5 /* ESDI interface */
106#define BSD_DTYPE_ST506 6 /* ST506 etc. */
107#define BSD_DTYPE_HPIB 7 /* CS/80 on HP-IB */
108#define BSD_DTYPE_HPFL 8 /* HP Fiber-link */
109#define BSD_DTYPE_FLOPPY 10 /* floppy */
110
111/* d_subtype values: */
112#define BSD_DSTYPE_INDOSPART 0x8 /* is inside dos partition */
113#define BSD_DSTYPE_DOSPART(s) ((s) & 3) /* dos partition number */
114#define BSD_DSTYPE_GEOMETRY 0x10 /* drive params in label */
115
116/*
117 * Filesystem type and version.
118 * Used to interpret other filesystem-specific
119 * per-partition information.
120 */
121#define BSD_FS_UNUSED 0 /* unused */
122#define BSD_FS_SWAP 1 /* swap */
123#define BSD_FS_V6 2 /* Sixth Edition */
124#define BSD_FS_V7 3 /* Seventh Edition */
125#define BSD_FS_SYSV 4 /* System V */
126#define BSD_FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
127#define BSD_FS_V8 6 /* Eighth Edition, 4K blocks */
128#define BSD_FS_BSDFFS 7 /* 4.2BSD fast file system */
129#define BSD_FS_BSDLFS 9 /* 4.4BSD log-structured file system */
130#define BSD_FS_OTHER 10 /* in use, but unknown/unsupported */
131#define BSD_FS_HPFS 11 /* OS/2 high-performance file system */
132#define BSD_FS_ISO9660 12 /* ISO-9660 filesystem (cdrom) */
133#define BSD_FS_ISOFS BSD_FS_ISO9660
134#define BSD_FS_BOOT 13 /* partition contains bootstrap */
135#define BSD_FS_ADOS 14 /* AmigaDOS fast file system */
136#define BSD_FS_HFS 15 /* Macintosh HFS */
137#define BSD_FS_ADVFS 16 /* Digital Unix AdvFS */
138
139/* this is annoying, but it's also the way it is :-( */
140#ifdef __alpha__
141#define BSD_FS_EXT2 8 /* ext2 file system */
142#else
143#define BSD_FS_MSDOS 8 /* MS-DOS file system */
144#endif
145
146/*
147 * flags shared by various drives:
148 */
149#define BSD_D_REMOVABLE 0x01 /* removable media */
150#define BSD_D_ECC 0x02 /* supports ECC */
151#define BSD_D_BADSECT 0x04 /* supports bad sector forw. */
152#define BSD_D_RAMDISK 0x08 /* disk emulator */
153#define BSD_D_CHAIN 0x10 /* can do back-back transfers */
154#define BSD_D_DOSPART 0x20 /* within MSDOS partition */
155
156#endif /* UTIL_LINUX_PT_BSD_H */