summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-23 17:35:05 +0200
committerDavid Sterba <dsterba@suse.com>2016-08-24 14:37:36 +0200
commit411de0cf4a25346439baf4f670660982f9914d17 (patch)
tree691e682de02f1130a1401e6db20160a0a994bf2b /btrfs-convert.c
parentf507d20d2f12d5bc0b850000a413dba11f9e1c9e (diff)
btrfs-progs: convert: move convert_insert_dirent
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r--btrfs-convert.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 3f7e07d3..b8684792 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -144,6 +144,35 @@ static int intersect_with_sb(u64 bytenr, u64 num_bytes)
return 0;
}
+static int convert_insert_dirent(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ const char *name, size_t name_len,
+ u64 dir, u64 objectid,
+ u8 file_type, u64 index_cnt,
+ struct btrfs_inode_item *inode)
+{
+ int ret;
+ u64 inode_size;
+ struct btrfs_key location = {
+ .objectid = objectid,
+ .offset = 0,
+ .type = BTRFS_INODE_ITEM_KEY,
+ };
+
+ ret = btrfs_insert_dir_item(trans, root, name, name_len,
+ dir, &location, file_type, index_cnt);
+ if (ret)
+ return ret;
+ ret = btrfs_insert_inode_ref(trans, root, name, name_len,
+ objectid, dir, index_cnt);
+ if (ret)
+ return ret;
+ inode_size = btrfs_stack_inode_size(inode) + name_len * 2;
+ btrfs_set_stack_inode_size(inode, inode_size);
+
+ return 0;
+}
+
/*
* Open Ext2fs in readonly mode, read block allocation bitmap and
* inode bitmap into memory.
@@ -291,35 +320,6 @@ static void ext2_close_fs(struct btrfs_convert_context *cctx)
ext2fs_close(cctx->fs_data);
}
-static int convert_insert_dirent(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- const char *name, size_t name_len,
- u64 dir, u64 objectid,
- u8 file_type, u64 index_cnt,
- struct btrfs_inode_item *inode)
-{
- int ret;
- u64 inode_size;
- struct btrfs_key location = {
- .objectid = objectid,
- .offset = 0,
- .type = BTRFS_INODE_ITEM_KEY,
- };
-
- ret = btrfs_insert_dir_item(trans, root, name, name_len,
- dir, &location, file_type, index_cnt);
- if (ret)
- return ret;
- ret = btrfs_insert_inode_ref(trans, root, name, name_len,
- objectid, dir, index_cnt);
- if (ret)
- return ret;
- inode_size = btrfs_stack_inode_size(inode) + name_len * 2;
- btrfs_set_stack_inode_size(inode, inode_size);
-
- return 0;
-}
-
struct dir_iterate_data {
struct btrfs_trans_handle *trans;
struct btrfs_root *root;