#include "errors.h"
#include "debug.h"
-extern char bootdevice[1024];
+extern char bootdevice[];
static char *netdev_path_to_filename(const char *path)
{
char *ptr;
char *ipath = NULL;
char *defdev = NULL;
- int device_kind;
+ int device_kind = -1;
result->dev = NULL;
result->part = -1;
if (!imagepath)
return 0;
+
+ /*
+ * Do preliminary checking for an iscsi device; it may appear as
+ * pure a network device (device_type == "network") if this is
+ * ISWI. This is the case on IBM systems doing an iscsi OFW
+ * boot.
+ */
+ if (strstr(imagepath, TOK_ISCSI)) {
+ /*
+ * get the virtual device information from the
+ * "nas-bootdevice" property.
+ */
+ if (prom_get_chosen("nas-bootdevice", bootdevice, BOOTDEVSZ)) {
+ DEBUG_F("reset boot-device to"
+ " /chosen/nas-bootdevice = %s\n", bootdevice);
+ device_kind = FILE_DEVICE_ISCSI;
+ ipath = strdup(bootdevice);
+ if (!ipath)
+ return 0;
+ }
+ else
+ return 0;
+ }
else if (!(ipath = strdup(imagepath)))
return 0;
if (defdevice) {
defdev = strdup(defdevice);
device_kind = prom_get_devtype(defdev);
- } else
+ } else if (device_kind == -1)
device_kind = prom_get_devtype(ipath);
- if (device_kind != FILE_DEVICE_NET && strchr(defdev, ':') != NULL) {
+ /*
+ * When an iscsi iqn is present, it may have embedded colons, so
+ * don't parse off anything.
+ */
+ if (device_kind != FILE_DEVICE_NET &&
+ device_kind != FILE_DEVICE_ISCSI &&
+ strchr(defdev, ':') != NULL) {
if ((ptr = strrchr(defdev, ':')) != NULL)
*ptr = 0; /* remove trailing : from defdevice if necessary */
}
/* This will not properly handle an obp-tftp argument list
* with elements after the filename; that is handled below.
*/
- if (device_kind != FILE_DEVICE_NET && strchr(ipath, ':') != NULL) {
+ if (device_kind != FILE_DEVICE_NET &&
+ device_kind != FILE_DEVICE_ISCSI &&
+ strchr(ipath, ':') != NULL) {
if ((ptr = strrchr(ipath, ',')) != NULL) {
char *colon = strrchr(ipath, ':');
/* If a ':' occurs *after* a ',', then we assume that there is
if (!defdev)
result->dev = netdev_path_to_dev(ipath);
- } else if ((ptr = strchr(ipath, ':')) != NULL) {
+ } else if (device_kind != FILE_DEVICE_ISCSI &&
+ (ptr = strrchr(ipath, ':')) != NULL) {
*ptr = 0;
result->dev = strdup(ipath);
if (*(ptr+1))
/* Locals & globals */
int useconf = 0;
-char bootdevice[1024];
+char bootdevice[BOOTDEVSZ];
char *password = NULL;
struct boot_fspec_t boot;
int _machine = _MACH_Pmac;
if (_machine == _MACH_Pmac)
setup_display();
- prom_get_chosen("bootpath", bootdevice, sizeof(bootdevice));
+ prom_get_chosen("bootpath", bootdevice, BOOTDEVSZ);
DEBUG_F("/chosen/bootpath = %s\n", bootdevice);
if (bootdevice[0] == 0) {
- prom_get_options("boot-device", bootdevice, sizeof(bootdevice));
+ prom_get_options("boot-device", bootdevice, BOOTDEVSZ);
DEBUG_F("boot-device = %s\n", bootdevice);
}
if (bootdevice[0] == 0) {