install - Fix a few issues
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 15 Aug 2017 21:19:51 +0000 (14:19 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 15 Aug 2017 21:19:51 +0000 (14:19 -0700)
* sleep 1 second before [re]surveying drives to give devfs time to
  [re]probe the drive.

* fn_subpart_hammer was apparently trying to check the capacity of the
  current slice when there is no current slice.  Check the disk capacity
  instead.

usr.sbin/installer/dfuibe_installer/flow.c
usr.sbin/installer/dfuibe_installer/fn_disk.c
usr.sbin/installer/dfuibe_installer/fn_subpart_hammer.c
usr.sbin/installer/libinstaller/diskutil.c
usr.sbin/installer/libinstaller/diskutil.h
usr.sbin/installer/libinstaller/survey.c

index f9e5f41..51fbbed 100644 (file)
@@ -40,6 +40,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 
 #ifdef ENABLE_NLS
@@ -1208,6 +1209,9 @@ state_create_subpartitions(struct i_fn_args *a)
        commands_execute(a, cmds);
        commands_free(cmds);
 
+       /*
+        * Create subpartitions and filesystems
+        */
        if (use_hammer)
                fn_create_subpartitions_hammer(a);
        else
index 152fcb8..b50b4cd 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 
 #ifdef ENABLE_NLS
@@ -260,7 +261,6 @@ fn_format_disk_mbr(struct i_fn_args *a)
                        a->result = 0;
                        return;
                }
-
                inform(a->c, _("The disk\n\n%s\n\nwas formatted."),
                    disk_get_desc(storage_get_selected_disk(a->s)));
                a->result = 1;
index 22743a6..236185a 100644 (file)
@@ -814,10 +814,12 @@ fn_create_subpartitions_hammer(struct i_fn_args *a)
        int done = 0;
 
        a->result = 0;
-       capacity = slice_get_capacity(storage_get_selected_slice(a->s));
+       capacity = disk_get_capacity(storage_get_selected_disk(a->s));
        if (capacity < HAMMER_MIN) {
-               inform(a->c, _("The selected disk is smaller than the "
-                   "required %dM for the HAMMER filesystem."), HAMMER_MIN);
+               inform(a->c, _("The selected %dM disk is smaller than the "
+                   "required %dM for the HAMMER filesystem."),
+                   (int)capacity,
+                   (int)HAMMER_MIN);
                return;
        }
        while (!done) {
index 20aa29d..0ad699f 100644 (file)
@@ -194,6 +194,13 @@ disk_get_desc(const struct disk *d)
        return(d->desc);
 }
 
+unsigned long
+disk_get_capacity(const struct disk *d)
+{
+       return(d->capacity);
+}
+
+
 void
 disk_set_desc(struct disk *d, const char *desc)
 {
@@ -215,7 +222,7 @@ disk_set_desc(struct disk *d, const char *desc)
        if (*c == '\0')
                d->capacity = 0;
        else
-               d->capacity = atoi(c + 1);
+               d->capacity = strtoul(c + 1, NULL, 0);
 }
 
 /*
index 938816a..cdaa7d1 100644 (file)
@@ -130,6 +130,7 @@ struct disk         *disk_new(struct storage *, const char *);
 struct disk            *disk_find(const struct storage *, const char *);
 struct disk            *disk_next(const struct disk *);
 void                    disks_free(struct storage *);
+unsigned long           disk_get_capacity(const struct disk *);
 void                    disk_set_number(struct disk *, const int);
 void                    disk_set_desc(struct disk *, const char *);
 void                    disk_set_serno(struct disk *, const char *);
index 3024a1e..b8fc42d 100644 (file)
@@ -163,6 +163,7 @@ survey_storage(struct i_fn_args *a)
        struct partinfo diskpart;
        char diskpath[PATH_MAX];
 
+       sleep(1);               /* give devfs time to probe */
        disks_free(a->s);
 
        len = sizeof(mem);