1 /* 2 * Copyright (C) 2015-2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "block_tree.h" 20 21 struct block_map { 22 struct block_tree tree; 23 }; 24 25 #define BLOCK_MAP_INITIAL_VALUE(block_map) \ 26 { .tree = BLOCK_TREE_INITIAL_VALUE(block_map.tree), } 27 28 struct block_map_path { 29 struct block_tree_path path; 30 }; 31 32 void block_map_init(const struct transaction* tr, 33 struct block_map* block_map, 34 const struct block_mac* root, 35 size_t block_size); 36 37 bool block_map_get(struct transaction* tr, 38 struct block_map* block_map, 39 data_block_t index, 40 struct block_mac* block_mac); 41 42 void block_map_set(struct transaction* tr, 43 struct block_map* block_map, 44 data_block_t index, 45 const struct block_mac* block_mac); 46 47 void block_map_put_dirty(struct transaction* tr, 48 struct block_map* block_map, 49 data_block_t index, 50 void* data, 51 struct obj_ref* data_ref); 52 53 void block_map_truncate(struct transaction* tr, 54 struct block_map* block_map, 55 data_block_t index); 56 57 bool block_map_check(struct transaction* tr, 58 struct block_map* block_map, 59 data_block_t count); 60 61 void block_map_free(struct transaction* tr, struct block_map* block_map); 62