#include "crypto/hash.h"
#include "disk-io.h"
-struct btrfs_info btrfs_info;
struct btrfs_fs_info *current_fs_info;
static int show_dir(struct btrfs_root *root, struct extent_buffer *eb,
char *target = NULL;
char filetime[32];
time_t mtime;
- int ret;
+ int ret = 0;
btrfs_dir_item_key_to_cpu(eb, di, &key);
struct btrfs_fs_info *fs_info;
int ret = -1;
- btrfs_blk_desc = fs_dev_desc;
- btrfs_part_info = fs_partition;
-
- memset(&btrfs_info, 0, sizeof(btrfs_info));
-
btrfs_hash_init();
- if (btrfs_read_superblock())
- return -1;
-
- if (btrfs_chunk_map_init()) {
- printf("%s: failed to init chunk map\n", __func__);
- return -1;
- }
-
- btrfs_info.tree_root.objectid = 0;
- btrfs_info.tree_root.bytenr = btrfs_info.sb.root;
- btrfs_info.chunk_root.objectid = 0;
- btrfs_info.chunk_root.bytenr = btrfs_info.sb.chunk_root;
-
- if (__btrfs_read_chunk_tree()) {
- printf("%s: failed to read chunk tree\n", __func__);
- return -1;
- }
-
- if (btrfs_find_root(btrfs_get_default_subvol_objectid(),
- &btrfs_info.fs_root, NULL)) {
- printf("%s: failed to find default subvolume\n", __func__);
- return -1;
- }
-
fs_info = open_ctree_fs_info(fs_dev_desc, fs_partition);
if (fs_info) {
current_fs_info = fs_info;
}
ret = btrfs_iter_dir(root, ino, show_dir);
if (ret < 0) {
- error("An error occured while listing directory %s", path);
+ error("An error occurred while listing directory %s", path);
return ret;
}
return 0;
ret = btrfs_file_read(root, ino, offset, len, buf);
if (ret < 0) {
- error("An error occured while reading file %s", file);
+ error("An error occurred while reading file %s", file);
return ret;
}
void btrfs_close(void)
{
- btrfs_chunk_map_exit();
if (current_fs_info) {
close_ctree_fs_info(current_fs_info);
current_fs_info = NULL;