]> git.ipfire.org Git - thirdparty/util-linux.git/blame - fdisk/fdiskbsdlabel.h
Imported from util-linux-2.10s tarball.
[thirdparty/util-linux.git] / fdisk / fdiskbsdlabel.h
CommitLineData
726f69e2
KZ
1/*
2 * Copyright (c) 1987, 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
66ee8158 34#include <linux/types.h> /* for __u32, __u16, __u8, __s16 */
2b6fc908 35
fd6b7a7f
KZ
36#ifndef BSD_DISKMAGIC /* perhaps from <linux/genhd.h> */
37#define BSD_DISKMAGIC ((__u32) 0x82564557)
38#endif
39
40#ifndef BSD_MAXPARTITIONS
726f69e2 41#define BSD_MAXPARTITIONS 8
fd6b7a7f
KZ
42#endif
43
726f69e2
KZ
44#define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
45
22853e4a 46#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__mips__)
726f69e2
KZ
47#define BSD_LABELSECTOR 1
48#define BSD_LABELOFFSET 0
22853e4a 49#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__)
726f69e2 50#define BSD_LABELSECTOR 0
fd6b7a7f 51#define BSD_LABELOFFSET 64
726f69e2
KZ
52#else
53#error unknown architecture
54#endif
55
2b6fc908
KZ
56#define BSD_BBSIZE 8192 /* size of boot area, with label */
57#define BSD_SBSIZE 8192 /* max size of fs superblock */
58
fd6b7a7f
KZ
59struct xbsd_disklabel {
60 __u32 d_magic; /* the magic number */
61 __s16 d_type; /* drive type */
62 __s16 d_subtype; /* controller/d_type specific */
726f69e2 63 char d_typename[16]; /* type name, e.g. "eagle" */
726f69e2 64 char d_packname[16]; /* pack identifier */
726f69e2 65 /* disk geometry: */
fd6b7a7f
KZ
66 __u32 d_secsize; /* # of bytes per sector */
67 __u32 d_nsectors; /* # of data sectors per track */
68 __u32 d_ntracks; /* # of tracks per cylinder */
69 __u32 d_ncylinders; /* # of data cylinders per unit */
70 __u32 d_secpercyl; /* # of data sectors per cylinder */
71 __u32 d_secperunit; /* # of data sectors per unit */
726f69e2
KZ
72 /*
73 * Spares (bad sector replacements) below
74 * are not counted in d_nsectors or d_secpercyl.
75 * Spare sectors are assumed to be physical sectors
76 * which occupy space at the end of each track and/or cylinder.
77 */
fd6b7a7f
KZ
78 __u16 d_sparespertrack; /* # of spare sectors per track */
79 __u16 d_sparespercyl; /* # of spare sectors per cylinder */
726f69e2
KZ
80 /*
81 * Alternate cylinders include maintenance, replacement,
82 * configuration description areas, etc.
83 */
fd6b7a7f 84 __u32 d_acylinders; /* # of alt. cylinders per unit */
726f69e2
KZ
85
86 /* hardware characteristics: */
87 /*
88 * d_interleave, d_trackskew and d_cylskew describe perturbations
89 * in the media format used to compensate for a slow controller.
90 * Interleave is physical sector interleave, set up by the formatter
91 * or controller when formatting. When interleaving is in use,
92 * logically adjacent sectors are not physically contiguous,
93 * but instead are separated by some number of sectors.
94 * It is specified as the ratio of physical sectors traversed
95 * per logical sector. Thus an interleave of 1:1 implies contiguous
96 * layout, while 2:1 implies that logical sector 0 is separated
97 * by one sector from logical sector 1.
98 * d_trackskew is the offset of sector 0 on track N
99 * relative to sector 0 on track N-1 on the same cylinder.
100 * Finally, d_cylskew is the offset of sector 0 on cylinder N
101 * relative to sector 0 on cylinder N-1.
102 */
fd6b7a7f
KZ
103 __u16 d_rpm; /* rotational speed */
104 __u16 d_interleave; /* hardware sector interleave */
105 __u16 d_trackskew; /* sector 0 skew, per track */
106 __u16 d_cylskew; /* sector 0 skew, per cylinder */
107 __u32 d_headswitch; /* head switch time, usec */
108 __u32 d_trkseek; /* track-to-track seek, usec */
109 __u32 d_flags; /* generic flags */
726f69e2 110#define NDDATA 5
fd6b7a7f 111 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
726f69e2 112#define NSPARE 5
fd6b7a7f
KZ
113 __u32 d_spare[NSPARE]; /* reserved for future use */
114 __u32 d_magic2; /* the magic number (again) */
115 __u16 d_checksum; /* xor of data incl. partitions */
726f69e2 116 /* filesystem and partition information: */
fd6b7a7f
KZ
117 __u16 d_npartitions; /* number of partitions in following */
118 __u32 d_bbsize; /* size of boot area at sn0, bytes */
119 __u32 d_sbsize; /* max size of fs superblock, bytes */
120 struct xbsd_partition { /* the partition table */
121 __u32 p_size; /* number of sectors in partition */
122 __u32 p_offset; /* starting sector */
123 __u32 p_fsize; /* filesystem basic fragment size */
124 __u8 p_fstype; /* filesystem type, see below */
125 __u8 p_frag; /* filesystem fragments per block */
126 __u16 p_cpg; /* filesystem cylinders per group */
726f69e2
KZ
127 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
128};
129
130/* d_type values: */
131#define BSD_DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
132#define BSD_DTYPE_MSCP 2 /* MSCP */
133#define BSD_DTYPE_DEC 3 /* other DEC (rk, rl) */
134#define BSD_DTYPE_SCSI 4 /* SCSI */
135#define BSD_DTYPE_ESDI 5 /* ESDI interface */
136#define BSD_DTYPE_ST506 6 /* ST506 etc. */
137#define BSD_DTYPE_HPIB 7 /* CS/80 on HP-IB */
138#define BSD_DTYPE_HPFL 8 /* HP Fiber-link */
139#define BSD_DTYPE_FLOPPY 10 /* floppy */
140
141/* d_subtype values: */
142#define BSD_DSTYPE_INDOSPART 0x8 /* is inside dos partition */
143#define BSD_DSTYPE_DOSPART(s) ((s) & 3) /* dos partition number */
144#define BSD_DSTYPE_GEOMETRY 0x10 /* drive params in label */
145
146#ifdef DKTYPENAMES
fd6b7a7f 147static char *xbsd_dktypenames[] = {
726f69e2
KZ
148 "unknown",
149 "SMD",
150 "MSCP",
151 "old DEC",
152 "SCSI",
153 "ESDI",
154 "ST506",
155 "HP-IB",
156 "HP-FL",
157 "type 9",
158 "floppy",
159 0
160};
fd6b7a7f 161#define BSD_DKMAXTYPES (sizeof(xbsd_dktypenames) / sizeof(xbsd_dktypenames[0]) - 1)
726f69e2
KZ
162#endif
163
164/*
165 * Filesystem type and version.
166 * Used to interpret other filesystem-specific
167 * per-partition information.
168 */
169#define BSD_FS_UNUSED 0 /* unused */
170#define BSD_FS_SWAP 1 /* swap */
171#define BSD_FS_V6 2 /* Sixth Edition */
172#define BSD_FS_V7 3 /* Seventh Edition */
173#define BSD_FS_SYSV 4 /* System V */
174#define BSD_FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
175#define BSD_FS_V8 6 /* Eighth Edition, 4K blocks */
176#define BSD_FS_BSDFFS 7 /* 4.2BSD fast file system */
726f69e2
KZ
177#define BSD_FS_BSDLFS 9 /* 4.4BSD log-structured file system */
178#define BSD_FS_OTHER 10 /* in use, but unknown/unsupported */
179#define BSD_FS_HPFS 11 /* OS/2 high-performance file system */
180#define BSD_FS_ISO9660 12 /* ISO-9660 filesystem (cdrom) */
181#define BSD_FS_ISOFS BSD_FS_ISO9660
182#define BSD_FS_BOOT 13 /* partition contains bootstrap */
183#define BSD_FS_ADOS 14 /* AmigaDOS fast file system */
184#define BSD_FS_HFS 15 /* Macintosh HFS */
22853e4a 185#define BSD_FS_ADVFS 16 /* Digital Unix AdvFS */
726f69e2 186
fd6b7a7f
KZ
187/* this is annoying, but it's also the way it is :-( */
188#ifdef __alpha__
22853e4a 189#define BSD_FS_EXT2 8 /* ext2 file system */
fd6b7a7f
KZ
190#else
191#define BSD_FS_MSDOS 8 /* MS-DOS file system */
192#endif
193
726f69e2 194#ifdef DKTYPENAMES
fd6b7a7f 195static struct systypes xbsd_fstypes[] = {
726f69e2
KZ
196 {BSD_FS_UNUSED, "unused"},
197 {BSD_FS_SWAP, "swap"},
198 {BSD_FS_V6, "Version 6"},
199 {BSD_FS_V7, "Version 7"},
200 {BSD_FS_SYSV, "System V"},
201 {BSD_FS_V71K, "4.1BSD"},
202 {BSD_FS_V8, "Eighth Edition"},
203 {BSD_FS_BSDFFS, "4.2BSD"},
fd6b7a7f
KZ
204#ifdef __alpha__
205 {BSD_FS_EXT2, "ext2"},
206#else
726f69e2 207 {BSD_FS_MSDOS, "MS-DOS"},
fd6b7a7f 208#endif
726f69e2
KZ
209 {BSD_FS_BSDLFS, "4.4LFS"},
210 {BSD_FS_OTHER, "unknown"},
211 {BSD_FS_HPFS, "HPFS"},
212 {BSD_FS_ISO9660,"ISO-9660"},
213 {BSD_FS_BOOT, "boot"},
214 {BSD_FS_ADOS, "ADOS"},
2b6fc908 215 {BSD_FS_HFS, "HFS"},
22853e4a 216 {BSD_FS_ADVFS, "AdvFS"},
2b6fc908 217 { 0, NULL }
726f69e2 218};
2b6fc908 219#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1)
726f69e2 220
726f69e2
KZ
221#endif
222
223/*
224 * flags shared by various drives:
225 */
226#define BSD_D_REMOVABLE 0x01 /* removable media */
227#define BSD_D_ECC 0x02 /* supports ECC */
228#define BSD_D_BADSECT 0x04 /* supports bad sector forw. */
229#define BSD_D_RAMDISK 0x08 /* disk emulator */
230#define BSD_D_CHAIN 0x10 /* can do back-back transfers */
231#define BSD_D_DOSPART 0x20 /* within MSDOS partition */