[PATCH] Fix sparse file size off-by-one error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# HG changeset patch
# User john.levon@xxxxxxx
# 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@xxxxxxx>

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)

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux