xref: /openbsd/sbin/pdisk/partition_map.h (revision 78b63d65)
1 //
2 // partition_map.h - partition map routines
3 //
4 // Written by Eryk Vershen (eryk@apple.com)
5 //
6 
7 /*
8  * Copyright 1996,1998 by Apple Computer, Inc.
9  *              All Rights Reserved
10  *
11  * Permission to use, copy, modify, and distribute this software and
12  * its documentation for any purpose and without fee is hereby granted,
13  * provided that the above copyright notice appears in all copies and
14  * that both the copyright notice and this permission notice appear in
15  * supporting documentation.
16  *
17  * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
18  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19  * FOR A PARTICULAR PURPOSE.
20  *
21  * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
22  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
24  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26  */
27 
28 #ifndef __partition_map__
29 #define __partition_map__
30 
31 #include "dpme.h"
32 #include "media.h"
33 
34 
35 //
36 // Defines
37 //
38 #define	PBLOCK_SIZE	512
39 
40 
41 //
42 // Types
43 //
44 struct partition_map_header {
45     MEDIA m;
46     char *name;
47     struct partition_map * disk_order;
48     struct partition_map * base_order;
49     Block0 *misc;
50     int writeable;
51     int changed;
52     int physical_block;		// must be == sbBlockSize
53     int logical_block;		// must be <= physical_block
54     int blocks_in_map;
55     int maximum_in_map;
56     unsigned long media_size;	// in logical_blocks
57 };
58 typedef struct partition_map_header partition_map_header;
59 
60 struct partition_map {
61     struct partition_map * next_on_disk;
62     struct partition_map * prev_on_disk;
63     struct partition_map * next_by_base;
64     struct partition_map * prev_by_base;
65     long disk_address;
66     struct partition_map_header * the_map;
67     int contains_driver;
68     DPME *data;
69 };
70 typedef struct partition_map partition_map;
71 
72 
73 //
74 // Global Constants
75 //
76 extern const char * kFreeType;
77 extern const char * kMapType;
78 extern const char * kUnixType;
79 extern const char * kHFSType;
80 extern const char * kFreeName;
81 extern const char * kPatchType;
82 
83 
84 //
85 // Global Variables
86 //
87 extern int rflag;
88 extern int interactive;
89 extern int dflag;
90 
91 
92 //
93 // Forward declarations
94 //
95 int add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, partition_map_header *map);
96 void close_partition_map(partition_map_header *map);
97 partition_map_header* create_partition_map(char *name, partition_map_header *oldmap);
98 void delete_partition_from_map(partition_map *entry);
99 partition_map* find_entry_by_disk_address(long index, partition_map_header *map);
100 partition_map* find_entry_by_type(const char *type_name, partition_map_header *map);
101 partition_map_header* init_partition_map(char *name, partition_map_header* oldmap);
102 void move_entry_in_map(long old_index, long index, partition_map_header *map);
103 partition_map_header* open_partition_map(char *name, int *valid_file, int ask_logical_size);
104 void resize_map(long new_size, partition_map_header *map);
105 void write_partition_map(partition_map_header *map);
106 
107 #endif /* __partition_map__ */
108