xref: /freebsd-13.1/sys/sys/disk/vtoc.h (revision ef4b102c)
1 /*-
2  * Copyright (c) 2008 Marcel Moolenaar
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  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 #ifndef _SYS_DISK_VTOC_H_
30 #define	_SYS_DISK_VTOC_H_
31 
32 #include <sys/types.h>
33 
34 #define	VTOC_TAG_UNASSIGNED	0x00
35 #define	VTOC_TAG_BOOT		0x01
36 #define	VTOC_TAG_ROOT		0x02
37 #define	VTOC_TAG_SWAP		0x03
38 #define	VTOC_TAG_USR		0x04
39 #define	VTOC_TAG_BACKUP		0x05	/* "c" partition */
40 #define	VTOC_TAG_STAND		0x06
41 #define	VTOC_TAG_VAR		0x07
42 #define	VTOC_TAG_HOME		0x08
43 #define	VTOC_TAG_ALTSCTR	0x09	/* alternate sector partition */
44 #define	VTOC_TAG_CACHE		0x0a	/* Solaris cachefs partition */
45 #define	VTOC_TAG_VXVM_PUB	0x0e	/* VxVM public region */
46 #define	VTOC_TAG_VXVM_PRIV	0x0f	/* VxVM private region */
47 
48 /* NetBSD/mips defines this */
49 #define	VTOC_TAG_NETBSD_FFS	0xff
50 
51 /* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */
52 #define	VTOC_TAG_FREEBSD_SWAP	0x0901
53 #define	VTOC_TAG_FREEBSD_UFS	0x0902
54 #define	VTOC_TAG_FREEBSD_VINUM	0x0903
55 #define	VTOC_TAG_FREEBSD_ZFS	0x0904
56 #define	VTOC_TAG_FREEBSD_NANDFS	0x0905
57 
58 #define	VTOC_FLAG_UNMNT		0x01	/* unmountable partition */
59 #define	VTOC_FLAG_RDONLY	0x10    /* partition is read/only */
60 
61 #define	VTOC_ASCII_LEN	128
62 #define	VTOC_BOOTSIZE	8192		/* 16 sectors */
63 #define	VTOC_MAGIC	0xdabe
64 #define	VTOC_RAW_PART	2
65 #define	VTOC_SANITY	0x600ddeee
66 #define	VTOC_VERSION	1
67 #define	VTOC_VOLUME_LEN	8
68 
69 #define	VTOC8_NPARTS	8
70 
71 struct vtoc8 {
72 	char		ascii[VTOC_ASCII_LEN];
73 	uint32_t	version;
74 	char		volume[VTOC_VOLUME_LEN];
75 	uint16_t	nparts;
76 	struct {
77 		uint16_t	tag;
78 		uint16_t	flag;
79 	} part[VTOC8_NPARTS];
80 	uint16_t	__alignment;
81 	uint32_t	bootinfo[3];
82 	uint32_t	sanity;
83 	uint32_t	reserved[10];
84 	uint32_t	timestamp[VTOC8_NPARTS];
85 	uint16_t	wskip;
86 	uint16_t	rskip;
87 	char		padding[152];
88 	uint16_t	rpm;
89 	uint16_t	physcyls;
90 	uint16_t	sparesecs;
91 	uint16_t	spare1[2];
92 	uint16_t	interleave;
93 	uint16_t	ncyls;
94 	uint16_t	altcyls;
95 	uint16_t	nheads;
96 	uint16_t	nsecs;
97 	uint16_t	spare2[2];
98 	struct {
99 		uint32_t	cyl;
100 		uint32_t	nblks;
101 	} map[VTOC8_NPARTS];
102 	uint16_t	magic;
103 	uint16_t	cksum;
104 };
105 
106 #ifdef CTASSERT
107 CTASSERT(sizeof(struct vtoc8) == 512);
108 #endif
109 
110 #endif /* _SYS_DISK_VTOC_H_ */
111