summaryrefslogtreecommitdiff
path: root/morphlib/writeexts.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-02-07 11:27:52 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-02-07 11:27:52 +0000
commit4a2578e39c8074bf9fb75870a045da88ffd6e299 (patch)
tree906b3f4b863d2064b778ccef30d86f473063fd47 /morphlib/writeexts.py
parent55c1922f52cff88ec1c08f350cab88e8a2957322 (diff)
downloadmorph-4a2578e39c8074bf9fb75870a045da88ffd6e299.tar.gz
Create hole in-process without executing dd(1)
Suggested-By: Richard Maw
Diffstat (limited to 'morphlib/writeexts.py')
-rwxr-xr-xmorphlib/writeexts.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py
index 23473021..676a9d22 100755
--- a/morphlib/writeexts.py
+++ b/morphlib/writeexts.py
@@ -70,13 +70,10 @@ class WriteExtension(cliapp.Application):
'''Create a raw disk image.'''
self.status(msg='Creating empty disk image')
- cliapp.runcmd(
- ['dd',
- 'if=/dev/zero',
- 'of=' + filename,
- 'bs=1',
- 'seek=%d' % size,
- 'count=0'])
+ with open(filename, 'wb') as f:
+ if size > 0:
+ f.seek(size-1)
+ f.write('\0')
def mkfs_btrfs(self, location):
'''Create a btrfs filesystem on the disk.'''