diff options
Diffstat (limited to 'df.c')
-rw-r--r-- | df.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -3,6 +3,7 @@ | |||
3 | #include <mntent.h> | 3 | #include <mntent.h> |
4 | #include <sys/stat.h> | 4 | #include <sys/stat.h> |
5 | #include <sys/vfs.h> | 5 | #include <sys/vfs.h> |
6 | #include <fstab.h> | ||
6 | 7 | ||
7 | const char df_usage[] = "df [filesystem ...]\n" | 8 | const char df_usage[] = "df [filesystem ...]\n" |
8 | "\n" | 9 | "\n" |
@@ -10,7 +11,7 @@ const char df_usage[] = "df [filesystem ...]\n" | |||
10 | 11 | ||
11 | 12 | ||
12 | static int | 13 | static int |
13 | df(const char * device, const char * mountPoint) | 14 | df(char* device, const char * mountPoint) |
14 | { | 15 | { |
15 | struct statfs s; | 16 | struct statfs s; |
16 | long blocks_used; | 17 | long blocks_used; |
@@ -25,6 +26,8 @@ df(const char * device, const char * mountPoint) | |||
25 | blocks_used = s.f_blocks - s.f_bfree; | 26 | blocks_used = s.f_blocks - s.f_bfree; |
26 | blocks_percent_used = (long) | 27 | blocks_percent_used = (long) |
27 | (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); | 28 | (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); |
29 | if ( strcmp(device, "/dev/root")==0) | ||
30 | device=(getfsfile ("/"))->fs_spec; | ||
28 | 31 | ||
29 | printf( | 32 | printf( |
30 | "%-20s %9ld %9ld %9ld %3ld%% %s\n", | 33 | "%-20s %9ld %9ld %9ld %3ld%% %s\n", |
@@ -75,7 +78,7 @@ df_main(int argc, char * * argv) | |||
75 | } | 78 | } |
76 | 79 | ||
77 | while ( (mountEntry = getmntent (mountTable))) { | 80 | while ( (mountEntry = getmntent (mountTable))) { |
78 | int status=df(mountEntry->mnt_fsname ,mountEntry->mnt_dir); | 81 | int status=df(mountEntry->mnt_fsname, mountEntry->mnt_dir); |
79 | if (status) | 82 | if (status) |
80 | return status; | 83 | return status; |
81 | } | 84 | } |
@@ -129,3 +132,5 @@ findMountPoint(const char* name, const char* table) | |||
129 | endmntent(mountTable); | 132 | endmntent(mountTable); |
130 | return mountEntry; | 133 | return mountEntry; |
131 | } | 134 | } |
135 | |||
136 | |||