f2fs_sparseblock.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef F2FS_UTILS_F2F2_UTILS_H_
  17. #define F2FS_UTILS_F2F2_UTILS_H_
  18. #include <stdint.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define ver_after(a, b) (typecheck(unsigned long long, a) && \
  23. typecheck(unsigned long long, b) && \
  24. ((long long)((a) - (b)) > 0))
  25. #define ver_equal(a, b) (typecheck(unsigned long long, a) && \
  26. typecheck(unsigned long long, b) && \
  27. ((long long)((a) - (b)) == 0))
  28. struct f2fs_sit_block;
  29. struct f2fs_summary_block;
  30. struct f2fs_info {
  31. uint64_t blocks_per_segment;
  32. uint32_t block_size;
  33. char *sit_bmp;
  34. uint32_t sit_bmp_size;
  35. uint64_t blocks_per_sit;
  36. struct f2fs_sit_block *sit_blocks;
  37. struct f2fs_summary_block *sit_sums;
  38. uint64_t cp_blkaddr;
  39. uint64_t cp_valid_cp_blkaddr;
  40. uint64_t sit_blkaddr;
  41. uint64_t nat_blkaddr;
  42. uint64_t ssa_blkaddr;
  43. uint64_t main_blkaddr;
  44. uint64_t total_user_used;
  45. uint64_t total_blocks;
  46. };
  47. uint64_t get_num_blocks_used(struct f2fs_info *info);
  48. struct f2fs_info *generate_f2fs_info(int fd);
  49. void free_f2fs_info(struct f2fs_info *info);
  50. unsigned int get_f2fs_filesystem_size_sec(char *dev);
  51. int run_on_used_blocks(uint64_t startblock, struct f2fs_info *info, int (*func)(uint64_t pos, void *data), void *data);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif // F2FS_UTILS_F2F2_UTILS_H_