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//
45struct 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    unsigned long media_size;	// in logical_blocks
59};
60typedef struct partition_map_header partition_map_header;
61
62struct 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    long 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};
74typedef struct partition_map partition_map;
75
76/* Identifies the HFS kind. */
77enum {
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//
88extern const char * kFreeType;
89extern const char * kMapType;
90extern const char * kUnixType;
91extern const char * kHFSType;
92extern const char * kFreeName;
93extern const char * kPatchType;
94
95
96//
97// Global Variables
98//
99extern int rflag;
100extern int interactive;
101extern int dflag;
102
103
104//
105// Forward declarations
106//
107int add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, partition_map_header *map);
108void close_partition_map(partition_map_header *map);
109partition_map_header* create_partition_map(char *name, partition_map_header *oldmap, int oflag);
110void delete_partition_from_map(partition_map *entry);
111partition_map* find_entry_by_disk_address(long, partition_map_header *);
112partition_map* find_entry_by_type(const char *type_name, partition_map_header *map);
113partition_map* find_entry_by_base(u32 base, partition_map_header *map);
114partition_map_header* init_partition_map(char *name, partition_map_header* oldmap, int oflag);
115void move_entry_in_map(long, long, partition_map_header *);
116partition_map_header* open_partition_map(char *name, int *valid_file, int ask_logical_size, int oflag);
117void resize_map(unsigned long new_size, partition_map_header *map);
118void write_partition_map(partition_map_header *map);
119void bzb_init_slice(BZB *bp, int slice);
120void dpme_init_flags(DPME *data);
121
122#endif /* __partition_map__ */
123