btrfs.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * BTRFS filesystem implementation for U-Boot
  4. *
  5. * 2017 Marek Behun, CZ.NIC, marek.behun@nic.cz
  6. */
  7. #ifndef __BTRFS_BTRFS_H__
  8. #define __BTRFS_BTRFS_H__
  9. #include <linux/rbtree.h>
  10. #include "conv-funcs.h"
  11. struct btrfs_info {
  12. struct btrfs_super_block sb;
  13. struct btrfs_root tree_root;
  14. struct btrfs_root fs_root;
  15. struct btrfs_root chunk_root;
  16. struct rb_root chunks_root;
  17. };
  18. extern struct btrfs_info btrfs_info;
  19. /* hash.c */
  20. void btrfs_hash_init(void);
  21. u32 btrfs_crc32c(u32, const void *, size_t);
  22. u32 btrfs_csum_data(char *, u32, size_t);
  23. void btrfs_csum_final(u32, void *);
  24. static inline u64 btrfs_name_hash(const char *name, int len)
  25. {
  26. return btrfs_crc32c((u32) ~1, name, len);
  27. }
  28. /* dev.c */
  29. extern struct blk_desc *btrfs_blk_desc;
  30. extern disk_partition_t *btrfs_part_info;
  31. int btrfs_devread(u64, int, void *);
  32. /* chunk-map.c */
  33. u64 btrfs_map_logical_to_physical(u64);
  34. int btrfs_chunk_map_init(void);
  35. void btrfs_chunk_map_exit(void);
  36. int btrfs_read_chunk_tree(void);
  37. /* compression.c */
  38. u32 btrfs_decompress(u8 type, const char *, u32, char *, u32);
  39. /* super.c */
  40. int btrfs_read_superblock(void);
  41. /* dir-item.c */
  42. typedef int (*btrfs_readdir_callback_t)(const struct btrfs_root *,
  43. struct btrfs_dir_item *);
  44. int btrfs_lookup_dir_item(const struct btrfs_root *, u64, const char *, int,
  45. struct btrfs_dir_item *);
  46. int btrfs_readdir(const struct btrfs_root *, u64, btrfs_readdir_callback_t);
  47. /* root.c */
  48. int btrfs_find_root(u64, struct btrfs_root *, struct btrfs_root_item *);
  49. u64 btrfs_lookup_root_ref(u64, struct btrfs_root_ref *, char *);
  50. /* inode.c */
  51. u64 btrfs_lookup_inode_ref(struct btrfs_root *, u64, struct btrfs_inode_ref *,
  52. char *);
  53. int btrfs_lookup_inode(const struct btrfs_root *, struct btrfs_key *,
  54. struct btrfs_inode_item *, struct btrfs_root *);
  55. int btrfs_readlink(const struct btrfs_root *, u64, char *);
  56. u64 btrfs_lookup_path(struct btrfs_root *, u64, const char *, u8 *,
  57. struct btrfs_inode_item *, int);
  58. u64 btrfs_file_read(const struct btrfs_root *, u64, u64, u64, char *);
  59. /* subvolume.c */
  60. u64 btrfs_get_default_subvol_objectid(void);
  61. /* extent-io.c */
  62. u64 btrfs_read_extent_inline(struct btrfs_path *,
  63. struct btrfs_file_extent_item *, u64, u64,
  64. char *);
  65. u64 btrfs_read_extent_reg(struct btrfs_path *, struct btrfs_file_extent_item *,
  66. u64, u64, char *);
  67. #endif /* !__BTRFS_BTRFS_H__ */