aboutsummaryrefslogtreecommitdiff
path: root/stand/common/devopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/common/devopen.c')
-rw-r--r--stand/common/devopen.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/stand/common/devopen.c b/stand/common/devopen.c
index de6165c03e8e..23ee2e211001 100644
--- a/stand/common/devopen.c
+++ b/stand/common/devopen.c
@@ -32,6 +32,10 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
+#ifdef LOADER_GELI_SUPPORT
+#include "geliboot.h"
+#endif
+
int
devopen(struct open_file *f, const char *fname, const char **file)
{
@@ -43,6 +47,7 @@ devopen(struct open_file *f, const char *fname, const char **file)
return (result);
/* point to device-specific data so that device open can use it */
+ f->f_dev = dev->d_dev;
f->f_devdata = dev;
result = dev->d_dev->dv_open(f, dev);
if (result != 0) {
@@ -51,8 +56,17 @@ devopen(struct open_file *f, const char *fname, const char **file)
return (result);
}
- /* reference the devsw entry from the open_file structure */
- f->f_dev = dev->d_dev;
+#ifdef LOADER_GELI_SUPPORT
+ /*
+ * If f->f_dev is geli-encrypted and we can decrypt it (will prompt for
+ * pw if needed), this will attach the geli code to the open_file by
+ * replacing f->f_dev and f_devdata with pointers to a geli_devdesc.
+ */
+ if (f->f_dev->dv_type == DEVT_DISK) {
+ geli_probe_and_attach(f);
+ }
+#endif
+
return (0);
}