}
image_root = btrfs_mksubvol(root, subvol_name,
- CONV_IMAGE_SUBVOL_OBJECTID);
+ CONV_IMAGE_SUBVOL_OBJECTID, true);
if (!image_root) {
error("unable to link subvolume %s", subvol_name);
goto fail;
#ifndef __BTRFS_CTREE_H__
#define __BTRFS_CTREE_H__
+#include <stdbool.h>
+
#if BTRFS_FLAT_INCLUDES
#include "list.h"
#include "kerncompat.h"
int btrfs_mkdir(struct btrfs_trans_handle *trans, struct btrfs_root *root,
char *name, int namelen, u64 parent_ino, u64 *ino, int mode);
struct btrfs_root *btrfs_mksubvol(struct btrfs_root *root, const char *base,
- u64 root_objectid);
+ u64 root_objectid, bool convert);
/* file.c */
int btrfs_get_extent(struct btrfs_trans_handle *trans,
}
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;
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;