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:
Ed Bartosh
2016-11-02 22:33:07 +02:00
committed by Richard Purdie
parent eb345ca720
commit c8669749e3
2 changed files with 13 additions and 7 deletions

View File

@@ -56,8 +56,9 @@ class DiskImage():
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):