[PATCH 1/2] FileDevice._create: don't alloc memory equal to file size, close fd

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

 



Write the new file out in 1k blocks of zeroes.
---
 pyanaconda/storage/devices.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 51f2a13..0eca0a9 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -3458,9 +3458,11 @@ class FileDevice(StorageDevice):
     def _create(self, w):
         """ Create the device. """
         log_method_call(self, self.name, status=self.status)
-        fd = os.open(self.path, os.O_RDWR)
-        buf = '\0' * 1024 * 1024 * self.size
-        os.write(fd, buf)
+        fd = os.open(self.path, os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
+        buf = "\0" * 1024 * 1024
+        for n in range(self.size):
+            os.write(fd, buf)
+        os.close(fd)
 
     def _destroy(self):
         """ Destroy the device. """
-- 
1.7.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


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