gpt.h revision 1.15
1/*-
2 * Copyright (c) 2002 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: src/sbin/gpt/gpt.h,v 1.11 2006/06/22 22:05:28 marcel Exp $
27 */
28
29#ifndef _GPT_H_
30#define	_GPT_H_
31
32#include <sys/endian.h>
33#ifndef HAVE_NBTOOL_CONFIG_H
34#include <sys/disklabel_gpt.h>
35#else
36#include <nbinclude/sys/disklabel_gpt.h>
37#endif
38
39#include <uuid.h>
40
41int	parse_uuid(const char *, uuid_t *);
42
43struct mbr_part {
44	uint8_t		part_flag;		/* bootstrap flags */
45	uint8_t		part_shd;		/* starting head */
46	uint8_t		part_ssect;		/* starting sector */
47	uint8_t		part_scyl;		/* starting cylinder */
48	uint8_t		part_typ;		/* partition type */
49	uint8_t		part_ehd;		/* end head */
50	uint8_t		part_esect;		/* end sector */
51	uint8_t		part_ecyl;		/* end cylinder */
52	uint16_t	part_start_lo;		/* absolute starting ... */
53	uint16_t	part_start_hi;		/* ... sector number */
54	uint16_t	part_size_lo;		/* partition size ... */
55	uint16_t	part_size_hi;		/* ... in sectors */
56};
57
58struct mbr {
59	uint8_t		mbr_code[446];
60	struct mbr_part	mbr_part[4];
61	uint16_t	mbr_sig;
62#define	MBR_SIG		0xAA55
63};
64
65extern const char *device_arg;
66extern char *device_name;
67extern off_t mediasz;
68extern u_int parts;
69extern u_int secsz;
70extern int readonly, verbose;
71
72uint32_t crc32(const void *, size_t);
73void	gpt_close(int);
74int	gpt_gpt(int, off_t, int);
75int	gpt_open(const char *);
76void*	gpt_read(int, off_t, size_t);
77int	gpt_write(int, map_t *);
78
79uint8_t *utf16_to_utf8(uint16_t *);
80void	utf8_to_utf16(const uint8_t *, uint16_t *, size_t);
81
82int	cmd_add(int, char *[]);
83int	cmd_backup(int, char *[]);
84int	cmd_biosboot(int, char *[]);
85int	cmd_create(int, char *[]);
86int	cmd_destroy(int, char *[]);
87int	cmd_label(int, char *[]);
88int	cmd_migrate(int, char *[]);
89int	cmd_recover(int, char *[]);
90int	cmd_remove(int, char *[]);
91int	cmd_resize(int, char *[]);
92int	cmd_resizedisk(int, char *[]);
93int	cmd_restore(int, char *[]);
94int	cmd_set(int, char *[]);
95int	cmd_show(int, char *[]);
96int	cmd_type(int, char *[]);
97int	cmd_unset(int, char *[]);
98
99#endif /* _GPT_H_ */
100