FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 05-09-2011, 07:00 PM
Will Woods
 
Default storage: add SparseFileDevice

Works just like FileDevice, but uses os.ftruncate to create the file
rather than writing zeroes. Unsuitable for swap files but useful for
other things, like making disk images.
---
pyanaconda/storage/devices.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 0eca0a9..dbaf3cd 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -3470,6 +3470,18 @@ class FileDevice(StorageDevice):
os.unlink(self.path)


+class SparseFileDevice(FileDevice):
+ """A sparse file on a filesystem.
+ This exists for sparse disk images."""
+ _type = "sparse file"
+ def _create(self, w):
+ """Create a sparse file."""
+ log_method_call(self, self.name, status=self.status)
+ fd = os.open(self.path, os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
+ os.ftruncate(fd, 1024*1024*self.size)
+ os.close(fd)
+
+
class DirectoryDevice(FileDevice):
""" A directory on a filesystem.

--
1.7.5.1

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

Thread Tools




All times are GMT. The time now is 04:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org