aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0322c55162cb..05637f9fd7c7 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -267,19 +267,24 @@ static int find_and_setup_root(struct btrfs_super_block *super,
267 267
268struct btrfs_root *open_ctree(char *filename, struct btrfs_super_block *super) 268struct btrfs_root *open_ctree(char *filename, struct btrfs_super_block *super)
269{ 269{
270 int fp;
271
272 fp = open(filename, O_CREAT | O_RDWR, 0600);
273 if (fp < 0) {
274 return NULL;
275 }
276 return open_ctree_fd(fp, super);
277}
278
279struct btrfs_root *open_ctree_fd(int fp, struct btrfs_super_block *super)
280{
270 struct btrfs_root *root = malloc(sizeof(struct btrfs_root)); 281 struct btrfs_root *root = malloc(sizeof(struct btrfs_root));
271 struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root)); 282 struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root));
272 struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root)); 283 struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root));
273 struct btrfs_root *inode_root = malloc(sizeof(struct btrfs_root)); 284 struct btrfs_root *inode_root = malloc(sizeof(struct btrfs_root));
274 struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info)); 285 struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
275 int fp;
276 int ret; 286 int ret;
277 287
278 fp = open(filename, O_CREAT | O_RDWR, 0600);
279 if (fp < 0) {
280 free(root);
281 return NULL;
282 }
283 INIT_RADIX_TREE(&fs_info->cache_radix, GFP_KERNEL); 288 INIT_RADIX_TREE(&fs_info->cache_radix, GFP_KERNEL);
284 INIT_RADIX_TREE(&fs_info->pinned_radix, GFP_KERNEL); 289 INIT_RADIX_TREE(&fs_info->pinned_radix, GFP_KERNEL);
285 INIT_LIST_HEAD(&fs_info->trans); 290 INIT_LIST_HEAD(&fs_info->trans);