summaryrefslogtreecommitdiff
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
commit439623c9ffbd56fb1241265321e9a2dd8e1437f5 (patch)
tree37826eb7efb7f7eeb9512c6424815918720edd6d
parentc7e6642d855283b85182097b24226e78aa78e199 (diff)
downloaddefinitions-439623c9ffbd56fb1241265321e9a2dd8e1437f5.tar.gz
Create hole in-process without executing dd(1)
Suggested-By: Richard Maw
-rwxr-xr-xwriteexts.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/writeexts.py b/writeexts.py
index 23473021..676a9d22 100755
--- a/writeexts.py
+++ b/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.'''