diff --git a/src/df.c b/src/df.c index b803fc73b..8a0293ca9 100644 --- a/src/df.c +++ b/src/df.c @@ -127,6 +127,7 @@ static bool print_grand_total; /* Grand total data. */ static struct fs_usage grand_fsu; +static bool grand_fsu_fsu_files_top_bit_set; /* Display modes. */ enum @@ -993,8 +994,11 @@ get_field_values (struct field_values_t *bv, static void add_to_grand_total (struct field_values_t *bv, struct field_values_t *iv) { - if (known_value (iv->total)) - grand_fsu.fsu_files += iv->total; + if (known_value (iv->total) && known_value (iv->available_to_root)) + add_uint_with_neg_flag (&grand_fsu.fsu_files, + &grand_fsu_fsu_files_top_bit_set, + iv->total - iv->available_to_root, + iv->total < iv->available_to_root); if (known_value (iv->available)) grand_fsu.fsu_ffree += iv->available; @@ -1860,6 +1864,9 @@ main (int argc, char **argv) NULL, NULL, NULL, false, false, &grand_fsu, false); print_table (); + + if (print_grand_total & grand_fsu_fsu_files_top_bit_set) + die (EXIT_FAILURE, 0, "iused < 0"); } else {