Home | History | Annotate | Line # | Download | only in hfs
libhfs.h revision 1.7
      1 /*	$NetBSD: libhfs.h,v 1.7 2015/06/21 14:00:40 maxv Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Yevgeny Binder, Dieter Baron, and Pelle Johansson.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _FS_HFS_LIBHFS_H_
     33 #define _FS_HFS_LIBHFS_H_
     34 
     35 #include <sys/endian.h>
     36 #include <sys/param.h>
     37 #include <sys/mount.h>	/* needs to go after sys/param.h or compile fails */
     38 #include <sys/types.h>
     39 #if defined(_KERNEL)
     40 #include <sys/kernel.h>
     41 #include <sys/systm.h>
     42 #include <sys/fcntl.h>
     43 #endif /* defined(_KERNEL) */
     44 
     45 #if !defined(_KERNEL) && !defined(STANDALONE)
     46 #include <fcntl.h>
     47 #include <iconv.h>
     48 #include <stdarg.h>
     49 #include <stdint.h>
     50 #include <stdio.h>
     51 #include <stdlib.h>
     52 #include <unistd.h>
     53 #endif /* !defined(_KERNEL) && !defined(STANDALONE) */
     54 
     55 #define max(A,B) ((A) > (B) ? (A):(B))
     56 #define min(A,B) ((A) < (B) ? (A):(B))
     57 
     58 
     59 /* Macros to handle errors in this library. Not recommended outside libhfs.c */
     60 #ifdef __PCC__
     61 #define HFS_LIBERR(format, ...) \
     62 	do{ hfslib_error(format, __FILE__, __LINE__); \
     63 		goto error; } while(/*CONSTCOND*/ 0)
     64 #else
     65 #define HFS_LIBERR(format, ...) \
     66 	do{ hfslib_error(format, __FILE__, __LINE__, ##__VA_ARGS__); \
     67 		goto error; } while(/*CONSTCOND*/ 0)
     68 #endif
     69 
     70 #if 0
     71 #pragma mark Constants (on-disk)
     72 #endif
     73 
     74 
     75 enum {
     76 	HFS_SIG_HFSP	= 0x482B,	/* 'H+' */
     77 	HFS_SIG_HFSX	= 0x4858,	/* 'HX' */
     78 	HFS_SIG_HFS	= 0x4244	/* 'BD' */
     79 }; /* volume signatures */
     80 
     81 typedef enum {
     82 							/* bits 0-6 are reserved */
     83 	HFS_VOL_HWLOCK			= 7,
     84 	HFS_VOL_UNMOUNTED		= 8,
     85 	HFS_VOL_BADBLOCKS		= 9,
     86 	HFS_VOL_NOCACHE		= 10,
     87 	HFS_VOL_DIRTY			= 11,
     88 	HFS_VOL_CNIDS_RECYCLED	= 12,
     89 	HFS_VOL_JOURNALED		= 13,
     90 							/* bit 14 is reserved */
     91 	HFS_VOL_SWLOCK			= 15
     92 							/* bits 16-31 are reserved */
     93 } hfs_volume_attribute_bit; /* volume header attribute bits */
     94 
     95 typedef enum {
     96 	HFS_LEAFNODE	= -1,
     97 	HFS_INDEXNODE	= 0,
     98 	HFS_HEADERNODE	= 1,
     99 	HFS_MAPNODE	= 2
    100 } hfs_node_kind; /* btree node kinds */
    101 
    102 enum {
    103 	HFS_BAD_CLOSE_MASK			= 0x00000001,
    104 	HFS_BIG_KEYS_MASK			= 0x00000002,
    105 	HFS_VAR_INDEX_KEYS_MASK	= 0x00000004
    106 }; /* btree header attribute masks */
    107 
    108 typedef enum {
    109 	HFS_CNID_ROOT_PARENT	= 1,
    110 	HFS_CNID_ROOT_FOLDER	= 2,
    111 	HFS_CNID_EXTENTS		= 3,
    112 	HFS_CNID_CATALOG		= 4,
    113 	HFS_CNID_BADBLOCKS		= 5,
    114 	HFS_CNID_ALLOCATION	= 6,
    115 	HFS_CNID_STARTUP		= 7,
    116 	HFS_CNID_ATTRIBUTES	= 8,
    117 								/* CNIDs 9-13 are reserved */
    118 	HFS_CNID_REPAIR		= 14,
    119 	HFS_CNID_TEMP			= 15,
    120 	HFS_CNID_USER			= 16
    121 } hfs_special_cnid; /* special CNID values */
    122 
    123 typedef enum {
    124 	HFS_REC_FLDR			= 0x0001,
    125 	HFS_REC_FILE			= 0x0002,
    126 	HFS_REC_FLDR_THREAD	= 0x0003,
    127 	HFS_REC_FILE_THREAD	= 0x0004
    128 } hfs_catalog_rec_kind; /* catalog record types */
    129 
    130 enum {
    131 	HFS_JOURNAL_ON_DISK_MASK		= 0x00000001, /* journal on same volume */
    132 	HFS_JOURNAL_ON_OTHER_MASK		= 0x00000002, /* journal elsewhere */
    133 	HFS_JOURNAL_NEEDS_INIT_MASK	= 0x00000004
    134 }; /* journal flag masks */
    135 
    136 enum {
    137 	HFS_JOURNAL_HEADER_MAGIC	= 0x4a4e4c78,
    138 	HFS_JOURNAL_ENDIAN_MAGIC	= 0x12345678
    139 }; /* journal magic numbers */
    140 
    141 enum {
    142 	HFS_DATAFORK	= 0x00,
    143 	HFS_RSRCFORK	= 0xFF
    144 }; /* common fork types */
    145 
    146 enum {
    147 	HFS_KEY_CASEFOLD	= 0xCF,
    148 	HFS_KEY_BINARY		= 0XBC
    149 }; /* catalog key comparison method types */
    150 
    151 enum {
    152 	HFS_MIN_CAT_KEY_LEN	= 6,
    153 	HFS_MAX_CAT_KEY_LEN	= 516,
    154 	HFS_MAX_EXT_KEY_LEN	= 10
    155 };
    156 
    157 enum {
    158 	HFS_HARD_LINK_FILE_TYPE = 0x686C6E6B,  /* 'hlnk' */
    159 	HFS_HFSLUS_CREATOR     = 0x6866732B   /* 'hfs+' */
    160 };
    161 
    162 
    163 #if 0
    164 #pragma mark -
    165 #pragma mark Constants (custom)
    166 #endif
    167 
    168 
    169 /* number of bytes between start of volume and volume header */
    170 #define HFS_VOLUME_HEAD_RESERVE_SIZE	1024
    171 
    172 typedef enum {
    173 	HFS_CATALOG_FILE = 1,
    174 	HFS_EXTENTS_FILE = 2,
    175 	HFS_ATTRIBUTES_FILE = 3
    176 } hfs_btree_file_type; /* btree file kinds */
    177 
    178 
    179 #if 0
    180 #pragma mark -
    181 #pragma mark On-Disk Types (Mac OS specific)
    182 #endif
    183 
    184 typedef uint32_t	hfs_macos_type_code; /* four 1-byte char field */
    185 
    186 typedef struct {
    187 	int16_t	v;
    188 	int16_t	h;
    189 } hfs_macos_point_t;
    190 
    191 typedef struct {
    192 	int16_t	t;	/* top */
    193 	int16_t	l;	/* left */
    194 	int16_t	b;	/* bottom */
    195 	int16_t	r;	/* right */
    196 } hfs_macos_rect_t;
    197 
    198 typedef struct {
    199 	hfs_macos_type_code	file_type;
    200 	hfs_macos_type_code	file_creator;
    201 	uint16_t				finder_flags;
    202 	hfs_macos_point_t	location;
    203 	uint16_t				reserved;
    204 } hfs_macos_file_info_t;
    205 
    206 typedef struct {
    207 	int16_t	reserved[4];
    208 	uint16_t	extended_finder_flags;
    209 	int16_t	reserved2;
    210 	int32_t	put_away_folder_cnid;
    211 } hfs_macos_extended_file_info_t;
    212 
    213 typedef struct {
    214 	hfs_macos_rect_t		window_bounds;
    215 	uint16_t				finder_flags;
    216 	hfs_macos_point_t	location;
    217 	uint16_t				reserved;
    218 } hfs_macos_folder_info_t;
    219 
    220 typedef struct {
    221 	hfs_macos_point_t	scroll_position;
    222 	int32_t				reserved;
    223 	uint16_t				extended_finder_flags;
    224 	int16_t				reserved2;
    225 	int32_t				put_away_folder_cnid;
    226 } hfs_macos_extended_folder_info_t;
    227 
    228 
    229 #if 0
    230 #pragma mark -
    231 #pragma mark On-Disk Types
    232 #endif
    233 
    234 typedef uint16_t unichar_t;
    235 
    236 typedef uint32_t hfs_cnid_t;
    237 
    238 typedef struct {
    239 	uint16_t	length;
    240 	unichar_t	unicode[255];
    241 } hfs_unistr255_t;
    242 
    243 typedef struct {
    244 	uint32_t	start_block;
    245 	uint32_t	block_count;
    246 } hfs_extent_descriptor_t;
    247 
    248 typedef hfs_extent_descriptor_t hfs_extent_record_t[8];
    249 
    250 typedef struct hfs_fork_t {
    251 	uint64_t				logical_size;
    252 	uint32_t				clump_size;
    253 	uint32_t				total_blocks;
    254 	hfs_extent_record_t	extents;
    255 } hfs_fork_t;
    256 
    257 typedef struct {
    258 	uint16_t	signature;
    259 	uint16_t	version;
    260 	uint32_t	attributes;
    261 	uint32_t	last_mounting_version;
    262 	uint32_t	journal_info_block;
    263 
    264 	uint32_t	date_created;
    265 	uint32_t	date_modified;
    266 	uint32_t	date_backedup;
    267 	uint32_t	date_checked;
    268 
    269 	uint32_t	file_count;
    270 	uint32_t	folder_count;
    271 
    272 	uint32_t	block_size;
    273 	uint32_t	total_blocks;
    274 	uint32_t	free_blocks;
    275 
    276 	uint32_t	next_alloc_block;
    277 	uint32_t	rsrc_clump_size;
    278 	uint32_t	data_clump_size;
    279 	hfs_cnid_t	next_cnid;
    280 
    281 	uint32_t	write_count;
    282 	uint64_t	encodings;
    283 
    284 	uint32_t	finder_info[8];
    285 
    286 	hfs_fork_t	allocation_file;
    287 	hfs_fork_t	extents_file;
    288 	hfs_fork_t	catalog_file;
    289 	hfs_fork_t	attributes_file;
    290 	hfs_fork_t	startup_file;
    291 } hfs_volume_header_t;
    292 
    293 typedef struct {
    294 	uint32_t	flink;
    295 	uint32_t	blink;
    296 	int8_t		kind;
    297 	uint8_t		height;
    298 	uint16_t	num_recs;
    299 	uint16_t	reserved;
    300 } hfs_node_descriptor_t;
    301 
    302 typedef struct {
    303 	uint16_t	tree_depth;
    304 	uint32_t	root_node;
    305 	uint32_t	leaf_recs;
    306 	uint32_t	first_leaf;
    307 	uint32_t	last_leaf;
    308 	uint16_t	node_size;
    309 	uint16_t	max_key_len;
    310 	uint32_t	total_nodes;
    311 	uint32_t	free_nodes;
    312 	uint16_t	reserved;
    313 	uint32_t	clump_size;		/* misaligned */
    314 	uint8_t		btree_type;
    315 	uint8_t		keycomp_type;
    316 	uint32_t	attributes;		/* long aligned again */
    317 	uint32_t	reserved2[16];
    318 } hfs_header_record_t;
    319 
    320 typedef struct {
    321 	uint16_t			key_len;
    322 	hfs_cnid_t			parent_cnid;
    323 	hfs_unistr255_t	name;
    324 } hfs_catalog_key_t;
    325 
    326 typedef struct {
    327 	uint16_t	key_length;
    328 	uint8_t		fork_type;
    329 	uint8_t		padding;
    330 	hfs_cnid_t	file_cnid;
    331 	uint32_t	start_block;
    332 } hfs_extent_key_t;
    333 
    334 typedef struct {
    335 	uint32_t	owner_id;
    336 	uint32_t	group_id;
    337 	uint8_t		admin_flags;
    338 	uint8_t		owner_flags;
    339 	uint16_t	file_mode;
    340 	union {
    341 		uint32_t	inode_num;
    342 		uint32_t	link_count;
    343 		uint32_t	raw_device;
    344 	} special;
    345 } hfs_bsd_data_t;
    346 
    347 typedef struct {
    348 	int16_t			rec_type;
    349 	uint16_t		flags;
    350 	uint32_t		valence;
    351 	hfs_cnid_t		cnid;
    352 	uint32_t		date_created;
    353 	uint32_t		date_content_mod;
    354 	uint32_t		date_attrib_mod;
    355 	uint32_t		date_accessed;
    356 	uint32_t		date_backedup;
    357 	hfs_bsd_data_t						bsd;
    358 	hfs_macos_folder_info_t			user_info;
    359 	hfs_macos_extended_folder_info_t	finder_info;
    360 	uint32_t		text_encoding;
    361 	uint32_t		reserved;
    362 } hfs_folder_record_t;
    363 
    364 typedef struct {
    365 	int16_t			rec_type;
    366 	uint16_t		flags;
    367 	uint32_t		reserved;
    368 	hfs_cnid_t		cnid;
    369 	uint32_t		date_created;
    370 	uint32_t		date_content_mod;
    371 	uint32_t		date_attrib_mod;
    372 	uint32_t		date_accessed;
    373 	uint32_t		date_backedup;
    374 	hfs_bsd_data_t						bsd;
    375 	hfs_macos_file_info_t				user_info;
    376 	hfs_macos_extended_file_info_t		finder_info;
    377 	uint32_t		text_encoding;
    378 	uint32_t		reserved2;
    379 	hfs_fork_t		data_fork;
    380 	hfs_fork_t		rsrc_fork;
    381 } hfs_file_record_t;
    382 
    383 typedef struct {
    384 	int16_t				rec_type;
    385 	int16_t				reserved;
    386 	hfs_cnid_t			parent_cnid;
    387 	hfs_unistr255_t	name;
    388 } hfs_thread_record_t;
    389 
    390 typedef struct {
    391 	uint32_t	flags;
    392 	uint32_t	device_signature[8];
    393 	uint64_t	offset;
    394 	uint64_t	size;
    395 	uint64_t	reserved[32];
    396 } hfs_journal_info_t;
    397 
    398 typedef struct {
    399 	uint32_t	magic;
    400 	uint32_t	endian;
    401 	uint64_t	start;
    402 	uint64_t	end;
    403 	uint64_t	size;
    404 	uint32_t	blocklist_header_size;
    405 	uint32_t	checksum;
    406 	uint32_t	journal_header_size;
    407 } hfs_journal_header_t;
    408 
    409 /* plain HFS structures needed for hfs wrapper support */
    410 
    411 typedef struct {
    412 	uint16_t        start_block;
    413 	uint16_t        block_count;
    414 } hfs_hfs_extent_descriptor_t;
    415 
    416 typedef hfs_hfs_extent_descriptor_t hfs_hfs_extent_record_t[3];
    417 
    418 typedef struct {
    419 	uint16_t        signature;
    420 	uint32_t        date_created;
    421 	uint32_t        date_modified;
    422 	uint16_t        attributes;
    423 	uint16_t        root_file_count;
    424 	uint16_t        volume_bitmap;
    425 	uint16_t        next_alloc_block;
    426 	uint16_t        total_blocks;
    427 	uint32_t        block_size;
    428 	uint32_t        clump_size;
    429 	uint16_t        first_block;
    430 	hfs_cnid_t      next_cnid;
    431 	uint16_t        free_blocks;
    432 	unsigned char   volume_name[28];
    433 	uint32_t        date_backedup;
    434 	uint16_t        backup_seqnum;
    435 	uint32_t        write_count;
    436 	uint32_t        extents_clump_size;
    437 	uint32_t        catalog_clump_size;
    438 	uint16_t        root_folder_count;
    439 	uint32_t        file_count;
    440 	uint32_t        folder_count;
    441 	uint32_t        finder_info[8];
    442 	uint16_t        embedded_signature;
    443 	hfs_hfs_extent_descriptor_t embedded_extent;
    444 	uint32_t        extents_size;
    445 	hfs_hfs_extent_record_t extents_extents;
    446 	uint32_t        catalog_size;
    447 	hfs_hfs_extent_record_t catalog_extents;
    448 } hfs_hfs_master_directory_block_t;
    449 
    450 #if 0
    451 #pragma mark -
    452 #pragma mark Custom Types
    453 #endif
    454 
    455 typedef struct {
    456 	hfs_volume_header_t	vh;		/* volume header */
    457 	hfs_header_record_t	chr;	/* catalog file header node record*/
    458 	hfs_header_record_t	ehr;	/* extent overflow file header node record*/
    459 	uint8_t	catkeysizefieldsize;	/* size of catalog file key_len field in
    460 									 * bytes (1 or 2); always 2 for HFS+ */
    461 	uint8_t	extkeysizefieldsize;	/* size of extent file key_len field in
    462 									 * bytes (1 or 2); always 2 for HFS+ */
    463 	hfs_unistr255_t		name;	/* volume name */
    464 
    465 	/* pointer to catalog file key comparison function */
    466 	int (*keycmp) (const void*, const void*);
    467 
    468 	int						journaled;	/* 1 if volume is journaled, else 0 */
    469 	hfs_journal_info_t		jib;	/* journal info block */
    470 	hfs_journal_header_t	jh;		/* journal header */
    471 
    472 	uint64_t offset;	/* offset, in bytes, of HFS+ volume */
    473 	int		readonly;	/* 0 if mounted r/w, 1 if mounted r/o */
    474 	void*	cbdata;		/* application-specific data; allocated, defined and
    475 						 * used (if desired) by the program, usually within
    476 						 * callback routines */
    477 } hfs_volume;
    478 
    479 typedef union {
    480 	/* for leaf nodes */
    481 	int16_t					type; /* type of record: folder, file, or thread */
    482 	hfs_folder_record_t	folder;
    483 	hfs_file_record_t		file;
    484 	hfs_thread_record_t	thread;
    485 
    486 	/* for pointer nodes */
    487 	/* (using this large union for just one tiny field is not memory-efficient,
    488 	 *	 so change this if it becomes problematic) */
    489 	uint32_t	child;	/* node number of this node's child node */
    490 } hfs_catalog_keyed_record_t;
    491 
    492 /*
    493  * These arguments are passed among libhfs without any inspection. This struct
    494  * is accepted by all public functions of libhfs, and passed to each callback.
    495  * An application dereferences each pointer to its own specific struct of
    496  * arguments. Callbacks must be prepared to deal with NULL values for any of
    497  * these fields (by providing default values to be used in lieu of that
    498  * argument). However, a NULL pointer to this struct is an error.
    499  *
    500  * It was decided to make one unified argument structure, rather than many
    501  * separate, operand-specific structures, because, when this structure is passed
    502  * to a public function (e.g., hfslib_open_volume()), the function may make
    503  * several calls (and subcalls) to various facilities, e.g., read(), malloc(),
    504  * and free(), all of which require their own particular arguments. The
    505  * facilities to be used are quite impractical to foreshadow, so the application
    506  * takes care of all possible calls at once. This also reinforces the idea that
    507  * a public call is an umbrella to a set of system calls, and all of these calls
    508  * must be passed arguments which do not change within the context of this
    509  * umbrella. (E.g., if a public function makes two calls to read(), one call
    510  * should not be passed a uid of root and the other passed a uid of daemon.)
    511  */
    512 typedef struct {
    513 	/* The 'error' function does not take an argument. All others do. */
    514 
    515 	void*	allocmem;
    516 	void*	reallocmem;
    517 	void*	freemem;
    518 	void*	openvol;
    519 	void*	closevol;
    520 	void*	read;
    521 } hfs_callback_args;
    522 
    523 typedef struct {
    524 	/* error(in_format, in_file, in_line, in_args) */
    525 	void (*error) (const char*, const char*, int, va_list);
    526 
    527 	/* allocmem(in_size, cbargs) */
    528 	void* (*allocmem) (size_t, hfs_callback_args*);
    529 
    530 	/* reallocmem(in_ptr, in_size, cbargs) */
    531 	void* (*reallocmem) (void*, size_t, hfs_callback_args*);
    532 
    533 	/* freemem(in_ptr, cbargs) */
    534 	void (*freemem) (void*, hfs_callback_args*);
    535 
    536 	/* openvol(in_volume, in_devicepath, cbargs)
    537 	 * returns 0 on success */
    538 	int (*openvol) (hfs_volume*, const char*, hfs_callback_args*);
    539 
    540 	/* closevol(in_volume, cbargs) */
    541 	void (*closevol) (hfs_volume*, hfs_callback_args*);
    542 
    543 	/* read(in_volume, out_buffer, in_length, in_offset, cbargs)
    544 	 * returns 0 on success */
    545 	int (*read) (hfs_volume*, void*, uint64_t, uint64_t,
    546 		hfs_callback_args*);
    547 } hfs_callbacks;
    548 
    549 extern hfs_callbacks	hfs_gcb;	/* global callbacks */
    550 
    551 /*
    552  * global case folding table
    553  * (lazily initialized; see comments at bottom of hfs_open_volume())
    554  */
    555 extern unichar_t* hfs_gcft;
    556 
    557 #if 0
    558 #pragma mark -
    559 #pragma mark Functions
    560 #endif
    561 
    562 void hfslib_init(hfs_callbacks*);
    563 void hfslib_done(void);
    564 void hfslib_init_cbargs(hfs_callback_args*);
    565 
    566 int hfslib_open_volume(const char*, int, hfs_volume*,
    567 	hfs_callback_args*);
    568 void hfslib_close_volume(hfs_volume*, hfs_callback_args*);
    569 
    570 int hfslib_path_to_cnid(hfs_volume*, hfs_cnid_t, char**, uint16_t*,
    571 	hfs_callback_args*);
    572 hfs_cnid_t hfslib_find_parent_thread(hfs_volume*, hfs_cnid_t,
    573 	hfs_thread_record_t*, hfs_callback_args*);
    574 int hfslib_find_catalog_record_with_cnid(hfs_volume*, hfs_cnid_t,
    575 	hfs_catalog_keyed_record_t*, hfs_catalog_key_t*, hfs_callback_args*);
    576 int hfslib_find_catalog_record_with_key(hfs_volume*, hfs_catalog_key_t*,
    577 	hfs_catalog_keyed_record_t*, hfs_callback_args*);
    578 int hfslib_find_extent_record_with_key(hfs_volume*, hfs_extent_key_t*,
    579 	hfs_extent_record_t*, hfs_callback_args*);
    580 int hfslib_get_directory_contents(hfs_volume*, hfs_cnid_t,
    581 	hfs_catalog_keyed_record_t**, hfs_unistr255_t**, uint32_t*,
    582 	hfs_callback_args*);
    583 int hfslib_is_journal_clean(hfs_volume*);
    584 int hfslib_is_private_file(hfs_catalog_key_t*);
    585 
    586 int hfslib_get_hardlink(hfs_volume *, uint32_t,
    587 			 hfs_catalog_keyed_record_t *, hfs_callback_args *);
    588 
    589 size_t hfslib_read_volume_header(void*, hfs_volume_header_t*);
    590 size_t hfslib_read_master_directory_block(void*,
    591 	hfs_hfs_master_directory_block_t*);
    592 size_t hfslib_reada_node(void*, hfs_node_descriptor_t*, void***, uint16_t**,
    593 	hfs_btree_file_type, hfs_volume*, hfs_callback_args*);
    594 size_t hfslib_reada_node_offsets(void*, uint16_t*);
    595 size_t hfslib_read_header_node(void**, uint16_t*, uint16_t,
    596 	hfs_header_record_t*, void*, void*);
    597 size_t hfslib_read_catalog_keyed_record(void*, hfs_catalog_keyed_record_t*,
    598 	int16_t*, hfs_catalog_key_t*, hfs_volume*);
    599 size_t hfslib_read_extent_record(void*, hfs_extent_record_t*, hfs_node_kind,
    600 	hfs_extent_key_t*, hfs_volume*);
    601 void hfslib_free_recs(void***, uint16_t**, uint16_t*, hfs_callback_args*);
    602 
    603 size_t hfslib_read_fork_descriptor(void*, hfs_fork_t*);
    604 size_t hfslib_read_extent_descriptors(void*, hfs_extent_record_t*);
    605 size_t hfslib_read_unistr255(void*, hfs_unistr255_t*);
    606 size_t hfslib_read_bsd_data(void*, hfs_bsd_data_t*);
    607 size_t hfslib_read_file_userinfo(void*, hfs_macos_file_info_t*);
    608 size_t hfslib_read_file_finderinfo(void*, hfs_macos_extended_file_info_t*);
    609 size_t hfslib_read_folder_userinfo(void*, hfs_macos_folder_info_t*);
    610 size_t hfslib_read_folder_finderinfo(void*, hfs_macos_extended_folder_info_t*);
    611 size_t hfslib_read_journal_info(void*, hfs_journal_info_t*);
    612 size_t hfslib_read_journal_header(void*, hfs_journal_header_t*);
    613 
    614 uint16_t hfslib_make_catalog_key(hfs_cnid_t, uint16_t, unichar_t*,
    615 	hfs_catalog_key_t*);
    616 uint16_t hfslib_make_extent_key(hfs_cnid_t, uint8_t, uint32_t,
    617 	hfs_extent_key_t*);
    618 uint16_t hfslib_get_file_extents(hfs_volume*, hfs_cnid_t, uint8_t,
    619 	hfs_extent_descriptor_t**, hfs_callback_args*);
    620 int hfslib_readd_with_extents(hfs_volume*, void*, uint64_t*, uint64_t,
    621 	uint64_t, hfs_extent_descriptor_t*, uint16_t, hfs_callback_args*);
    622 
    623 int hfslib_compare_catalog_keys_cf(const void*, const void*);
    624 int hfslib_compare_catalog_keys_bc(const void*, const void*);
    625 int hfslib_compare_extent_keys(const void*, const void*);
    626 
    627 
    628 /* callback wrappers */
    629 void hfslib_error(const char*, const char*, int, ...) __attribute__ ((format (printf, 1, 4)));
    630 void* hfslib_malloc(size_t, hfs_callback_args*);
    631 void* hfslib_realloc(void*, size_t, hfs_callback_args*);
    632 void hfslib_free(void*, hfs_callback_args*);
    633 int hfslib_openvoldevice(hfs_volume*, const char*, hfs_callback_args*);
    634 void hfslib_closevoldevice(hfs_volume*, hfs_callback_args*);
    635 int hfslib_readd(hfs_volume*, void*, uint64_t, uint64_t, hfs_callback_args*);
    636 
    637 #endif /* !_FS_HFS_LIBHFS_H_ */
    638