diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2014-08-27 17:14:13 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2014-08-27 17:14:13 +0200 |
commit | 727dd67821e4581e4b61b30b79ca47c5bffc8497 (patch) | |
tree | d5be61f067a42b2633ef148f416f138e7c2f7da2 /package/sash/src/df.c | |
parent | 683cf71a6ebccbd4f827ad4a6ac92dbbaf8f644d (diff) | |
parent | 008d0e157538e4a4c302dc79e6c28c9da615b527 (diff) |
Merge branch 'master' of git+ssh://openadk.org/git/openadk
Diffstat (limited to 'package/sash/src/df.c')
-rw-r--r-- | package/sash/src/df.c | 55 |
1 files changed, 55 insertions, 0 deletions
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 <kjahds@kjahds.com>, + * + * 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 <fcntl.h> +#include <sys/types.h> +#include <sys/vfs.h> + +#include <sys/stat.h> +#include <dirent.h> +#include <pwd.h> +#include <grp.h> +#include <time.h> +#include <linux/major.h> +#ifdef __UC_LIBC__ +#include <linux/types.h> +#endif +#include <sys/time.h> +#include <sys/param.h> +#include <errno.h> + +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); +} + |