1 // 2 // partition_map.h - partition map routines 3 // 4 // Written by Eryk Vershen 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 #define MAX_LINUX_MAP 15 40 41 42 // 43 // Types 44 // 45 struct partition_map_header { 46 MEDIA m; 47 char *name; 48 struct partition_map * disk_order; 49 struct partition_map * base_order; 50 Block0 *misc; 51 int writable; 52 int changed; 53 int written; 54 int physical_block; // must be == sbBlockSize 55 int logical_block; // must be <= physical_block 56 int blocks_in_map; 57 int maximum_in_map; 58 uint32_t media_size; // in logical_blocks 59 }; 60 typedef struct partition_map_header partition_map_header; 61 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; 67 int32_t disk_address; 68 struct partition_map_header * the_map; 69 int contains_driver; 70 DPME *data; 71 int HFS_kind; 72 char *HFS_name; 73 }; 74 typedef struct partition_map partition_map; 75 76 /* Identifies the HFS kind. */ 77 enum { 78 kHFS_not = 0, // ' ' 79 kHFS_std = 1, // 'h' 80 kHFS_embed = 2, // 'e' 81 kHFS_plus = 3 // '+' 82 }; 83 84 85 // 86 // Global Constants 87 // 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; 94 95 96 // 97 // Global Variables 98 // 99 extern int rflag; 100 extern int interactive; 101 extern int dflag; 102 103 104 // 105 // Forward declarations 106 // 107 int add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32_t 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(int32_t, 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(uint32_t base, partition_map_header *map); 114 partition_map_header* init_partition_map(char *name, partition_map_header* oldmap); 115 void move_entry_in_map(int32_t, int32_t, partition_map_header *); 116 partition_map_header* open_partition_map(char *name, int *valid_file, int ask_logical_size); 117 void resize_map(uint32_t 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); 121 122 #endif /* __partition_map__ */ 123