mkfs_cfg.stripesize = blocksize;
mkfs_cfg.features = features;
/* New convert need these space */
- mkfs_cfg.fs_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
- mkfs_cfg.chunk_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
- *(mkfs_cfg.fs_uuid) = '\0';
- *(mkfs_cfg.chunk_uuid) = '\0';
+ memset(mkfs_cfg.chunk_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
+ memset(mkfs_cfg.fs_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
ret = make_btrfs(fd, &mkfs_cfg, &cctx);
if (ret) {
}
mkfs_cfg.label = label;
- mkfs_cfg.fs_uuid = fs_uuid;
+ memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));
memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
mkfs_cfg.num_bytes = dev_block_count;
mkfs_cfg.nodesize = nodesize;
struct btrfs_super_block *super = (struct btrfs_super_block *)super_buf;
int ret;
- /*
- * We rely on cfg->chunk_uuid and cfg->fs_uuid to pass uuid
- * for other functions.
- * Caller must allocate space for them
- */
- BUG_ON(!cfg->chunk_uuid || !cfg->fs_uuid);
memset(super_buf, 0, BTRFS_SUPER_INFO_SIZE);
cfg->num_bytes = round_down(cfg->num_bytes, cfg->sectorsize);
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super->fsid) != 0) {
error("cound not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;
unsigned char chunk_uuid[BTRFS_UUID_SIZE];
int ret;
- /* We rely on cfg->fs_uuid and chunk_uuid to fsid and chunk uuid */
- BUG_ON(!cfg->fs_uuid || !cfg->chunk_uuid);
ret = uuid_parse(cfg->fs_uuid, fsid);
if (ret)
return -EINVAL;
memset(&super, 0, sizeof(super));
num_bytes = (cfg->num_bytes / cfg->sectorsize) * cfg->sectorsize;
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super.fsid) != 0) {
error("cannot not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;