int kickstartFromBD(char *kssrc) { int rc; char *p, *np = NULL, *r = NULL, *tmpstr, *ksdev, *kspath, *biosksdev; logMessage(INFO, "getting kickstart file from biosdrive"); /* format is bd:[device]:/path/to/ks.cfg */ /* split of pieces */ tmpstr = strdup(kssrc); p = strchr(tmpstr, ':'); if (p) np = strchr(p+1, ':'); if (!p || !np) { logMessage(WARNING, "Format of command line is ks=bd:device:/path/to/ks.cfg"); free(tmpstr); return 1; } *np = '\0'; kspath = np+1; r = strchr(p+1,'p'); if(!r){ logMessage(INFO, "Format of biosdisk is 80p1"); free(tmpstr); return 1; } *r = '\0'; biosksdev = getBiosDisk((p + 1)); if(!biosksdev){ startNewt(); newtWinMessage(_("Error"), _("OK"), _("Cannot find hard drive for BIOS disk %s"), p + 1); return 1; } ksdev = malloc(strlen(biosksdev) + 3); sprintf(ksdev, "%s%s", biosksdev, r + 1); logMessage(INFO, "Loading ks from device %s on path %s", ksdev, kspath); if ((rc=getKickstartFromBlockDevice(ksdev, kspath))) { if (rc == 3) { startNewt(); newtWinMessage(_("Error"), _("OK"), _("Cannot find kickstart file on hard drive.")); } return 1; } return 0; }
int kickstartFromRemovable(char *kssrc) { struct device ** devices; char *p, *kspath; int i, rc; logMessage(INFO, "doing kickstart from removable media"); devices = getDevices(DEVICE_DISK); /* usb can take some time to settle, even with the various hacks we * have in place. some systems use portable USB CD-ROM drives, try to * make sure there really isn't one before bailing. */ for (i = 0; !devices && i < 10; ++i) { logMessage(INFO, "sleeping to wait for a USB disk"); sleep(2); devices = getDevices(DEVICE_DISK); } if (!devices) { logMessage(ERROR, "no disks"); return 1; } for (i = 0; devices[i]; i++) { if (devices[i]->priv.removable == 1) { logMessage(INFO, "first removable media is %s", devices[i]->device); break; } } if (!devices[i] || (devices[i]->priv.removable == 0)) { logMessage(ERROR, "no removable devices"); return 1; } /* format is floppy:[/path/to/ks.cfg] */ kspath = ""; p = strchr(kssrc, ':'); if (p) kspath = p + 1; if (!p || strlen(kspath) < 1) kspath = "/ks.cfg"; if ((rc=getKickstartFromBlockDevice(devices[i]->device, kspath))) { if (rc == 3) { startNewt(); newtWinMessage(_("Error"), _("OK"), _("Cannot find ks.cfg on removable media.")); } return 1; } return 0; }
int kickstartFromCD(char *kssrc) { int rc, i; char *p, *kspath; struct device ** devices; logMessage(INFO, "getting kickstart file from first CDROM"); devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0); /* usb can take some time to settle, even with the various hacks we * have in place. some systems use portable USB CD-ROM drives, try to * make sure there really isn't one before bailing */ for (i = 0; !devices && i < 10; ++i) { logMessage(DEBUGLVL, "sleeping to wait for a USB CD-ROM"); sleep(2); devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0); } if (!devices) { logMessage(ERROR, "No CDROM devices found!"); return 1; } /* format is cdrom:[/path/to/ks.cfg] */ kspath = ""; p = strchr(kssrc, ':'); if (p) kspath = p + 1; if (!p || strlen(kspath) < 1) kspath = "/ks.cfg"; for (i=0; devices[i]; i++) { if (!devices[i]->device) continue; rc = getKickstartFromBlockDevice(devices[i]->device, kspath); if (rc == 0) return 0; } startNewt(); newtWinMessage(_("Error"), _("OK"), _("Cannot find kickstart file on CDROM.")); return 1; }
int kickstartFromHD(char *kssrc) { int rc; char *p, *np = NULL, *tmpstr, *ksdev, *kspath; logMessage(INFO, "getting kickstart file from harddrive"); /* format is hd:[device]:/path/to/ks.cfg */ /* split up pieces */ tmpstr = strdup(kssrc); p = strchr(tmpstr, ':'); if (p) np = strchr(p+1, ':'); /* no second colon, assume its the old format of */ /* hd:[device]/path/to/ks.cfg */ /* this format is bad however because some devices have '/' in them! */ if (!np) np = strchr(p+1, '/'); if (!p || !np) { logMessage(WARNING, "Format of command line is ks=hd:[device]:/path/to/ks.cfg"); free(tmpstr); return 1; } *np = '\0'; ksdev = p+1; kspath = np+1; logMessage(INFO, "Loading ks from device %s on path %s", ksdev, kspath); if ((rc=getKickstartFromBlockDevice(ksdev, kspath))) { if (rc == 3) { startNewt(); newtWinMessage(_("Error"), _("OK"), _("Cannot find kickstart file on hard drive.")); } return 1; } return 0; }