gpt.h revision 1.14 1 1.1 christos /*-
2 1.1 christos * Copyright (c) 2002 Marcel Moolenaar
3 1.1 christos * All rights reserved.
4 1.1 christos *
5 1.1 christos * Redistribution and use in source and binary forms, with or without
6 1.1 christos * modification, are permitted provided that the following conditions
7 1.1 christos * are met:
8 1.1 christos *
9 1.1 christos * 1. Redistributions of source code must retain the above copyright
10 1.1 christos * notice, this list of conditions and the following disclaimer.
11 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 christos * notice, this list of conditions and the following disclaimer in the
13 1.1 christos * documentation and/or other materials provided with the distribution.
14 1.1 christos *
15 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.1 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 1.1 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 1.1 christos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 1.1 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 1.1 christos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 1.1 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 1.1 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 1.1 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 1.1 christos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 1.1 christos *
26 1.1 christos * $FreeBSD: src/sbin/gpt/gpt.h,v 1.11 2006/06/22 22:05:28 marcel Exp $
27 1.1 christos */
28 1.1 christos
29 1.1 christos #ifndef _GPT_H_
30 1.1 christos #define _GPT_H_
31 1.1 christos
32 1.1 christos #include <sys/endian.h>
33 1.14 christos #ifndef HAVE_NBTOOL_CONFIG_H
34 1.2 christos #include <sys/disklabel_gpt.h>
35 1.14 christos #else
36 1.14 christos #include <nbinclude/sys/disklabel_gpt.h>
37 1.14 christos #endif
38 1.3 thorpej #define GPT_SIZE GPT_HDR_SIZE
39 1.2 christos #define hdr_uuid hdr_guid
40 1.2 christos #define ent_uuid ent_guid
41 1.1 christos
42 1.1 christos #include <uuid.h>
43 1.1 christos
44 1.6 jakllsch #define le_uuid_dec uuid_dec_le
45 1.6 jakllsch #define le_uuid_enc uuid_enc_le
46 1.1 christos int parse_uuid(const char *, uuid_t *);
47 1.1 christos
48 1.1 christos struct mbr_part {
49 1.1 christos uint8_t part_flag; /* bootstrap flags */
50 1.1 christos uint8_t part_shd; /* starting head */
51 1.1 christos uint8_t part_ssect; /* starting sector */
52 1.1 christos uint8_t part_scyl; /* starting cylinder */
53 1.1 christos uint8_t part_typ; /* partition type */
54 1.1 christos uint8_t part_ehd; /* end head */
55 1.1 christos uint8_t part_esect; /* end sector */
56 1.1 christos uint8_t part_ecyl; /* end cylinder */
57 1.1 christos uint16_t part_start_lo; /* absolute starting ... */
58 1.1 christos uint16_t part_start_hi; /* ... sector number */
59 1.1 christos uint16_t part_size_lo; /* partition size ... */
60 1.1 christos uint16_t part_size_hi; /* ... in sectors */
61 1.1 christos };
62 1.1 christos
63 1.1 christos struct mbr {
64 1.5 jakllsch uint8_t mbr_code[446];
65 1.1 christos struct mbr_part mbr_part[4];
66 1.1 christos uint16_t mbr_sig;
67 1.1 christos #define MBR_SIG 0xAA55
68 1.1 christos };
69 1.1 christos
70 1.4 uebayasi extern const char *device_arg;
71 1.1 christos extern char *device_name;
72 1.1 christos extern off_t mediasz;
73 1.1 christos extern u_int parts;
74 1.1 christos extern u_int secsz;
75 1.1 christos extern int readonly, verbose;
76 1.1 christos
77 1.1 christos uint32_t crc32(const void *, size_t);
78 1.1 christos void gpt_close(int);
79 1.12 jnemeth int gpt_gpt(int, off_t, int);
80 1.1 christos int gpt_open(const char *);
81 1.1 christos void* gpt_read(int, off_t, size_t);
82 1.1 christos int gpt_write(int, map_t *);
83 1.1 christos
84 1.1 christos uint8_t *utf16_to_utf8(uint16_t *);
85 1.1 christos void utf8_to_utf16(const uint8_t *, uint16_t *, size_t);
86 1.1 christos
87 1.1 christos int cmd_add(int, char *[]);
88 1.10 jnemeth int cmd_backup(int, char *[]);
89 1.5 jakllsch int cmd_biosboot(int, char *[]);
90 1.1 christos int cmd_create(int, char *[]);
91 1.1 christos int cmd_destroy(int, char *[]);
92 1.1 christos int cmd_label(int, char *[]);
93 1.1 christos int cmd_migrate(int, char *[]);
94 1.1 christos int cmd_recover(int, char *[]);
95 1.1 christos int cmd_remove(int, char *[]);
96 1.7 jnemeth int cmd_resize(int, char *[]);
97 1.12 jnemeth int cmd_resizedisk(int, char *[]);
98 1.11 jnemeth int cmd_restore(int, char *[]);
99 1.9 jnemeth int cmd_set(int, char *[]);
100 1.1 christos int cmd_show(int, char *[]);
101 1.13 jnemeth int cmd_type(int, char *[]);
102 1.9 jnemeth int cmd_unset(int, char *[]);
103 1.1 christos
104 1.1 christos #endif /* _GPT_H_ */
105