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

Cyril Hrubis chrubis@suse.cz
Thu Aug 18 13:33:39 CEST 2016


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))

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list