2 // partition_map.h - partition map routines
4 // Written by Eryk Vershen
8 * Copyright 1996,1998 by Apple Computer, Inc.
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.
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.
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.
28 #ifndef __partition_map__
29 #define __partition_map__
38 #define PBLOCK_SIZE 512
39 #define MAX_LINUX_MAP 15
45 struct partition_map_header
{
48 struct partition_map
* disk_order
;
49 struct partition_map
* base_order
;
54 int physical_block
; // must be == sbBlockSize
55 int logical_block
; // must be <= physical_block
58 unsigned long media_size
; // in logical_blocks
60 typedef struct partition_map_header partition_map_header
;
62 struct partition_map
{
63 struct partition_map
* next_on_disk
;
64 struct partition_map
* prev_on_disk
;
65 struct partition_map
* next_by_base
;
66 struct partition_map
* prev_by_base
;
68 struct partition_map_header
* the_map
;
74 typedef struct partition_map partition_map
;
76 /* Identifies the HFS kind. */
80 kHFS_embed
= 2, // 'e'
88 extern const char * kFreeType
;
89 extern const char * kMapType
;
90 extern const char * kUnixType
;
91 extern const char * kHFSType
;
92 extern const char * kFreeName
;
93 extern const char * kPatchType
;
100 extern int interactive
;
105 // Forward declarations
107 int add_partition_to_map(const char *name
, const char *dptype
, u32 base
, u32 length
, partition_map_header
*map
);
108 void close_partition_map(partition_map_header
*map
);
109 partition_map_header
* create_partition_map(char *name
, partition_map_header
*oldmap
);
110 void delete_partition_from_map(partition_map
*entry
);
111 partition_map
* find_entry_by_disk_address(long, partition_map_header
*);
112 partition_map
* find_entry_by_type(const char *type_name
, partition_map_header
*map
);
113 partition_map
* find_entry_by_base(u32 base
, partition_map_header
*map
);
114 partition_map_header
* init_partition_map(char *name
, partition_map_header
* oldmap
);
115 void move_entry_in_map(long, long, partition_map_header
*);
116 partition_map_header
* open_partition_map(char *name
, int *valid_file
, int ask_logical_size
);
117 void resize_map(unsigned long new_size
, partition_map_header
*map
);
118 void write_partition_map(partition_map_header
*map
);
119 void bzb_init_slice(BZB
*bp
, int slice
);
120 void dpme_init_flags(DPME
*data
);
122 #endif /* __partition_map__ */