blob: 4247cbbb09766601df2687aedf86ef4ff33ee6da [file] [log] [blame]
Marek BehĂșn21a14fa2017-09-03 17:00:28 +02001/*
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
9#ifndef __BTRFS_BTRFS_H__
10#define __BTRFS_BTRFS_H__
11
12#include <linux/rbtree.h>
13#include "conv-funcs.h"
14
15struct btrfs_info {
16 struct btrfs_super_block sb;
17 struct btrfs_root_backup *root_backup;
18
19 struct btrfs_root tree_root;
20 struct btrfs_root fs_root;
21 struct btrfs_root chunk_root;
22
23 struct rb_root chunks_root;
24};
25
26extern struct btrfs_info btrfs_info;
27
28/* hash.c */
29void btrfs_hash_init(void);
30u32 btrfs_crc32c(u32, const void *, size_t);
31u32 btrfs_csum_data(char *, u32, size_t);
32void btrfs_csum_final(u32, void *);
33
34static inline u64 btrfs_name_hash(const char *name, int len)
35{
36 return btrfs_crc32c((u32) ~1, name, len);
37}
38
39/* dev.c */
40extern struct blk_desc *btrfs_blk_desc;
41extern disk_partition_t *btrfs_part_info;
42
43int btrfs_devread(u64, int, void *);
44
45/* chunk-map.c */
46u64 btrfs_map_logical_to_physical(u64);
47int btrfs_chunk_map_init(void);
48void btrfs_chunk_map_exit(void);
49int btrfs_read_chunk_tree(void);
50
51/* compression.c */
52u32 btrfs_decompress(u8 type, const char *, u32, char *, u32);
53
54/* super.c */
55int btrfs_read_superblock(void);
56
57/* dir-item.c */
58typedef int (*btrfs_readdir_callback_t)(const struct btrfs_root *,
59 struct btrfs_dir_item *);
60
61int btrfs_lookup_dir_item(const struct btrfs_root *, u64, const char *, int,
62 struct btrfs_dir_item *);
63int btrfs_readdir(const struct btrfs_root *, u64, btrfs_readdir_callback_t);
64
65/* root.c */
66int btrfs_find_root(u64, struct btrfs_root *, struct btrfs_root_item *);
67u64 btrfs_lookup_root_ref(u64, struct btrfs_root_ref *, char *);
68
69/* inode.c */
70u64 btrfs_lookup_inode_ref(struct btrfs_root *, u64, struct btrfs_inode_ref *,
71 char *);
72int btrfs_lookup_inode(const struct btrfs_root *, struct btrfs_key *,
73 struct btrfs_inode_item *, struct btrfs_root *);
74int btrfs_readlink(const struct btrfs_root *, u64, char *);
75u64 btrfs_lookup_path(struct btrfs_root *, u64, const char *, u8 *,
76 struct btrfs_inode_item *, int);
77u64 btrfs_file_read(const struct btrfs_root *, u64, u64, u64, char *);
78
79/* subvolume.c */
80u64 btrfs_get_default_subvol_objectid(void);
81
82/* extent-io.c */
83u64 btrfs_read_extent_inline(struct btrfs_path *,
84 struct btrfs_file_extent_item *, u64, u64,
85 char *);
86u64 btrfs_read_extent_reg(struct btrfs_path *, struct btrfs_file_extent_item *,
87 u64, u64, char *);
88
89#endif /* !__BTRFS_BTRFS_H__ */