[et-mgmt-tools] [PATCH] Fix sparse file size off-by-one error
john.levon at sun.com
john.levon at sun.com
Wed Dec 3 02:24:50 UTC 2008
# HG changeset patch
# User john.levon at sun.com
# Date 1228271065 28800
# Node ID ca3207be8b5da3d6f4f9f5432dfa819cfab173c8
# Parent 31aef21ff81fc33675c09ed0e03e152b963f5042
Fix sparse file size off-by-one error
The Solaris loopback driver (lofi) requires files be a multiple of
512-bytes in size. Sparse files created via lseek(f, size, 0) are
1 byte larger than what is being requested.
Signed-off-by: John Danielson <john.danielson at sun.com>
diff --git a/virtinst/CloneManager.py b/virtinst/CloneManager.py
--- a/virtinst/CloneManager.py
+++ b/virtinst/CloneManager.py
@@ -557,7 +557,7 @@ def _do_duplicate(design):
design.clone_bs = 4096
sparse_copy_mode = True
fd = os.open(dst_dev, os.O_WRONLY | os.O_CREAT)
- os.lseek(fd, dst_siz, 0)
+ os.lseek(fd, dst_siz - 1, 0)
os.write(fd, '\x00')
os.close(fd)
else:
diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
--- a/virtinst/VirtualDisk.py
+++ b/virtinst/VirtualDisk.py
@@ -488,7 +488,7 @@ class VirtualDisk(VirtualDevice):
try:
fd = os.open(self.path, os.O_WRONLY | os.O_CREAT)
if self.sparse:
- os.lseek(fd, size_bytes, 0)
+ os.lseek(fd, size_bytes -1, 0)
os.write(fd, '\x00')
if progresscb:
progresscb.update(self.size)
More information about the et-mgmt-tools
mailing list