From 8e2707b81b0c90295c9fdf92a576925442d22147 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 20 Aug 2014 21:11:13 +0200 Subject: add sash, simpleinit and a uclibc config for nonmmu case --- package/sash/src/df.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 package/sash/src/df.c (limited to 'package/sash/src/df.c') diff --git a/package/sash/src/df.c b/package/sash/src/df.c new file mode 100644 index 000000000..99ac2217e --- /dev/null +++ b/package/sash/src/df.c @@ -0,0 +1,55 @@ +/* df.c: + * + * Copyright (C) 1998 Kenneth Albanowski , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "sash.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#ifdef __UC_LIBC__ +#include +#endif +#include +#include +#include + +void +do_df(int argc, char * argv[]) +{ + char * name; + struct statfs stbuf; + +#if 0 + fclose(stdin); +#endif + + if (argc<2) + name = "/"; + else + name = argv[1]; + + if (statfs(name, &stbuf) == -1) { + printf("Unable to get disk space of %s: %s\n", name, strerror(errno)); + return; + } + + printf("Total Kbytes: %ld\n", (stbuf.f_bsize / 256) * (stbuf.f_blocks / 4)); + printf("Free Kbytes: %ld\n", (stbuf.f_bsize / 256) * (stbuf.f_bfree / 4)); + printf("Total nodes: %ld\n", stbuf.f_files); + printf("Free nodes: %ld\n", stbuf.f_ffree); +} + -- cgit v1.2.3