summaryrefslogtreecommitdiff
path: root/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-21 11:13:29 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-21 11:13:29 -0400
commit8a2c8123c5ee5b09f3b8265e5e6db2e687d29e99 (patch)
tree4e608f93d52d4df45d20e3482ac8acaf02244118 /disk-io.c
parentb55672a2a1694d27b73f8233efcc1d986bfc797a (diff)
create a root dir in mkfs
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/disk-io.c b/disk-io.c
index 0322c551..05637f9f 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -267,19 +267,24 @@ static int find_and_setup_root(struct btrfs_super_block *super,
struct btrfs_root *open_ctree(char *filename, struct btrfs_super_block *super)
{
+ int fp;
+
+ fp = open(filename, O_CREAT | O_RDWR, 0600);
+ if (fp < 0) {
+ return NULL;
+ }
+ return open_ctree_fd(fp, super);
+}
+
+struct btrfs_root *open_ctree_fd(int fp, struct btrfs_super_block *super)
+{
struct btrfs_root *root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root));
struct btrfs_root *inode_root = malloc(sizeof(struct btrfs_root));
struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
- int fp;
int ret;
- fp = open(filename, O_CREAT | O_RDWR, 0600);
- if (fp < 0) {
- free(root);
- return NULL;
- }
INIT_RADIX_TREE(&fs_info->cache_radix, GFP_KERNEL);
INIT_RADIX_TREE(&fs_info->pinned_radix, GFP_KERNEL);
INIT_LIST_HEAD(&fs_info->trans);