]>
git.saurik.com Git - apple/hfs.git/blob - libhfs_metadata/iterate_hfs_metadata.c
5 #include "iterate_hfs_metadata.h"
6 #include "../CopyHFSMeta/Data.h"
7 #include "../CopyHFSMeta/hfsmeta.h"
10 * These variables are used by the CopyHFSMeta routines, so we have to define them
13 __private_extern__
int debug
= 0;
14 __private_extern__
int verbose
= 0;
15 __private_extern__
int printProgress
= 0;
18 * This is essentially the guts of CopyHFSMeta, only without
19 * the ability to write out to a sparse bundle. It also always
20 * wants to get the "other" metadata (symlinks and large EA extents).
22 * For each extent it finds, it calls the passed-in function pointer,
23 * with the start and length.
25 * It will go through and get the symlink and EA extents first, and
26 * then go through the rest of the extents. It does not attempt any
30 iterate_hfs_metadata(char *device
, int (*handle_extent
)(int fd
, off_t start
, off_t length
, void *ctx
), void *context_ptr
)
32 struct DeviceInfo
*devp
= NULL
;
33 struct VolumeDescriptor
*vdp
= NULL
;
34 VolumeObjects_t
*vop
= NULL
;
37 devp
= OpenDevice(device
, 0);
43 vdp
= VolumeInfo(devp
);
49 if (CompareVolumeHeaders(vdp
) == -1) {
54 vop
= InitVolumeObject(devp
, vdp
);
61 * These guys don't have an error. Probably
69 * By this point, vop has all of the system metadata.
70 * The only metadata we don't have would be symlinks (from
71 * the catalog file), and extended attribute fork extents
72 * (from the attributes file). We get those with
73 * FindOtherMetadata().
75 retval
= FindOtherMetadata(vop
, ^(int fid __unused
, off_t start
, off_t len
) {
76 return (*handle_extent
)(devp
->fd
, start
, len
, context_ptr
);
83 * Now, we've handled all of the other metadata, so we need
84 * to go through the rest of our metadata, which is in vop.
86 ExtentList_t
*extList
;
87 for (extList
= vop
->list
;
89 extList
= extList
->next
) {
92 for (index
= 0; index
< extList
->count
; index
++) {
93 retval
= (*handle_extent
)(devp
->fd
, extList
->extents
[index
].base
, extList
->extents
[index
].length
, context_ptr
);
101 ReleaseVolumeObjects(vop
);
104 ReleaseVolumeDescriptor(vdp
);
107 ReleaseDeviceInfo(devp
);