FS#23300 - [AIF core] cleaner method for obtaining disk size

Attached to Project: Release Engineering
Opened by CalimeroTeknik (Calimero) - Wednesday, 16 March 2011, 19:10 GMT
Last edited by Gerardo Exequiel Pozzi (djgera) - Monday, 26 November 2012, 04:43 GMT
Task Type Bug Report
Category AIF
Status Closed
Assigned To No-one
Architecture All
Severity Very Low
Priority Normal
Reported Version 2010.05
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

The method to obtain the size of a block peripheral is currently parsing the output of fdisk.
In /usr/lib/aif/core/libs/lib-blockdevices-filesystems.sh, line 875:
bytes=$((`fdisk -l $1 2>/dev/null | sed -n '2p' | cut -d' ' -f5`))

When using a fork of AIF for my livecd, I figured out that if the locale is not English, this causes problems (returns nothing) and the installer crashes on an arithmetic syntax error.
The cause may be an insecable space or something, I don't know.

Anyway, parsing fdisk's output isn't careful, no matter how you consider it.

So I suggest to change line 875 of /usr/lib/aif/core/libs/lib-blockdevices-filesystems.sh to:
bytes=$(($(</sys/dev/block/$((16#$(stat -c %t $1))):$((16#$(stat -c %T $1)))/size)*512))

This doesn't depend on how fdisk's output is formatted, at least.
This task depends upon

Closed by  Gerardo Exequiel Pozzi (djgera)
Monday, 26 November 2012, 04:43 GMT
Reason for closing:  Deferred
Comment by Dieter Plaetinck (Dieter_be) - Monday, 01 August 2011, 07:49 GMT
Hmm, although we did refactor some size getting (see https://github.com/Dieterbe/aif/commit/048532662999a5f0909646f26f5368ddbf0558fa ) the offending code you mentioned is still there in get_blockdevice_size ()
Comment by Dieter Plaetinck (Dieter_be) - Sunday, 14 August 2011, 09:09 GMT
Hmm your suggested code hardcodes a 512B blocksize, I don't think that's good.
Comment by CalimeroTeknik (Calimero) - Sunday, 28 August 2011, 13:20 GMT
bytes=$(($(</sys/dev/block/$((16#$(stat -c %t $1))):$((16#$(stat -c %T $1)))/size)*$(blockdev --getss $1)))
can be used as well then.

Loading...