diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/imager/direct.py | 5 | ||||
| -rw-r--r-- | scripts/lib/wic/partition.py | 15 |
2 files changed, 13 insertions, 7 deletions
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py index edf5e5d221..2bedef08d6 100644 --- a/scripts/lib/wic/imager/direct.py +++ b/scripts/lib/wic/imager/direct.py | |||
| @@ -56,8 +56,9 @@ class DiskImage(): | |||
| 56 | if self.created: | 56 | if self.created: |
| 57 | return | 57 | return |
| 58 | # create sparse disk image | 58 | # create sparse disk image |
| 59 | cmd = "truncate %s -s %s" % (self.device, self.size) | 59 | with open(self.device, 'w') as sparse: |
| 60 | exec_cmd(cmd) | 60 | os.ftruncate(sparse.fileno(), self.size) |
| 61 | |||
| 61 | self.created = True | 62 | self.created = True |
| 62 | 63 | ||
| 63 | class DirectImageCreator(BaseImageCreator): | 64 | class DirectImageCreator(BaseImageCreator): |
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index 90f65a1e39..89c33ab8b7 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
| @@ -217,7 +217,8 @@ class Partition(): | |||
| 217 | msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ | 217 | msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ |
| 218 | (extra_blocks, self.mountpoint, rootfs_size)) | 218 | (extra_blocks, self.mountpoint, rootfs_size)) |
| 219 | 219 | ||
| 220 | exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024)) | 220 | with open(rootfs, 'w') as sparse: |
| 221 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) | ||
| 221 | 222 | ||
| 222 | extra_imagecmd = "-i 8192" | 223 | extra_imagecmd = "-i 8192" |
| 223 | 224 | ||
| @@ -250,7 +251,8 @@ class Partition(): | |||
| 250 | msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ | 251 | msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ |
| 251 | (extra_blocks, self.mountpoint, rootfs_size)) | 252 | (extra_blocks, self.mountpoint, rootfs_size)) |
| 252 | 253 | ||
| 253 | exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024)) | 254 | with open(rootfs, 'w') as sparse: |
| 255 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) | ||
| 254 | 256 | ||
| 255 | label_str = "" | 257 | label_str = "" |
| 256 | if self.label: | 258 | if self.label: |
| @@ -305,7 +307,8 @@ class Partition(): | |||
| 305 | """ | 307 | """ |
| 306 | Prepare an empty ext2/3/4 partition. | 308 | Prepare an empty ext2/3/4 partition. |
| 307 | """ | 309 | """ |
| 308 | exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024)) | 310 | with open(rootfs, 'w') as sparse: |
| 311 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) | ||
| 309 | 312 | ||
| 310 | extra_imagecmd = "-i 8192" | 313 | extra_imagecmd = "-i 8192" |
| 311 | 314 | ||
| @@ -322,7 +325,8 @@ class Partition(): | |||
| 322 | """ | 325 | """ |
| 323 | Prepare an empty btrfs partition. | 326 | Prepare an empty btrfs partition. |
| 324 | """ | 327 | """ |
| 325 | exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024)) | 328 | with open(rootfs, 'w') as sparse: |
| 329 | os.ftruncate(sparse.fileno(), rootfs_size * 1024) | ||
| 326 | 330 | ||
| 327 | label_str = "" | 331 | label_str = "" |
| 328 | if self.label: | 332 | if self.label: |
| @@ -383,7 +387,8 @@ class Partition(): | |||
| 383 | """ | 387 | """ |
| 384 | path = "%s/fs.%s" % (cr_workdir, self.fstype) | 388 | path = "%s/fs.%s" % (cr_workdir, self.fstype) |
| 385 | 389 | ||
| 386 | exec_cmd("truncate %s -s %d" % (path, self.size * 1024)) | 390 | with open(path, 'w') as sparse: |
| 391 | os.ftruncate(sparse.fileno(), self.size * 1024) | ||
| 387 | 392 | ||
| 388 | import uuid | 393 | import uuid |
| 389 | label_str = "" | 394 | label_str = "" |
