]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/disklabel.h
MFV r323527: 5815 libzpool's panic function doesn't set global panicstr, ::status...
[FreeBSD/FreeBSD.git] / sys / sys / disklabel.h
1 /*-
2  * Copyright (c) 1987, 1988, 1993
3  *      The Regents of the University of California.  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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      @(#)disklabel.h 8.2 (Berkeley) 7/10/94
30  * $FreeBSD$
31  */
32
33 #ifndef _SYS_DISKLABEL_H_
34 #define _SYS_DISKLABEL_H_
35
36 #ifndef _KERNEL
37 #include <sys/types.h>
38 #endif
39 #include <sys/ioccom.h>
40
41 #include <sys/disk/bsd.h>
42
43 /* Disk description table, see disktab(5) */
44 #define _PATH_DISKTAB   "/etc/disktab"
45
46 /*
47  * The label is in block 0 or 1, possibly offset from the beginning
48  * to leave room for a bootstrap, etc.
49  * XXX these should be defined per controller (or drive) elsewhere, not here!
50  * XXX in actuality it can't even be per controller or drive. It should be
51  * constant/fixed across storage hardware and CPU architectures. Disks can
52  * travel from one machine to another and a label created on one machine
53  * should be detectable and understood by the other.
54  */
55 #define LABELSECTOR     1                       /* sector containing label */
56 #define LABELOFFSET     0                       /* offset of label in sector */
57
58 #define DISKMAGIC       BSD_MAGIC               /* The disk magic number */
59
60 #ifndef MAXPARTITIONS
61 #define MAXPARTITIONS   BSD_NPARTS_MIN
62 #endif
63
64 /* Size of bootblock area in sector-size neutral bytes */
65 #define BBSIZE          BSD_BOOTBLOCK_SIZE
66
67 #define LABEL_PART      BSD_PART_RAW
68 #define RAW_PART        BSD_PART_RAW
69 #define SWAP_PART       BSD_PART_SWAP
70
71 #define NDDATA          BSD_NDRIVEDATA
72 #define NSPARE          BSD_NSPARE
73
74 static __inline u_int16_t dkcksum(struct disklabel *lp);
75 static __inline u_int16_t
76 dkcksum(struct disklabel *lp)
77 {
78         u_int16_t *start, *end;
79         u_int16_t sum = 0;
80
81         start = (u_int16_t *)lp;
82         end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
83         while (start < end)
84                 sum ^= *start++;
85         return (sum);
86 }
87
88 #ifdef DKTYPENAMES
89 static const char *dktypenames[] = {
90         "unknown",
91         "SMD",
92         "MSCP",
93         "old DEC",
94         "SCSI",
95         "ESDI",
96         "ST506",
97         "HP-IB",
98         "HP-FL",
99         "type 9",
100         "floppy",
101         "CCD",
102         "Vinum",
103         "DOC2K",
104         "Raid",
105         "?",
106         "jfs",
107         NULL
108 };
109 #define DKMAXTYPES      (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
110 #endif
111
112 #ifdef  FSTYPENAMES
113 static const char *fstypenames[] = {
114         "unused",
115         "swap",
116         "Version 6",
117         "Version 7",
118         "System V",
119         "4.1BSD",
120         "Eighth Edition",
121         "4.2BSD",
122         "MSDOS",
123         "4.4LFS",
124         "unknown",
125         "HPFS",
126         "ISO9660",
127         "boot",
128         "vinum",
129         "raid",
130         "Filecore",
131         "EXT2FS",
132         "NTFS",
133         "?",
134         "ccd",
135         "jfs",
136         "HAMMER",
137         "HAMMER2",
138         "UDF",
139         "?",
140         "EFS",
141         "ZFS",
142         "?",
143         "?",
144         "nandfs",
145         NULL
146 };
147 #define FSMAXTYPES      (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
148 #endif
149
150 /*
151  * NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
152  */
153
154 /*
155  * Functions for proper encoding/decoding of struct disklabel into/from
156  * bytestring.
157  */
158 void bsd_partition_le_dec(u_char *ptr, struct partition *d);
159 int bsd_disklabel_le_dec(u_char *ptr, struct disklabel *d, int maxpart);
160 void bsd_partition_le_enc(u_char *ptr, struct partition *d);
161 void bsd_disklabel_le_enc(u_char *ptr, struct disklabel *d);
162
163 #ifndef _KERNEL
164 __BEGIN_DECLS
165 struct disklabel *getdiskbyname(const char *);
166 __END_DECLS
167 #endif
168
169 #endif /* !_SYS_DISKLABEL_H_ */