UNIX Free Pascal


.


13.34. df.

uses linux;

 

var s:string;

p:statfs;

i,k: word;

fd:text;

buf:array[1..1000]of char;

pol:boolean;

var

size:array[1..3] of double;

sizepow:array[1..3] of integer;

const

letters:array [0..3] of char=('b','K','M','G');

 

function point_Mount(var f:string):string;

var str:string;j,k:integer;flag:boolean;

begin

str:='';

k:=0;

flag:=false;

for j:=1 to length(f) do

begin

if f[j]=' ' then begin flag:=true;inc(k);end;

if (flag=true)and(k=1)then

begin

str:=str+f[j];

end;

end;

delete(str,1,1);

point_Mount:=str;

end;

 

 

begin

assign(fd,'/etc/mtab');

reset(fd);

pol:=true;

 

Writeln(' ࠠ 𠠠 렠 򠠠 % ');

 

while not eof(fd) do

begin

readln(fd,s);

 

pol:=fsstat(point_Mount(s),p);

if (pol)and(p.blocks<>0) then

begin

for i:=1 to length(s) do

begin

write(s[i]);

if s[i]=' ' then break;

end;

for k:=i to 1 do

write(' ');

size[1]:=1.*p.blocks*p.bsize;

size[2]:=1.*(p.blocks-p.bavail)*p.bsize;

size[3]:=1.*p.bavail*p.bsize;

for i:=1 to 3 do

begin

sizepow[i]:=0;

while size[i]>1024 do

begin

size[i]:=size[i]/1024;

inc(sizepow[i]);

end;

end;

writeln(size[1]:15:1,letters[sizepow[1]],{ }

size[2]:10:1,letters[sizepow[2]], { }

 

size[3]:10:1,letters[sizepow[3]], { }

' ',((p.blocks-p.bavail)*100/p.blocks):4:0,'% ', { }

' ',point_Mount(s)); {}

end

end;

close(fd);

end.

 

 




- -  - -  - -