summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--loader2/kickstart.c20
-rw-r--r--loader2/kickstart.h2
-rw-r--r--loader2/net.c14
-rw-r--r--loader2/nfsinstall.c31
-rw-r--r--loader2/urlinstall.c38
5 files changed, 51 insertions, 54 deletions
diff --git a/loader2/kickstart.c b/loader2/kickstart.c
index 443b22ae0..4fc129674 100644
--- a/loader2/kickstart.c
+++ b/loader2/kickstart.c
@@ -294,6 +294,26 @@ int getKickstartFromBlockDevice(char *device, char *path) {
return rc;
}
+void getHostandPath(char * ksSource, char **host, char ** file, char * ip) {
+ *host = malloc(strlen(ksSource) + 1);
+ strcpy(*host, ksSource);
+
+ *file = strchr(*host, '/');
+
+ if (*file) {
+ **file = '\0';
+ *file = *file + 1;
+ } else {
+ *file = malloc(sizeof(char *));
+ **file = '\0';
+ }
+
+ if ((*file) && (((*file)[strlen(*file) - 1] == '/') ||
+ ((*file)[strlen(*file) - 1] == '\0'))) {
+ *file = sdupprintf("%s%s-kickstart", *file, ip);
+
+ }
+}
void getKickstartFile(struct knownDevices * kd,
struct loaderData_s * loaderData, int * flagsPtr) {
diff --git a/loader2/kickstart.h b/loader2/kickstart.h
index 7e74de073..6c2f98ada 100644
--- a/loader2/kickstart.h
+++ b/loader2/kickstart.h
@@ -21,4 +21,6 @@ void getKickstartFile(struct knownDevices * kd,
struct loaderData_s * loaderData, int * flagsPtr);
void setupKickstart(struct loaderData_s * loaderData, int * flagsPtr);
int getKickstartFromBlockDevice(char *device, char *path);
+void getHostandPath(char * ksSource, char **host, char ** file, char * ip);
+
#endif
diff --git a/loader2/net.c b/loader2/net.c
index c03602a7a..7a8abd7c7 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -215,7 +215,7 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
logMessage("pump told us: %s", chptr);
return;
}
-
+
cfg->isDynamic = 1;
} else if (inet_aton(loaderData->ip, &addr)) {
cfg->dev.ip = addr;
@@ -755,12 +755,15 @@ int chooseNetworkInterface(struct knownDevices * kd,
* the network */
int kickstartNetworkUp(struct knownDevices * kd,
struct loaderData_s * loaderData,
+ struct networkDeviceConfig *netCfgPtr,
int flags) {
int rc;
- struct networkDeviceConfig netCfg;
initLoopback();
+ memset(netCfgPtr, 0, sizeof(*netCfgPtr));
+ netCfgPtr->isDynamic = 1;
+
do {
/* this is smart and does the right thing based on whether or not
* we have ksdevice= specified */
@@ -784,12 +787,9 @@ int kickstartNetworkUp(struct knownDevices * kd,
}
loaderData->ipinfo_set = 1;
- memset(&netCfg, 0, sizeof(netCfg));
- netCfg.isDynamic = 1;
-
- setupNetworkDeviceConfig(&netCfg, loaderData, flags);
+ setupNetworkDeviceConfig(netCfgPtr, loaderData, flags);
- rc = readNetConfig(loaderData->netDev, &netCfg, flags);
+ rc = readNetConfig(loaderData->netDev, netCfgPtr, flags);
if (rc) {
logMessage("unable to setup networking");
return -1;
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index e760936b8..69526ee6c 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -275,30 +275,27 @@ void setKickstartNfs(struct loaderData_s * loaderData, int argc,
int kickstartFromNfs(char * url, struct knownDevices * kd,
struct loaderData_s * loaderData, int flags) {
- char * host = NULL, * file = NULL;
+ char * host = NULL, *path = NULL, * file = NULL;
int failed = 0;
+ struct networkDeviceConfig netCfg;
- if (kickstartNetworkUp(kd, loaderData, flags)) {
+ logMessage("going to get ks from nfs");
+
+ if (kickstartNetworkUp(kd, loaderData, &netCfg, flags)) {
logMessage("unable to bring up network");
return 1;
}
- host = url;
- /* JKFIXME: need to add this; abstract out the functionality
- * so that we can use it for all types */
- if (host[strlen(url) - 1] == '/') {
- logMessage("directory syntax not supported yet");
- return 1;
- /* host[strlen(host) - 1] = '\0';
- file = malloc(30);
- sprintf(file, "%s-kickstart", inet_ntoa(netDev.dev.ip));*/
+ getHostandPath(url, &host, &path, inet_ntoa(netCfg.dev.ip));
+
+ /* nfs has to be a little bit different... split off the last part as
+ * the file and then concatenate host + dir path */
+ file = strrchr(path, '/');
+ if (!file) {
+ file = "/";
} else {
- file = strrchr(host, '/');
- if (!file) {
- file = "/";
- } else {
- *file++ = '\0';
- }
+ *file++ ='\0';
+ host = sdupprintf("%s/%s", host, path);
}
logMessage("ks location: nfs://%s/%s", host, file);
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index 72f45f13c..8d154db3a 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <unistd.h>
+#include "kickstart.h"
#include "loader.h"
#include "loadermisc.h"
#include "lang.h"
@@ -302,9 +303,9 @@ int kickstartFromUrl(char * url, struct knownDevices * kd,
!strncmp(url, "ftp://", 6) ? URL_METHOD_FTP : URL_METHOD_HTTP;
char * host = NULL, * file = NULL, * chptr = NULL;
int fd, rc;
+ struct networkDeviceConfig netCfg;
-
- if (kickstartNetworkUp(kd, loaderData, flags)) {
+ if (kickstartNetworkUp(kd, loaderData, &netCfg, flags)) {
logMessage("unable to bring up network");
return 1;
}
@@ -312,35 +313,11 @@ int kickstartFromUrl(char * url, struct knownDevices * kd,
memset(&ui, 0, sizeof(ui));
ui.protocol = proto;
- switch(proto) {
- case URL_METHOD_HTTP:
- host = url + 7;
- break;
- case URL_METHOD_FTP:
- host = url + 6;
- logMessage("ftp kickstart source not supported yet");
- return 1;
- }
-
- /* JKFIXME: need to add this; abstract out the functionality
- * so that we can use it for all types */
- if (host[strlen(host) - 1] == '/') {
- logMessage("directory syntax not supported yet");
- return 1;
- /* host[strlen(host) - 1] = '\0';
- file = malloc(30);
- sprintf(file, "%s-kickstart", inet_ntoa(netDev.dev.ip));*/
- } else {
- file = strrchr(host, '/');
- if (!file) {
- file = host;
- host = "/";
- } else {
- *file++ = '\0';
- }
- }
+ getHostandPath((proto == URL_METHOD_FTP ? url + 6 : url + 7),
+ &host, &file, inet_ntoa(netCfg.dev.ip));
- logMessage("ks location: http://%s/%s", host, file);
+ logMessage("ks location: %s://%s/%s",
+ (proto == URL_METHOD_FTP ? "ftp" : "http"), host, file);
chptr = strchr(host, '/');
if (chptr == NULL) {
@@ -353,6 +330,7 @@ int kickstartFromUrl(char * url, struct knownDevices * kd,
*host = '/';
ui.prefix = strdup(host);
}
+ logMessage("address: %s, prefix: %s", ui.address, ui.prefix);
fd = urlinstStartTransfer(&ui, file, 1);
if (fd < 0) {