btrfs.h 2.4 KB

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