diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-07 11:27:52 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-07 11:27:52 +0000 |
commit | 4a2578e39c8074bf9fb75870a045da88ffd6e299 (patch) | |
tree | 906b3f4b863d2064b778ccef30d86f473063fd47 /morphlib | |
parent | 55c1922f52cff88ec1c08f350cab88e8a2957322 (diff) | |
download | morph-4a2578e39c8074bf9fb75870a045da88ffd6e299.tar.gz |
Create hole in-process without executing dd(1)
Suggested-By: Richard Maw
Diffstat (limited to 'morphlib')
-rwxr-xr-x | morphlib/writeexts.py | 11 |
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.''' |