Page MenuHomeFreeBSD

D19243.diff
No OneTemporary

D19243.diff

Index: stand/common/devopen.c
===================================================================
--- stand/common/devopen.c
+++ stand/common/devopen.c
@@ -29,8 +29,10 @@
#include <stand.h>
#include <string.h>
+#include <stdbool.h>
#include "bootstrap.h"
+#include "disk.h"
#ifdef LOADER_GELI_SUPPORT
#include "geliboot.h"
@@ -41,6 +43,7 @@
{
struct devdesc *dev;
int result;
+ bool is_open = false;
result = archsw.arch_getdev((void **)&dev, fname, file);
if (result)
@@ -49,11 +52,37 @@
/* 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) {
- f->f_devdata = NULL;
- free(dev);
- return (result);
+
+ /*
+ * Traditinally the open of FREEBSD MBR slice means that we will
+ * open the first BSD slice, if that does fail, only then we will
+ * open the MBR slice.
+ * To provide backwards compatibility, we need to check if there is
+ * slice specified in device name, and if so, we will add partition
+ * name 'a' and will try to open this updated name first.
+ */
+ if (dev->d_dev->dv_type == DEVT_DISK) {
+ struct disk_devdesc *tdev;
+
+ tdev = (struct disk_devdesc *)dev;
+ if (tdev->d_partition == -1) {
+ tdev->d_partition = 0;
+ result = dev->d_dev->dv_open(f, dev);
+ if (result != 0) {
+ tdev->d_partition = -1;
+ } else {
+ is_open = true;
+ }
+ }
+ }
+
+ if (is_open == false) {
+ result = dev->d_dev->dv_open(f, dev);
+ if (result != 0) {
+ f->f_devdata = NULL;
+ free(dev);
+ return (result);
+ }
}
#ifdef LOADER_GELI_SUPPORT

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 20, 11:22 AM (10 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30014868
Default Alt Text
D19243.diff (1 KB)

Event Timeline