if self.created:
return
# create sparse disk image
- cmd = "truncate %s -s %s" % (self.device, self.size)
- exec_cmd(cmd)
+ with open(self.device, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), self.size)
+
self.created = True
class DirectImageCreator(BaseImageCreator):
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
- exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024))
+ with open(rootfs, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), rootfs_size * 1024)
extra_imagecmd = "-i 8192"
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
- exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024))
+ with open(rootfs, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), rootfs_size * 1024)
label_str = ""
if self.label:
"""
Prepare an empty ext2/3/4 partition.
"""
- exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024))
+ with open(rootfs, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), rootfs_size * 1024)
extra_imagecmd = "-i 8192"
"""
Prepare an empty btrfs partition.
"""
- exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024))
+ with open(rootfs, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), rootfs_size * 1024)
label_str = ""
if self.label:
"""
path = "%s/fs.%s" % (cr_workdir, self.fstype)
- exec_cmd("truncate %s -s %d" % (path, self.size * 1024))
+ with open(path, 'w') as sparse:
+ os.ftruncate(sparse.fileno(), self.size * 1024)
import uuid
label_str = ""