libgpg-error: fix riscv64
[openadk.git] / package / sash / src / df.c
blob8f2c05533e11c30bceecdab791839b11cac8e8ba
1 /* df.c:
3 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
11 #include "sash.h"
13 #include <fcntl.h>
14 #include <sys/types.h>
15 #include <sys/vfs.h>
17 #include <sys/stat.h>
18 #include <dirent.h>
19 #include <pwd.h>
20 #include <grp.h>
21 #include <time.h>
22 #include <linux/major.h>
23 #ifdef __UC_LIBC__
24 #include <linux/types.h>
25 #endif
26 #include <sys/time.h>
27 #include <sys/param.h>
28 #include <errno.h>
30 void
31 do_df(int argc, char * argv[])
33 char * name;
34 struct statfs stbuf;
36 #if 0
37 fclose(stdin);
38 #endif
40 if (argc<2)
41 name = "/";
42 else
43 name = argv[1];
45 if (statfs(name, &stbuf) == -1) {
46 printf("Unable to get disk space of %s: %s\n", name, strerror(errno));
47 return;
50 printf("Total Kbytes: %ld\n", (stbuf.f_bsize / 256) * (stbuf.f_blocks / 4));
51 printf("Free Kbytes: %ld\n", (stbuf.f_bsize / 256) * (stbuf.f_bfree / 4));
52 printf("Total nodes: %ld\n", stbuf.f_files);
53 printf("Free nodes: %ld\n", stbuf.f_ffree);