]> git.saurik.com Git - apple/hfs.git/blob - core/hfs_key_roll.h
hfs-366.1.1.tar.gz
[apple/hfs.git] / core / hfs_key_roll.h
1 /*
2 * Copyright (c) 2014 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef HFS_KEY_ROLL_H_
30 #define HFS_KEY_ROLL_H_
31
32 #include <stdbool.h>
33
34 #include "hfs_format.h"
35 #include "hfs_fsctl.h"
36 #include "hfs_cprotect.h"
37
38 /*
39 * This structure contains the in-memory information required for key
40 * rolling. It is referenced via a pointer in the cprotect structure.
41 */
42 typedef struct hfs_cp_key_roll_ctx {
43 #if DEBUG
44 uint32_t ckr_magic1;
45 #endif
46 // This indicates where we are with key rolling
47 off_rsrc_t ckr_off_rsrc;
48
49 // When set, indicates we are currently rolling a chunk
50 bool ckr_busy : 1;
51
52 /*
53 * This represents the tentative reservation---blocks that we have set
54 * aside for key rolling but can be claimed back by the allocation code
55 * if necessary.
56 */
57 struct rl_entry *ckr_tentative_reservation;
58
59 // This usually indicates the end of the last block we rolled
60 uint32_t ckr_preferred_next_block;
61
62 // The current extent that we're rolling to
63 HFSPlusExtentDescriptor ckr_roll_extent;
64
65 // The new keys -- variable length
66 cp_key_pair_t ckr_keys;
67 } hfs_cp_key_roll_ctx_t;
68
69 errno_t hfs_key_roll_check(struct cnode *cp, bool have_excl_trunc_lock);
70 errno_t hfs_key_roll_op(vfs_context_t ctx, vnode_t vp, hfs_key_roll_args_t *args);
71 errno_t hfs_key_roll_start(struct cnode *cp);
72 errno_t hfs_key_roll_up_to(vfs_context_t vfs_ctx, vnode_t vp, off_rsrc_t up_to);
73 errno_t hfs_key_roll_step(vfs_context_t vfs_ctx, vnode_t vp, off_rsrc_t up_to);
74 hfs_cp_key_roll_ctx_t *hfs_key_roll_ctx_alloc(const hfs_cp_key_roll_ctx_t *old,
75 uint16_t pers_key_len,
76 uint16_t cached_key_len,
77 cp_key_pair_t **pcpkp);
78 void hfs_release_key_roll_ctx(struct hfsmount *hfsmp, cprotect_t cpr);
79 bool hfs_is_key_rolling(cnode_t *cp);
80
81 #endif // HFS_KEY_ROLL_H_