xref: /netbsd-src/external/bsd/pdisk/dist/partition_map.h (revision 48a628ae0434c4247b560ad8f2eb1dc06d0dd070)
19428323dSchristos //
29428323dSchristos // partition_map.h - partition map routines
39428323dSchristos //
49428323dSchristos // Written by Eryk Vershen
59428323dSchristos //
69428323dSchristos 
79428323dSchristos /*
89428323dSchristos  * Copyright 1996,1998 by Apple Computer, Inc.
99428323dSchristos  *              All Rights Reserved
109428323dSchristos  *
119428323dSchristos  * Permission to use, copy, modify, and distribute this software and
129428323dSchristos  * its documentation for any purpose and without fee is hereby granted,
139428323dSchristos  * provided that the above copyright notice appears in all copies and
149428323dSchristos  * that both the copyright notice and this permission notice appear in
159428323dSchristos  * supporting documentation.
169428323dSchristos  *
179428323dSchristos  * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
189428323dSchristos  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
199428323dSchristos  * FOR A PARTICULAR PURPOSE.
209428323dSchristos  *
219428323dSchristos  * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
229428323dSchristos  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
239428323dSchristos  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
249428323dSchristos  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
259428323dSchristos  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
269428323dSchristos  */
279428323dSchristos 
289428323dSchristos #ifndef __partition_map__
299428323dSchristos #define __partition_map__
309428323dSchristos 
319428323dSchristos #include "dpme.h"
329428323dSchristos #include "media.h"
339428323dSchristos 
349428323dSchristos 
359428323dSchristos //
369428323dSchristos // Defines
379428323dSchristos //
389428323dSchristos #define	PBLOCK_SIZE	512
399428323dSchristos #define	MAX_LINUX_MAP	15
409428323dSchristos 
419428323dSchristos 
429428323dSchristos //
439428323dSchristos // Types
449428323dSchristos //
459428323dSchristos struct partition_map_header {
469428323dSchristos     MEDIA m;
479428323dSchristos     char *name;
489428323dSchristos     struct partition_map * disk_order;
499428323dSchristos     struct partition_map * base_order;
509428323dSchristos     Block0 *misc;
51*48a628aeSchristos     int writable;
529428323dSchristos     int changed;
539428323dSchristos     int written;
549428323dSchristos     int physical_block;		// must be == sbBlockSize
559428323dSchristos     int logical_block;		// must be <= physical_block
569428323dSchristos     int blocks_in_map;
579428323dSchristos     int maximum_in_map;
58*48a628aeSchristos     uint32_t media_size;	// in logical_blocks
599428323dSchristos };
609428323dSchristos typedef struct partition_map_header partition_map_header;
619428323dSchristos 
629428323dSchristos struct partition_map {
639428323dSchristos     struct partition_map * next_on_disk;
649428323dSchristos     struct partition_map * prev_on_disk;
659428323dSchristos     struct partition_map * next_by_base;
669428323dSchristos     struct partition_map * prev_by_base;
67*48a628aeSchristos     int32_t disk_address;
689428323dSchristos     struct partition_map_header * the_map;
699428323dSchristos     int contains_driver;
709428323dSchristos     DPME *data;
719428323dSchristos     int HFS_kind;
729428323dSchristos     char *HFS_name;
739428323dSchristos };
749428323dSchristos typedef struct partition_map partition_map;
759428323dSchristos 
769428323dSchristos /* Identifies the HFS kind. */
779428323dSchristos enum {
789428323dSchristos     kHFS_not       =   0,	// ' '
799428323dSchristos     kHFS_std       =   1,	// 'h'
809428323dSchristos     kHFS_embed     =   2,	// 'e'
819428323dSchristos     kHFS_plus      =   3	// '+'
829428323dSchristos };
839428323dSchristos 
849428323dSchristos 
859428323dSchristos //
869428323dSchristos // Global Constants
879428323dSchristos //
889428323dSchristos extern const char * kFreeType;
899428323dSchristos extern const char * kMapType;
909428323dSchristos extern const char * kUnixType;
919428323dSchristos extern const char * kHFSType;
929428323dSchristos extern const char * kFreeName;
939428323dSchristos extern const char * kPatchType;
949428323dSchristos 
959428323dSchristos 
969428323dSchristos //
979428323dSchristos // Global Variables
989428323dSchristos //
999428323dSchristos extern int rflag;
1009428323dSchristos extern int interactive;
1019428323dSchristos extern int dflag;
1029428323dSchristos 
1039428323dSchristos 
1049428323dSchristos //
1059428323dSchristos // Forward declarations
1069428323dSchristos //
107*48a628aeSchristos int add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32_t length, partition_map_header *map);
1089428323dSchristos void close_partition_map(partition_map_header *map);
1099428323dSchristos partition_map_header* create_partition_map(char *name, partition_map_header *oldmap);
1109428323dSchristos void delete_partition_from_map(partition_map *entry);
111*48a628aeSchristos partition_map* find_entry_by_disk_address(int32_t, partition_map_header *);
1129428323dSchristos partition_map* find_entry_by_type(const char *type_name, partition_map_header *map);
113*48a628aeSchristos partition_map* find_entry_by_base(uint32_t base, partition_map_header *map);
1149428323dSchristos partition_map_header* init_partition_map(char *name, partition_map_header* oldmap);
115*48a628aeSchristos void move_entry_in_map(int32_t, int32_t, partition_map_header *);
1169428323dSchristos partition_map_header* open_partition_map(char *name, int *valid_file, int ask_logical_size);
117*48a628aeSchristos void resize_map(uint32_t new_size, partition_map_header *map);
1189428323dSchristos void write_partition_map(partition_map_header *map);
119*48a628aeSchristos void bzb_init_slice(BZB *bp, int slice);
120*48a628aeSchristos void dpme_init_flags(DPME *data);
1219428323dSchristos 
1229428323dSchristos #endif /* __partition_map__ */
123