diff options
author | Jim Meyering <jim@meyering.net> | 1998-03-19 22:18:29 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1998-03-19 22:18:29 +0000 |
commit | 6ec5bace8a78667223737f5d332e64971b53e00a (patch) | |
tree | f7fe012a6b680f2b087b9e77cadd235c2fc5f154 /src | |
parent | b48e78e3b7b3a91b257f154106ddbabfaf3cb483 (diff) | |
download | coreutils-6ec5bace8a78667223737f5d332e64971b53e00a.tar.xz |
(show_dev): If fsu_bavail_top_bit_set is nonzero,
assume the original value corresponding to fsu_bavail was negative.
Diffstat (limited to 'src')
-rw-r--r-- | src/df.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -268,7 +268,9 @@ show_dev (const char *disk, const char *mount_point, const char *fstype) else { int w = human_readable_base ? 5 : 7; - char buf[3][LONGEST_HUMAN_READABLE + 1]; + char buf[2][LONGEST_HUMAN_READABLE + 1]; + char availbuf[LONGEST_HUMAN_READABLE + 2]; + char *avail; double blocks_percent_used; uintmax_t blocks_used; @@ -281,18 +283,31 @@ show_dev (const char *disk, const char *mount_point, const char *fstype) { blocks_used = fsu.fsu_blocks - fsu.fsu_bfree; blocks_percent_used = - (fsu.fsu_bfree < fsu.fsu_bavail ? -1 - : (blocks_used + fsu.fsu_bavail) == 0 ? 0 + ((fsu.fsu_bavail == -1 + || blocks_used + fsu.fsu_bavail == 0 + || (fsu.fsu_bavail_top_bit_set + ? blocks_used < - fsu.fsu_bavail + : fsu.fsu_bfree < fsu.fsu_bavail)) + ? -1 : blocks_used * 100.0 / (blocks_used + fsu.fsu_bavail)); } + avail = df_readable ((fsu.fsu_bavail_top_bit_set + ? - fsu.fsu_bavail + : fsu.fsu_bavail), + availbuf + 1, fsu.fsu_blocksize, + output_units, human_readable_base); + + if (fsu.fsu_bavail_top_bit_set) + *--avail = '-'; + printf (" %*s %*s %*s ", w, df_readable (fsu.fsu_blocks, buf[0], fsu.fsu_blocksize, output_units, human_readable_base), w, df_readable (blocks_used, buf[1], fsu.fsu_blocksize, output_units, human_readable_base), - w, df_readable (fsu.fsu_bavail, buf[2], fsu.fsu_blocksize, - output_units, human_readable_base)); + w, avail); + if (blocks_percent_used < 0) printf (" - "); else @@ -738,4 +753,3 @@ with the portable output format")); close_stdout (); exit (exit_status); } - |