OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [userland/] [sash/] [df.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* df.c:
2
 *
3
 * Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
4
 *
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
 */
10
 
11
#include "sash.h"
12
 
13
#include <linux/autoconf.h>
14
 
15
#include <fcntl.h>
16
#include <sys/types.h>
17
#include <sys/vfs.h>
18
 
19
#include <sys/stat.h>
20
#include <dirent.h>
21
#include <pwd.h>
22
#include <grp.h>
23
#include <time.h>
24
#include <linux/major.h>
25
#include <linux/types.h>
26
#include <sys/time.h>
27
#include <asm/param.h>
28
#include <errno.h>
29
 
30
void
31
do_df(int argc, char * argv[])
32
{
33
        char * name;
34
        struct statfs stbuf;
35
 
36
#if 0
37
        fclose(stdin);
38
#endif
39
 
40
        if (argc<2)
41
                name = "/";
42
        else
43
                name = argv[1];
44
 
45
        if (statfs(name, &stbuf) == -1) {
46
                printf("Unable to get disk space of %s: %s\n", name, strerror(errno));
47
                return;
48
        }
49
 
50
        printf("Total bytes: %ld\n", stbuf.f_bsize * stbuf.f_blocks);
51
        printf("Free bytes: %ld\n", stbuf.f_bsize * stbuf.f_bfree);
52
        printf("Total nodes: %ld\n", stbuf.f_files);
53
        printf("Free nodes: %ld\n", stbuf.f_ffree);
54
}
55
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.