Re: [PATCH] Provide a common block device size utility for Solaris & Linux

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

 



On Wed, Dec 03, 2008 at 09:37:57AM +0000, Daniel P. Berrange wrote:

> > +def blkdev_size(path):
> > +    if platform.system() == 'SunOS':
> > +        return os.stat(path)[stat.ST_SIZE]
> > +    else:
> > +        dummy, msg = commands.getstatusoutput('fdisk -s %s' % path)
> > +        # check
> > +        if msg.isdigit() == False:
> > +            lines = msg.splitlines()
> > +            # retry eg. for the GPT disk
> > +            msg = lines[len(lines)-1]
> > +        return (int(msg) * 1024)
> 
> 
> ACK, to the general idea of adding a common routine. The original Linux
> impl was kind of crazy. We could get a single portable impl for all
> OS by using seek(), which is how libvirt does it in its storage code.

Quite honestly, I wasn't entirely sure why you're using fdisk. But if
you don't need to, why use lseek() when os.stat() does the job?

regards
john

_______________________________________________
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