xref: /dragonfly/sys/sys/disklabel64.h (revision 0a31961570a4f5b0eff99d4c2e54d7bc722c8c2f)
1 /*
2  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #ifndef _SYS_DISKLABEL64_H_
36 #define   _SYS_DISKLABEL64_H_
37 
38 #ifndef _SYS_TYPES_H_
39 #include <sys/types.h>
40 #endif
41 #if defined(_KERNEL) && !defined(_SYS_SYSTM_H_)
42 #include <sys/systm.h>
43 #endif
44 #ifndef _SYS_IOCCOM_H_
45 #include <sys/ioccom.h>
46 #endif
47 #ifndef _SYS_UUID_H_
48 #include <sys/uuid.h>
49 #endif
50 
51 /*
52  * disklabel64's start at offset 0 on the disk or slice they reside.  All
53  * values are byte offsets, not block numbers, in order to allow portability.
54  * Unlike the original 32 bit disklabels, the on-disk format for a 64 bit
55  * disklabel is slice-relative and does not have to be translated.
56  *
57  * Currently the number of partitions is limited to 16, but the virgin
58  * disklabel code will leave enough space for 32.
59  */
60 #define DISKMAGIC64 ((u_int32_t)0xc4464c59)       /* The disk magic number */
61 #ifndef MAXPARTITIONS64
62 #define   MAXPARTITIONS64     16
63 #endif
64 #ifndef RESPARTITIONS64
65 #define   RESPARTITIONS64     32
66 #endif
67 
68 /*
69  * Space within the label reserved for the stage2 boot code.
70  */
71 #ifndef BOOT2SIZE64
72 #define BOOT2SIZE64 (1024 * 32)
73 #endif
74 
75 
76 #ifndef LOCORE
77 
78 /*
79  * A disklabel64 starts at slice relative offset 0, NOT SECTOR 1.  In
80  * otherwords, d_magic is at byte offset 512 within the slice, regardless
81  * of the sector size.
82  *
83  * The d_reserved0 area is not included in the crc and any kernel writeback
84  * of the label will not change the d_reserved area on-disk.  It is purely
85  * a shim to allow us to avoid sector calculations when reading or
86  * writing the label.  Since byte offsets are used in our 64 bit disklabel,
87  * the entire disklabel and the I/O required to access it becomes
88  * sector-agnostic.
89  */
90 struct disklabel64 {
91           char        d_reserved0[512]; /* reserved or unused */
92           u_int32_t d_magic;            /* the magic number */
93           u_int32_t d_crc;              /* crc32() d_magic thru last part */
94           u_int32_t d_align;            /* partition alignment requirement */
95           u_int32_t d_npartitions;      /* number of partitions */
96           struct uuid d_stor_uuid;      /* unique uuid for label */
97 
98           u_int64_t d_total_size;                 /* total size incl everything (bytes) */
99           u_int64_t d_bbase;            /* boot area base offset (bytes) */
100                                                   /* boot area is bbase - (pbase-1) */
101           u_int64_t d_pbase;            /* first allocatable offset (bytes) */
102           u_int64_t d_pstop;            /* last allocatable offset+1 (bytes) */
103                                                   /* pbase and pstop are physically aligned */
104           u_int64_t d_abase;            /* location of backup copy if not 0 */
105 
106           u_char      d_packname[64];
107           u_char    d_reserved[64];
108 
109           /*
110            * Note: offsets are relative to the base of the slice, NOT to
111            * d_pbase.  Unlike 32 bit disklabels the on-disk format for
112            * a 64 bit disklabel remains slice-relative.
113            *
114            * An uninitialized partition has a p_boffset and p_bsize of 0.
115            *
116            * If p_fstype is not supported for a live partition it is set
117            * to FS_OTHER.  This is typically the case when the filesystem
118            * is identified by its uuid.
119            */
120           struct partition64 {                    /* the partition table */
121                     u_int64_t p_boffset;          /* slice relative offset, in bytes */
122                     u_int64_t p_bsize;  /* size of partition, in bytes */
123                     u_int8_t  p_fstype;
124                     u_int8_t  p_unused01;         /* reserved, must be 0 */
125                     u_int8_t  p_unused02;         /* reserved, must be 0 */
126                     u_int8_t  p_unused03;         /* reserved, must be 0 */
127                     u_int32_t p_unused04;         /* reserved, must be 0 */
128                     u_int32_t p_unused05;         /* reserved, must be 0 */
129                     u_int32_t p_unused06;         /* reserved, must be 0 */
130                     struct uuid p_type_uuid;/* mount type as UUID */
131                     struct uuid p_stor_uuid;/* unique uuid for storage */
132           } d_partitions[MAXPARTITIONS64];/* actually may be more */
133 };
134 
135 #ifdef _KERNEL
136 extern struct disklabel_ops disklabel64_ops;
137 #endif
138 
139 /*
140  * Disk-specific ioctls.
141  */
142 #define DIOCGDINFO64          _IOR('d', 101, struct disklabel64)
143 #define DIOCSDINFO64          _IOW('d', 102, struct disklabel64)
144 #define DIOCWDINFO64          _IOW('d', 103, struct disklabel64)
145 #define DIOCGDVIRGIN64        _IOR('d', 105, struct disklabel64)
146 
147 #endif /* LOCORE */
148 
149 #endif /* !_SYS_DISKLABEL64_H_ */
150