diff options
author | Yingyi Luo <yingyil@google.com> | 2017-09-15 11:17:31 -0700 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-10-06 13:23:37 +0200 |
commit | fe667f6e7d0a3215bf671bfd70b0eb18d6e9c1a6 (patch) | |
tree | 2e6eb8bcb44a2985707a0f0496a08a644920494a /inode.c | |
parent | 8a820b57656c1a062c6445f872a9169fa0d9b381 (diff) |
btrfs-progs: add a parameter to btrfs_mksubvol
A convert parameter is added as a flag to indicate if btrfs_mksubvol()
is used for btrfs-convert. The change cascades down to the callchain.
Signed-off-by: Yingyi Luo <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'inode.c')
-rw-r--r-- | inode.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -573,7 +573,8 @@ out: } struct btrfs_root *btrfs_mksubvol(struct btrfs_root *root, - const char *base, u64 root_objectid) + const char *base, u64 root_objectid, + bool convert) { struct btrfs_trans_handle *trans; struct btrfs_fs_info *fs_info = root->fs_info; @@ -639,16 +640,21 @@ struct btrfs_root *btrfs_mksubvol(struct btrfs_root *root, key.type = BTRFS_ROOT_ITEM_KEY; memcpy(buf, base, len); - for (i = 0; i < 1024; i++) { - ret = btrfs_insert_dir_item(trans, root, buf, len, - dirid, &key, BTRFS_FT_DIR, index); - if (ret != -EEXIST) - break; - len = snprintf(buf, ARRAY_SIZE(buf), "%s%d", base, i); - if (len < 1 || len > BTRFS_NAME_LEN) { - ret = -EINVAL; - break; + if (convert) { + for (i = 0; i < 1024; i++) { + ret = btrfs_insert_dir_item(trans, root, buf, len, + dirid, &key, BTRFS_FT_DIR, index); + if (ret != -EEXIST) + break; + len = snprintf(buf, ARRAY_SIZE(buf), "%s%d", base, i); + if (len < 1 || len > BTRFS_NAME_LEN) { + ret = -EINVAL; + break; + } } + } else { + ret = btrfs_insert_dir_item(trans, root, buf, len, dirid, &key, + BTRFS_FT_DIR, index); } if (ret) goto fail; |