• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define ver_after(a, b)                                                      \
27     (typecheck(unsigned long long, a) && typecheck(unsigned long long, b) && \
28      ((long long)((a) - (b)) > 0))
29 
30 #define ver_equal(a, b)                                                      \
31     (typecheck(unsigned long long, a) && typecheck(unsigned long long, b) && \
32      ((long long)((a) - (b)) == 0))
33 
34 struct f2fs_sit_block;
35 struct f2fs_summary_block;
36 
37 struct f2fs_info {
38     uint64_t blocks_per_segment;
39     uint32_t block_size;
40 
41     char* sit_bmp;
42     uint32_t sit_bmp_size;
43     uint64_t blocks_per_sit;
44     struct f2fs_sit_block* sit_blocks;
45     struct f2fs_summary_block* sit_sums;
46 
47     uint64_t cp_blkaddr;
48     uint64_t cp_valid_cp_blkaddr;
49 
50     uint64_t sit_blkaddr;
51 
52     uint64_t nat_blkaddr;
53 
54     uint64_t ssa_blkaddr;
55 
56     uint64_t main_blkaddr;
57 
58     uint64_t total_user_used;
59     uint64_t total_blocks;
60 };
61 
62 uint64_t get_num_blocks_used(struct f2fs_info* info);
63 struct f2fs_info* generate_f2fs_info(int fd);
64 void free_f2fs_info(struct f2fs_info* info);
65 unsigned int get_f2fs_filesystem_size_sec(char* dev);
66 int run_on_used_blocks(uint64_t startblock, struct f2fs_info* info,
67                        int (*func)(uint64_t pos, void* data), void* data);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif  // F2FS_UTILS_F2F2_UTILS_H_
74