1176718Smarcel/*-
2176718Smarcel * Copyright (c) 2008 Marcel Moolenaar
3176718Smarcel * All rights reserved.
4176718Smarcel *
5176718Smarcel * Redistribution and use in source and binary forms, with or without
6176718Smarcel * modification, are permitted provided that the following conditions
7176718Smarcel * are met:
8176718Smarcel *
9176718Smarcel * 1. Redistributions of source code must retain the above copyright
10176718Smarcel *    notice, this list of conditions and the following disclaimer.
11176718Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12176718Smarcel *    notice, this list of conditions and the following disclaimer in the
13176718Smarcel *    documentation and/or other materials provided with the distribution.
14176718Smarcel *
15176718Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16176718Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17176718Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18176718Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19176718Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20176718Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21176718Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22176718Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23176718Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24176718Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25176718Smarcel *
26176718Smarcel * $FreeBSD$
27176718Smarcel */
28176718Smarcel
29176718Smarcel#ifndef _SYS_VTOC_H_
30176718Smarcel#define	_SYS_VTOC_H_
31176718Smarcel
32176718Smarcel#define	VTOC_TAG_UNASSIGNED	0x00
33176718Smarcel#define	VTOC_TAG_BOOT		0x01
34176718Smarcel#define	VTOC_TAG_ROOT		0x02
35176718Smarcel#define	VTOC_TAG_SWAP		0x03
36176718Smarcel#define	VTOC_TAG_USR		0x04
37176718Smarcel#define	VTOC_TAG_BACKUP		0x05	/* "c" partition */
38176718Smarcel#define	VTOC_TAG_STAND		0x06
39176718Smarcel#define	VTOC_TAG_VAR		0x07
40176718Smarcel#define	VTOC_TAG_HOME		0x08
41176718Smarcel#define	VTOC_TAG_ALTSCTR	0x09	/* alternate sector partition */
42176718Smarcel#define	VTOC_TAG_CACHE		0x0a	/* Solaris cachefs partition */
43176718Smarcel#define	VTOC_TAG_VXVM_PUB	0x0e	/* VxVM public region */
44176718Smarcel#define	VTOC_TAG_VXVM_PRIV	0x0f	/* VxVM private region */
45176718Smarcel
46176718Smarcel/* NetBSD/mips defines this */
47176718Smarcel#define	VTOC_TAG_NETBSD_FFS	0xff
48176718Smarcel
49176718Smarcel/* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */
50176718Smarcel#define	VTOC_TAG_FREEBSD_SWAP	0x0901
51176718Smarcel#define	VTOC_TAG_FREEBSD_UFS	0x0902
52176718Smarcel#define	VTOC_TAG_FREEBSD_VINUM	0x0903
53176718Smarcel#define	VTOC_TAG_FREEBSD_ZFS	0x0904
54236023Smarcel#define	VTOC_TAG_FREEBSD_NANDFS	0x0905
55176718Smarcel
56176718Smarcel#define	VTOC_FLAG_UNMNT		0x01	/* unmountable partition */
57208777Smarius#define	VTOC_FLAG_RDONLY	0x10    /* partition is read/only */
58176718Smarcel
59176718Smarcel#define	VTOC_ASCII_LEN	128
60208777Smarius#define	VTOC_BOOTSIZE	8192		/* 16 sectors */
61176718Smarcel#define	VTOC_MAGIC	0xdabe
62176718Smarcel#define	VTOC_RAW_PART	2
63176718Smarcel#define	VTOC_SANITY	0x600ddeee
64176718Smarcel#define	VTOC_VERSION	1
65176718Smarcel#define	VTOC_VOLUME_LEN	8
66176718Smarcel
67176718Smarcel#define	VTOC8_NPARTS	8
68176718Smarcel
69176718Smarcelstruct vtoc8 {
70176718Smarcel	char		ascii[VTOC_ASCII_LEN];
71176718Smarcel	uint32_t	version;
72176718Smarcel	char		volume[VTOC_VOLUME_LEN];
73176718Smarcel	uint16_t	nparts;
74176718Smarcel	struct {
75176718Smarcel		uint16_t	tag;
76176718Smarcel		uint16_t	flag;
77186096Smarcel	} part[VTOC8_NPARTS] __packed;
78176718Smarcel	uint16_t	__alignment;
79176718Smarcel	uint32_t	bootinfo[3];
80176718Smarcel	uint32_t	sanity;
81176718Smarcel	uint32_t	reserved[10];
82176718Smarcel	uint32_t	timestamp[VTOC8_NPARTS];
83176718Smarcel	uint16_t	wskip;
84176718Smarcel	uint16_t	rskip;
85176718Smarcel	char		padding[152];
86176718Smarcel	uint16_t	rpm;
87176718Smarcel	uint16_t	physcyls;
88176718Smarcel	uint16_t	sparesecs;
89176718Smarcel	uint16_t	spare1[2];
90176718Smarcel	uint16_t	interleave;
91176718Smarcel	uint16_t	ncyls;
92176718Smarcel	uint16_t	altcyls;
93176718Smarcel	uint16_t	nheads;
94176718Smarcel	uint16_t	nsecs;
95176718Smarcel	uint16_t	spare2[2];
96176718Smarcel	struct {
97176718Smarcel		uint32_t	cyl;
98176718Smarcel		uint32_t	nblks;
99176718Smarcel	} map[VTOC8_NPARTS];
100176718Smarcel	uint16_t	magic;
101176718Smarcel	uint16_t	cksum;
102205838Simp} __packed;
103176718Smarcel
104176718Smarcel#ifdef CTASSERT
105176718SmarcelCTASSERT(sizeof(struct vtoc8) == 512);
106176718Smarcel#endif
107176718Smarcel
108176718Smarcel#endif /* _SYS_VTOC_H_ */
109