aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/btrfs.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2020-06-24 18:03:01 +0200
committerTom Rini <trini@konsulko.com>2020-09-07 20:57:27 -0400
commitf06bfcf54d0e91892fcd1379e04aae9cd031fc78 (patch)
treeaac26e518b93db18f3a3557e78340f9ad5483465 /fs/btrfs/btrfs.c
parent57f24f10733ac57754d4eae3666919480718b032 (diff)
fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progs
open_ctree_fs_info() is the main entry point to open btrfs. This version is a simplfied version of __open_ctree_fd() of btrfs-progs, the main differences are: - Parameters on how to specify a block device Instead of @fd and @path, U-Boot uses blk_desc and disk_partition_t. - Remove open_ctree flags There won't be multiple open ctree modes in U-Boot. Otherwise functions structures are all kept the same. With open_ctree_fs_info() implemented, also introduce the global current_fs_info pointer to show the current opened btrfs. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'fs/btrfs/btrfs.c')
-rw-r--r--fs/btrfs/btrfs.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
index f5266f1b917..2bd2ec9ed91 100644
--- a/fs/btrfs/btrfs.c
+++ b/fs/btrfs/btrfs.c
@@ -14,6 +14,7 @@
#include "disk-io.h"
struct btrfs_info btrfs_info;
+struct btrfs_fs_info *current_fs_info;
static int readdir_callback(const struct __btrfs_root *root,
struct btrfs_dir_item *item)
@@ -81,6 +82,9 @@ static int readdir_callback(const struct __btrfs_root *root,
int btrfs_probe(struct blk_desc *fs_dev_desc,
struct disk_partition *fs_partition)
{
+ struct btrfs_fs_info *fs_info;
+ int ret = -1;
+
btrfs_blk_desc = fs_dev_desc;
btrfs_part_info = fs_partition;
@@ -111,7 +115,12 @@ int btrfs_probe(struct blk_desc *fs_dev_desc,
return -1;
}
- return 0;
+ fs_info = open_ctree_fs_info(fs_dev_desc, fs_partition);
+ if (fs_info) {
+ current_fs_info = fs_info;
+ ret = 0;
+ }
+ return ret;
}
int btrfs_ls(const char *path)
@@ -215,6 +224,10 @@ int btrfs_read(const char *file, void *buf, loff_t offset, loff_t len,
void btrfs_close(void)
{
btrfs_chunk_map_exit();
+ if (current_fs_info) {
+ close_ctree_fs_info(current_fs_info);
+ current_fs_info = NULL;
+ }
}
int btrfs_uuid(char *uuid_str)