[LTP] [PATCH] mkswap: make the test device size is aligned to pagesize

Cyril Hrubis
2016-08-18T11:33:39Z

Hi!
> Ok, this sounds better. I misunderstand you point at first.
>
> As this we can get the right(aligned) size of the device by add:
>
> # cat mkswap01.sh
> ...
> setup()
> {
> ...
>
> # Here get the size of the device and align it down to be the
> # multiple of $PAGE_SIZE and use that as the size for testing.
> device_real=`blockdev --getsize64 $TST_DEVICE`
> device_resi=$((${device_real} % ${PAGE_SIZE}))
>
> DEVICE_SIZE=$(((${device_real} - ${device_resi})/1024))

You can also use and integer division, which is a bit shorter:

DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))