diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-05-19 21:31:05 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-05-19 21:31:05 +0000 |
commit | 094a646be0a10d5ee7de094165c21d487bf8c4e2 (patch) | |
tree | bf4f95fb7778f132565f645dd8aa7310b0485b6d /sys | |
parent | 5e1a61144537696dde5a44ec7e01b262dda2ae42 (diff) |
Let setroot() pick the boot disk based on the DUID provided in bootduid if
a boot disk has not been selected by its caller.
ok jsing@, millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_disk.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 4afe565f307..9c51a67077b 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.223 2016/02/08 22:12:51 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.224 2016/05/19 21:31:04 kettenis Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -1447,14 +1447,22 @@ setroot(struct device *bootdv, int part, int exitflags) printf("\n"); } - /* Locate DUID for boot disk if not already provided. */ memset(duid, 0, sizeof(duid)); if (memcmp(bootduid, duid, sizeof(bootduid)) == 0) { + /* Locate DUID for boot disk since it was not provided. */ TAILQ_FOREACH(dk, &disklist, dk_link) if (dk->dk_device == bootdv) break; if (dk && (dk->dk_flags & DKF_LABELVALID)) bcopy(dk->dk_label->d_uid, bootduid, sizeof(bootduid)); + } else if (bootdv == NULL) { + /* Locate boot disk based on the provided DUID. */ + TAILQ_FOREACH(dk, &disklist, dk_link) + if (memcmp(dk->dk_label->d_uid, bootduid, + sizeof(bootduid)) == 0) + break; + if (dk && (dk->dk_flags & DKF_LABELVALID)) + bootdv = dk->dk_device; } bcopy(bootduid, rootduid, sizeof(rootduid)); |