9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] How do I find free disk space?
@ 2002-06-14 17:10 Blake McBride
  2002-06-15 15:14 ` FJ Ballesteros
  0 siblings, 1 reply; 3+ messages in thread
From: Blake McBride @ 2002-06-14 17:10 UTC (permalink / raw)
  To: 9fans

Greetings,

How can I find the amount of used and free disk / file system space
ala df?  I am using a standalone system with a KFS file system.

Thanks.

Blake McBride
blake@integra-online.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] How do I find free disk space?
  2002-06-14 17:10 [9fans] How do I find free disk space? Blake McBride
@ 2002-06-15 15:14 ` FJ Ballesteros
  0 siblings, 0 replies; 3+ messages in thread
From: FJ Ballesteros @ 2002-06-15 15:14 UTC (permalink / raw)
  To: 9fans

I think rsc sent this to 9fans

#!/bin/rc
# df

rfork e

fn h2d {
        echo 'ibase=16;' print `{echo $1|tr a-z A-Z} |bc
}

fn swap {
        echo $1 | sed 's/(..)(..)(..)(..)/\4\3\2\1/'
}

fn df {
        echo -n $1 ''
        blksz=`{xd -c $1 |grep 110 |sed 1q |
                sed 's/^.......   (.)  (.)  (.)  (.).*/\1\2\3\4/'}
        info=`{dd -bs $blksz -iseek 1 -count 1 < $1 >[2]/dev/null | xd
-l | sed
1q}
        total=$info(3)
        free=$info(4)
        if(~ $cputype 386) {
                total=`{swap $total}
                free=`{swap $free}
        }
        total=`{h2d $total}
        free=`{h2d $free}

        totalk=`{hoc -e $total^'*'^$blksz}
        freek=`{hoc -e $free^'*'^$blksz}
        totalk=`{hoc -e $totalk^'/'^1024}
        freek=`{hoc -e $freek^'/'^1024}

        echo $free / $total '*' $blksz '=' $freek / $totalk
}

disk=`{ls /dev/sd??/fs  >[2]/dev/null}
if(~ $#disk 0) {
        echo no disk found
        exit 'no disk'
}

for(i in $disk)
        df $i


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] How do I find free disk space?
@ 2002-06-14 17:31 Russ Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Russ Cox @ 2002-06-14 17:31 UTC (permalink / raw)
  To: 9fans

g% cat /bin/df
#!/bin/rc

rfork e

fn h2d {
	echo 'ibase=16;' print `{echo $1|tr a-z A-Z} |bc
}

fn swap {
	echo $1 | sed 's/(..)(..)(..)(..)/\4\3\2\1/'
}

fn df {
	echo -n $1 ''
	blksz=`{xd -c $1 |grep 110 |sed 1q |
		sed 's/^.......   (.)  (.)  (.)  (.).*/\1\2\3\4/'}
	info=`{dd -bs $blksz -iseek 1 -count 1 < $1 >[2]/dev/null | xd -l | sed 1q}
	total=$info(3)
	free=$info(4)
	if(~ $cputype 386) {
		total=`{swap $total}
		free=`{swap $free}
	}
	total=`{h2d $total}
	free=`{h2d $free}

	totalb=`{hoc -e $total^'*'^$blksz}
	freeb=`{hoc -e $free^'*'^$blksz}
	echo $free / $total '*' $blksz '=' $freeb / $totalb
}

disk=`{ls /dev/sd??/fs}
if(~ $#disk 0) {
	echo no disk found
	exit 'no disk'
}

for(i in $disk)
	df $i
g%



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-15 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-14 17:10 [9fans] How do I find free disk space? Blake McBride
2002-06-15 15:14 ` FJ Ballesteros
2002-06-14 17:31 Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).