aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Davis <brd@FreeBSD.org>2022-05-13 14:33:21 +0000
committerBrad Davis <brd@FreeBSD.org>2022-05-13 14:33:21 +0000
commit964ad27f1e48ec28247142cfe6afdfa1f8bd3182 (patch)
treed4d96c5c961d0758b302b86bd1594321247ed2af
parentdb71383b8836a586051b25c20992066d153c6941 (diff)
downloadsrc-964ad27f1e48ec28247142cfe6afdfa1f8bd3182.tar.gz
src-964ad27f1e48ec28247142cfe6afdfa1f8bd3182.zip
bsdinstall: Filter out devices that cannot be opened
Devices that cannot be opened are most likely the install media and should not be listed as destinations. Reviewed by: allanjude Approved by: allanjude Differential Revision: https://reviews.freebsd.org/D34879 Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--usr.sbin/bsdinstall/partedit/part_wizard.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c
index 2ffae7b16829..bc6427f859da 100644
--- a/usr.sbin/bsdinstall/partedit/part_wizard.c
+++ b/usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -135,6 +135,16 @@ boot_disk_select(struct gmesh *mesh)
continue;
if (strncmp(pp->lg_name, "cd", 2) == 0)
continue;
+ /*
+ * Check if the disk is available to be opened for
+ * write operations, it helps prevent the USB
+ * stick used to boot from being listed as an option
+ */
+ fd = g_open(pp->lg_name, 1);
+ if (fd == -1) {
+ continue;
+ }
+ g_close(fd);
disks = realloc(disks, (++n)*sizeof(disks[0]));
disks[n-1].name = pp->lg_name;