Skip to content

Instantly share code, notes, and snippets.

@tuxillo
Created November 5, 2016 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxillo/4a83ca03489ca344d7db263b2eb615ab to your computer and use it in GitHub Desktop.
Save tuxillo/4a83ca03489ca344d7db263b2eb615ab to your computer and use it in GitHub Desktop.
diff --git a/usr.sbin/installer/libinstaller/survey.c b/usr.sbin/installer/libinstaller/survey.c
index 42b5a28..3dad695 100644
--- a/usr.sbin/installer/libinstaller/survey.c
+++ b/usr.sbin/installer/libinstaller/survey.c
@@ -199,11 +199,23 @@ survey_storage(struct i_fn_args *a)
command_set_log_mode(cmd, COMMAND_LOG_SILENT);
aura_dict_rewind(di);
- while (!aura_dict_eof(di)) {
- aura_dict_get_current_key(di, &rk, &rk_len),
-
+ for (; !aura_dict_eof(di); aura_dict_next(di) ) {
+ aura_dict_get_current_key(di, &rk, &rk_len);
disk = (char *)rk;
+ /*
+ * Attempt to get media information from the disk. This information
+ * will be used later on for partitioning. Any disk that does not
+ * provide the information will be discarded as not suitable for
+ * an installation.
+ */
+ bzero(&diskpart, sizeof(diskpart));
+ snprintf(diskpath, PATH_MAX, "/dev/%s", disk);
+ if ((fd = open(diskpath, O_RDONLY)) < 0)
+ continue;
+ if (ioctl(fd, DIOCGPART, &diskpart) < 0)
+ continue;
+
cmd = command_add(cmds, "%s%s '@DISK' >>%ssurvey.txt",
a->os_root, cmd_name(a, "ECHO"), a->tmp);
command_set_log_mode(cmd, COMMAND_LOG_SILENT);
@@ -217,12 +229,6 @@ survey_storage(struct i_fn_args *a)
cmd = command_add(cmds, "%s%s '@DESC' >>%ssurvey.txt",
a->os_root, cmd_name(a, "ECHO"), a->tmp);
command_set_log_mode(cmd, COMMAND_LOG_SILENT);
- snprintf(diskpath, PATH_MAX, "/dev/%s", disk);
- if ((fd = open(diskpath, O_RDONLY)) < 0)
- failure |= 1;
- bzero(&diskpart, sizeof(diskpart));
- if (ioctl(fd, DIOCGPART, &diskpart) < 0)
- failure |= 1;
cmd = command_add(cmds, "%s%s '%s: %luMB' >>%ssurvey.txt",
a->os_root, cmd_name(a, "ECHO"),
disk,
@@ -267,8 +273,6 @@ survey_storage(struct i_fn_args *a)
cmd = command_add(cmds, "%s%s '@END' >>%ssurvey.txt",
a->os_root, cmd_name(a, "ECHO"), a->tmp);
command_set_log_mode(cmd, COMMAND_LOG_SILENT);
-
- aura_dict_next(di);
}
cmd = command_add(cmds, "%s%s '.' >>%ssurvey.txt",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment