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 > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 03-11-2009, 12:19 AM
David Lehman
 
Default On existing ext2/ext3 filesystems, init size and targetSize.

On Tue, 2009-03-10 at 14:35 -1000, David Cantrell wrote:
> On existing ext2 and ext3 filesystems, initialize our size property
> to the size of the filesystem in megabytes. Initialize targetSize
> to the size in megabytes of the used space. Use dumpe2fs to collect
> size information as the size does not necessarily match with the
> underlying StorageDevice this format sits on.

Just spitting out ideas here...

It would be cool to move this into a function -- then if the function
raises an exception we could catch it and mark the fs as not resizable.

Dave

> ---
> storage/formats/fs.py | 35 +++++++++++++++++++++++++++++++++++
> 1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/storage/formats/fs.py b/storage/formats/fs.py
> index 0c66d38..7579122 100644
> --- a/storage/formats/fs.py
> +++ b/storage/formats/fs.py
> @@ -26,6 +26,7 @@
> - migration
> - bug 472127: allow creation of tmpfs filesystems (/tmp, /var/tmp, &c)
> """
> +import math
> import os
> import isys
>
> @@ -704,6 +705,40 @@ class Ext2FS(FS):
> _migratefs = "tune2fs"
> _defaultMigrateOptions = ["-j"]
>
> + def __init__(self, *args, **kwargs):
> + FS.__init__(self, *args, **kwargs)
> +
> + # get size of existing filesystem
> + if self.exists:
> + blockCount = None
> + blockSize = None
> + freeBlocks = None
> +
> + buf = iutil.execWithCapture('dumpe2fs', ['-h', self.device],
> + stderr="/dev/tty5")
> +
> + for line in buf.splitlines():
> + tmp = line.split(' ')
> +
> + if line.startswith('Block count:'):
> + blockCount = long(tmp[len(tmp) - 1])
> + elif line.startswith('Block size:'):
> + blockSize = long(tmp[len(tmp) - 1])
> + elif line.startswith('Free blocks:'):
> + freeBlocks = long(tmp[len(tmp) - 1])
> +
> + if blockCount and blockSize and freeBlocks:
> + break
> +
> + total = blockCount * blockSize
> + free = freeBlocks * blockSize
> +
> + # report current size as megabytes
> + self._size = total / 1024.0 / 1024.0
> +
> + # set target size to used space
> + self.targetSize = math.ceil(total - free) / 1024.0 / 1024.0
> +
> @property
> def minSize(self):
> """ Minimum size for this filesystem in MB. """

_______________________________________________
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 01:36 AM.

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