[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 1228360958 28800
# Node ID d8591178ebfca87835c7c5181cd96fde303444c9
# Parent  a16f24e020cec71d5d61661a2a85e7e241ffe0be
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,8 +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.write(fd, '\x00')
+                os.ftruncate(fd, dst_siz)
                 os.close(fd)
             else:
                 design.clone_bs = 1024*1024*10
diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
--- a/virtinst/VirtualDisk.py
+++ b/virtinst/VirtualDisk.py
@@ -488,8 +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.write(fd, '\x00')
+                        os.ftruncate(fd, size_bytes)
                         if progresscb:
                             progresscb.update(self.size)
                     else:

_______________________________________________
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