]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_extents.h
xnu-3248.30.4.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_extents.h
1 //
2 // hfs_extents.h
3 // hfs
4 //
5 // Created by csuter on 7/11/14.
6 // Copyright (c) 2014 Apple. All rights reserved.
7 //
8
9 #ifndef HFS_EXTENTS_H_
10 #define HFS_EXTENTS_H_
11
12 #include <stdint.h>
13 #include <stdbool.h>
14
15 #include "hfs_format.h"
16
17 #if !HFS_EXTENTS_TEST && !HFS_ALLOC_TEST
18 #include "hfs_cnode.h"
19 #include "hfs.h"
20 #include "hfscommon/headers/BTreesInternal.h"
21 #endif
22
23 typedef struct hfs_ext_iter {
24 struct vnode *vp; // If NULL, this is an xattr extent
25 BTreeIterator bt_iter;
26 uint8_t ndx; // Index in group
27 bool last_in_fork;
28 uint32_t file_block;
29 uint32_t group_block_count;
30 HFSPlusExtentRecord group;
31 } hfs_ext_iter_t;
32
33 errno_t hfs_ext_find(vnode_t vp, off_t offset, hfs_ext_iter_t *iter);
34
35 errno_t hfs_ext_replace(hfsmount_t *hfsmp, vnode_t vp,
36 uint32_t file_block,
37 const HFSPlusExtentDescriptor *repl,
38 int count,
39 HFSPlusExtentRecord catalog_extents);
40
41 bool hfs_ext_iter_is_catalog_extents(hfs_ext_iter_t *iter);
42
43 static inline void hfs_ext_copy_rec(const HFSPlusExtentRecord src,
44 HFSPlusExtentRecord dst)
45 {
46 memcpy(dst, src, sizeof(HFSPlusExtentRecord));
47 }
48
49 static inline uint32_t hfs_ext_end(const HFSPlusExtentDescriptor *ext)
50 {
51 return ext->startBlock + ext->blockCount;
52 }
53
54 #endif // HFS_EXTENTS_H_