1 |
dpavlin |
1 |
/* |
2 |
|
|
* libhfs - library for reading and writing Macintosh HFS volumes |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2000 Klaus Halfmann <klaus.halfmann@feri.de> |
5 |
|
|
* Original 1996-1998 Robert Leslie <rob@mars.org> |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
|
* |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
/* Open the device, read and verify the volume header |
24 |
|
|
(and its backup) */ |
25 |
|
|
extern int volume_open(volume* vol, const void *devicehandle, int partition, int rw); |
26 |
|
|
|
27 |
|
|
/* Write back all data eventually cached and close the device. */ |
28 |
|
|
extern int volume_close(volume* vol); |
29 |
|
|
|
30 |
|
|
/* read multiple blocks into given memory. |
31 |
|
|
* |
32 |
|
|
* returns given pointer or NULL on failure. |
33 |
|
|
*/ |
34 |
|
|
extern void* volume_readfromfork(volume* vol, void* buf, |
35 |
|
|
hfsp_fork_raw* f, UInt32 block, |
36 |
|
|
UInt32 count, UInt8 forktype, UInt32 fileId); |
37 |
|
|
|
38 |
|
|
/* write multiple blocks of a fork buf to medium. |
39 |
|
|
* The caller is responsible for allocating a suffient |
40 |
|
|
* large fork and eventually needed extends records for now. |
41 |
|
|
* |
42 |
|
|
* block realtive index in fork to start with |
43 |
|
|
* count number of blocks to write |
44 |
|
|
* forktype usually HFSP_EXTENT_DATA or HFSP_EXTENT_RSRC |
45 |
|
|
* fileId id (needed) in case extents must be written |
46 |
|
|
* |
47 |
|
|
* returns value != 0 on error. |
48 |
|
|
*/ |
49 |
|
|
int volume_writetofork(volume* vol, void* buf, |
50 |
|
|
hfsp_fork_raw* f, UInt32 block, |
51 |
|
|
UInt32 count, UInt8 forktype, UInt32 fileId); |
52 |
|
|
|
53 |
|
|
/* Fill a given buffer with the given block in volume. |
54 |
|
|
*/ |
55 |
|
|
int volume_readinbuf(volume * vol,void* buf, long block); |
56 |
|
|
|
57 |
|
|
/* Check in Allocation file if given block is allocated. */ |
58 |
|
|
extern int volume_allocated(volume* v, UInt32 block); |
59 |
|
|
|
60 |
|
|
/* Read a raw hfsp_extent_rec from memory. */ |
61 |
|
|
extern char* volume_readextent(char *p, hfsp_extent_rec er); |
62 |
|
|
|
63 |
|
|
/* Read fork information from raw memory */ |
64 |
|
|
extern char* volume_readfork(char *p, hfsp_fork_raw* f); |
65 |
|
|
|
66 |
|
|
/* Write fork information to raw memory */ |
67 |
|
|
extern char* volume_writefork(char *p, hfsp_fork_raw* f); |
68 |
|
|
|
69 |
|
|
/* Initialize for to all zero, you may allocate later */ |
70 |
|
|
void volume_initfork(volume* vol, hfsp_fork_raw* f, UInt16 fork_type); |
71 |
|
|
|
72 |
|
|
/* internal function used to create the extents btree, |
73 |
|
|
is called by following inline function when needed */ |
74 |
|
|
extern void volume_create_extents_tree(volume* vol); |
75 |
|
|
|
76 |
|
|
/* accessor for entends btree, is created on demand */ |
77 |
|
|
static inline btree* volume_get_extents_tree(volume* vol) |
78 |
|
|
{ |
79 |
|
|
if (!vol->extents) |
80 |
|
|
volume_create_extents_tree(vol); |
81 |
|
|
return vol->extents; |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
/* return new Id for files/folder and check for overflow. |
85 |
|
|
* |
86 |
|
|
* retun 0 on error . |
87 |
|
|
*/ |
88 |
|
|
extern UInt32 volume_get_nextid(volume* vol); |
89 |
|
|
|