Daniel Rosenberg | 02e6625 | 2014-08-13 01:52:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | #ifndef F2FS_UTILS_F2F2_UTILS_H_ |
| 18 | #define F2FS_UTILS_F2F2_UTILS_H_ |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | #define ver_after(a, b) (typecheck(unsigned long long, a) && \ |
| 29 | typecheck(unsigned long long, b) && \ |
| 30 | ((long long)((a) - (b)) > 0)) |
| 31 | |
| 32 | #define ver_equal(a, b) (typecheck(unsigned long long, a) && \ |
| 33 | typecheck(unsigned long long, b) && \ |
| 34 | ((long long)((a) - (b)) == 0)) |
| 35 | |
| 36 | struct f2fs_sit_block; |
| 37 | struct f2fs_summary_block; |
| 38 | |
| 39 | struct f2fs_info { |
| 40 | u_int64_t blocks_per_segment; |
| 41 | u_int32_t block_size; |
| 42 | |
| 43 | char *sit_bmp; |
| 44 | u_int32_t sit_bmp_size; |
| 45 | u_int64_t blocks_per_sit; |
| 46 | struct f2fs_sit_block *sit_blocks; |
| 47 | struct f2fs_summary_block *sit_sums; |
| 48 | |
| 49 | u_int64_t cp_blkaddr; |
| 50 | u_int64_t cp_valid_cp_blkaddr; |
| 51 | |
| 52 | u_int64_t sit_blkaddr; |
| 53 | |
| 54 | u_int64_t nat_blkaddr; |
| 55 | |
| 56 | u_int64_t ssa_blkaddr; |
| 57 | |
| 58 | u_int64_t main_blkaddr; |
| 59 | |
| 60 | u_int64_t total_user_used; |
| 61 | u_int64_t total_blocks; |
| 62 | }; |
| 63 | |
| 64 | u64 get_num_blocks_used(struct f2fs_info *info); |
| 65 | struct f2fs_info *generate_f2fs_info(int fd); |
| 66 | void free_f2fs_info(struct f2fs_info *info); |
| 67 | unsigned int get_f2fs_filesystem_size_sec(char *dev); |
| 68 | int run_on_used_blocks(u64 startblock, struct f2fs_info *info, int (*func)(u64 pos, void *data), void *data); |
| 69 | |
| 70 | #ifdef __cplusplus |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #endif // F2FS_UTILS_F2F2_UTILS_H_ |