mirror of
https://git.yoctoproject.org/poky
synced 2026-09-25 07:36:23 +02:00
wic: call os.ftruncate instead of running truncate
Replaced running of truncate utility with the standard library call os.ftruncate (From OE-Core rev: 1ba6101ceaee354816e690d44bc9a5dd8dcf4011) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
eb345ca720
commit
c8669749e3
@@ -56,8 +56,9 @@ class DiskImage():
|
|||||||
if self.created:
|
if self.created:
|
||||||
return
|
return
|
||||||
# create sparse disk image
|
# create sparse disk image
|
||||||
cmd = "truncate %s -s %s" % (self.device, self.size)
|
with open(self.device, 'w') as sparse:
|
||||||
exec_cmd(cmd)
|
os.ftruncate(sparse.fileno(), self.size)
|
||||||
|
|
||||||
self.created = True
|
self.created = True
|
||||||
|
|
||||||
class DirectImageCreator(BaseImageCreator):
|
class DirectImageCreator(BaseImageCreator):
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ class Partition():
|
|||||||
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
|
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
|
||||||
(extra_blocks, self.mountpoint, rootfs_size))
|
(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"
|
extra_imagecmd = "-i 8192"
|
||||||
|
|
||||||
@@ -250,7 +251,8 @@ class Partition():
|
|||||||
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
|
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
|
||||||
(extra_blocks, self.mountpoint, rootfs_size))
|
(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 = ""
|
label_str = ""
|
||||||
if self.label:
|
if self.label:
|
||||||
@@ -305,7 +307,8 @@ class Partition():
|
|||||||
"""
|
"""
|
||||||
Prepare an empty ext2/3/4 partition.
|
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"
|
extra_imagecmd = "-i 8192"
|
||||||
|
|
||||||
@@ -322,7 +325,8 @@ class Partition():
|
|||||||
"""
|
"""
|
||||||
Prepare an empty btrfs partition.
|
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 = ""
|
label_str = ""
|
||||||
if self.label:
|
if self.label:
|
||||||
@@ -383,7 +387,8 @@ class Partition():
|
|||||||
"""
|
"""
|
||||||
path = "%s/fs.%s" % (cr_workdir, self.fstype)
|
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
|
import uuid
|
||||||
label_str = ""
|
label_str = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user