diff options
author | 2012-01-11 15:40:36 +0000 | |
---|---|---|
committer | 2012-01-11 15:40:36 +0000 | |
commit | 0a668dd24b5222697ed8c8b6c545496c9f1af9e7 (patch) | |
tree | 6c610af7532a8ba1ce971824fdead5e7343d9530 /sys/kern/subr_disk.c | |
parent | Move softraid root mapping to later in the boot process - this will allow (diff) | |
download | wireguard-openbsd-0a668dd24b5222697ed8c8b6c545496c9f1af9e7.tar.xz wireguard-openbsd-0a668dd24b5222697ed8c8b6c545496c9f1af9e7.zip |
If the DUID of the boot disk has not been provided, attempt to locate it
via the boot device. This allows root on softraid to work on most
architectures. For architectures that cannot clearly identify their boot
device, the DUID of the boot disk can still be passed from the boot loader,
as is already done for amd64 and i386.
Based on a suggestion from kettenis@
ok krw@
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r-- | sys/kern/subr_disk.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index af42b879752..82c28eff372 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.136 2012/01/11 15:17:48 jsing Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.137 2012/01/11 15:40:36 jsing Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -80,6 +80,7 @@ int disk_change; /* set if a disk has been attached/detached * is reset by hw_sysctl() */ +u_char bootduid[8]; /* DUID of boot disk. */ u_char rootduid[8]; /* DUID of root disk. */ /* softraid callback, do not use! */ @@ -1170,6 +1171,17 @@ setroot(struct device *bootdv, int part, int exitflags) extern char *nfsbootdevname; #endif + /* Locate DUID for boot disk if not already provided. */ + bzero(duid, sizeof(duid)); + if (bcmp(bootduid, duid, sizeof(bootduid)) == 0) { + 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)); + } + bcopy(bootduid, rootduid, sizeof(rootduid)); + #if NSOFTRAID > 0 sr_map_root(); #endif |