aboutsummaryrefslogtreecommitdiffstats
path: root/usr/df.c
blob: ad1a0000b0ff5e47b813bdd7ae1c184e46d61ebc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stat.h"
/* df: how much of the cart's battery-backed disk is left.
 * 256-byte blocks, 128 of them (32 KiB), 32 inodes - small enough that the
 * numbers are worth watching. */
void main(void) {
    unsigned char fs[4];
    unsigned int used;
    gfsstat(fs);
    used = (unsigned int)(fs[0] - fs[1]);
    puts("blocks  ");
    putu(used);
    putc('/');
    putu(fs[0]);
    puts(" used (");
    putu((unsigned int)used * 256 / 1024);
    puts("K of ");
    putu((unsigned int)fs[0] * 256 / 1024);
    puts("K)");
    nl();
    puts("inodes  ");
    putu((unsigned int)(fs[2] - fs[3]));
    putc('/');
    putu(fs[2]);
    puts(" used");
    nl();
}