Some more patchelttes from Larry Doolittle.
[oweals/busybox.git] / df.c
diff --git a/df.c b/df.c
index 485076f90e863fe827f52f6470d865513a162620..df68744337e2ebf4adc52ad2c43e3fd7a7681cd6 100644 (file)
--- a/df.c
+++ b/df.c
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <mntent.h>
 #include <sys/vfs.h>
 #include <getopt.h>
@@ -59,7 +60,9 @@ static int do_df(char *device, const char *mount_point)
                if (strcmp(device, "/dev/root") == 0) {
                        /* Adjusts device to be the real root device,
                         * or leaves device alone if it can't find it */
-                       find_real_root_device_name( device);
+                       device = find_real_root_device_name(device);
+                       if(device==NULL)
+                               return FALSE;
                }
 #ifdef BB_FEATURE_HUMAN_READABLE
                switch (df_disp_hr) {
@@ -73,18 +76,22 @@ static int do_df(char *device, const char *mount_point)
                                base = 0;
                }
                printf("%-20s %9s ", device,
-                          make_human_readable_str(s.f_blocks * (s.f_bsize/KILOBYTE), base));
+                          make_human_readable_str((unsigned long)(s.f_blocks * 
+                                          (s.f_bsize/(double)KILOBYTE)), base));
                printf("%9s ",
-                          make_human_readable_str((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base));
+                          make_human_readable_str((unsigned long)(
+                                          (s.f_blocks - s.f_bfree) * 
+                                          (s.f_bsize/(double)KILOBYTE)), base));
                printf("%9s %3ld%% %s\n",
-                          make_human_readable_str(s.f_bavail * (s.f_bsize/KILOBYTE), base),
+                          make_human_readable_str((unsigned long)(s.f_bavail * 
+                                          (s.f_bsize/(double)KILOBYTE)), base),
                           blocks_percent_used, mount_point);
 #else
                printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
                                device,
-                               (long) (s.f_blocks * (s.f_bsize / KILOBYTE)),
-                               (long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)),
-                               (long) (s.f_bavail * (s.f_bsize / KILOBYTE)),
+                               (long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
+                               (long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
+                               (long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
                                blocks_percent_used, mount_point);
 #endif
        }