#!/bin/sh
#
# Copyright (C) 1995,1996  Lars Berntzon
#
dmesg | 
sed 's/<.*cyl/<cyl/' | $AWK '
$0 ~ /^avail mem =/ && found == 1 { exit }
!/<.*cyl.*>/ { next }
{
    split($0, arr1, "<")
    split(arr1[2], arr2, ">")
    split(arr2[1], cols, FS)
    #print cols[1] " - " cols[2] " - " cols[3] " - " cols[4]

    if (cols[1] == "cyl" && cols[3] == "alt" && cols[5] == "hd" && cols[7] == "sec") {
	print int(cols[2] * cols[6] * cols[8] * 512 / 1024 / 1024 + 0.5 )
    }
    else {
	print "unknown format: ", $0
    }
    found=1
}
'
