[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[master] Adds interactive install support for NFS options (#537764)



This is a migration of the patch 22e2548cbb41a0c32fa3a0a2e67e67bbf3109155 from rhel5-branch, BZ#493052.
---
 loader/nfsinstall.c |   49 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index e405df9..3a89e34 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -58,11 +58,12 @@
 /* boot flags */
 extern uint64_t flags;
 
-static int nfsGetSetup(char ** hostptr, char ** dirptr) {
-    struct newtWinEntry entries[3];
+static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) {
+    struct newtWinEntry entries[4];
     char * buf;
     char * newServer = *hostptr ? strdup(*hostptr) : NULL;
     char * newDir = *dirptr ? strdup(*dirptr) : NULL;
+    char * newMountOpts = *optsptr ? strdup(*optsptr) : NULL;
     int rc;
 
     entries[0].text = _("NFS server name:");
@@ -77,11 +78,15 @@ static int nfsGetSetup(char ** hostptr, char ** dirptr) {
 
     entries[1].value = &newDir;
     entries[1].flags = NEWT_FLAG_SCROLL;
-    entries[2].text = NULL;
-    entries[2].value = NULL;
-
-    if (asprintf(&buf, _("Please enter the server name and path to your %s "
-                         "installation image."), getProductName()) == -1) {
+    entries[2].text = _("NFS mount options (optional):");
+    entries[2].value = &newMountOpts;
+    entries[2].flags = NEWT_FLAG_SCROLL;
+    entries[3].text = NULL; 
+    entries[3].value = NULL;
+
+    if (asprintf(&buf, _("Please enter the server, path to your %s "
+                         "installation image and optionally additional "
+                         "NFS mount options."), getProductName()) == -1) {
         logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
         abort();
     }
@@ -97,13 +102,16 @@ static int nfsGetSetup(char ** hostptr, char ** dirptr) {
     if (rc == 2) {
         if (newServer) free(newServer);
         if (newDir) free(newDir);
+        if (newMountOpts) free(newMountOpts);
         return LOADER_BACK;
     }
 
     if (*hostptr) free(*hostptr);
     if (*dirptr) free(*dirptr);
+    if (*optsptr) free(*optsptr);
     *hostptr = newServer;
     *dirptr = newDir;
+    *optsptr = newMountOpts;
 
     return 0;
 }
@@ -175,7 +183,6 @@ char * mountNfsImage(struct installMethod * method,
     while (stage != NFS_STAGE_DONE) {
         switch (stage) {
         case NFS_STAGE_NFS:
-            logMessage(INFO, "going to do nfsGetSetup");
             if (loaderData->method == METHOD_NFS && loaderData->stage2Data) {
                 host = ((struct nfsInstallData *)loaderData->stage2Data)->host;
                 directory = ((struct nfsInstallData *)loaderData->stage2Data)->directory;
@@ -207,9 +214,10 @@ char * mountNfsImage(struct installMethod * method,
                     directory = strdup(directory);
                 }
             } else {
-                char *substr, *tmp;
+                char *colonopts, *substr, *tmp;
 
-                if (nfsGetSetup(&host, &directory) == LOADER_BACK) {
+                logMessage(INFO, "going to do nfsGetSetup");
+                if (nfsGetSetup(&host, &directory, &mountOpts) == LOADER_BACK) {
                     loaderData->stage2Data = NULL;
                     return NULL;
                 }
@@ -219,21 +227,22 @@ char * mountNfsImage(struct installMethod * method,
                  */
                 substr = strstr(directory, ".img");
                 if (!substr || (substr && *(substr+4) != '\0')) {
-                    if (asprintf(&(loaderData->instRepo), "nfs:%s:%s",
-                                 host, directory) == -1) {
-                        logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
-                        abort();
+                    if (mountOpts && strlen(mountOpts)) {
+                        CHECKED_ASPRINTF(&colonopts, ":%s", mountOpts);
+                    } else {
+                        colonopts = strdup("");
                     }
 
-                    if (asprintf(&tmp, "nfs:%s:%s/images/install.img",
-                                 host, directory) == -1) {
-                        logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
-                        abort();
-                    }
+                    CHECKED_ASPRINTF(&(loaderData->instRepo), "nfs%s:%s:%s",
+                                     colonopts, host, directory);
+                    CHECKED_ASPRINTF(&tmp, "nfs%s:%s:%s/images/install.img",
+                                     colonopts, host, directory);
 
                     setStage2LocFromCmdline(tmp, loaderData);
                     free(host);
                     free(directory);
+                    free(mountOpts);
+                    free(colonopts);
                     free(tmp);
                     continue;
                 }
@@ -360,6 +369,8 @@ char * mountNfsImage(struct installMethod * method,
 
     free(host);
     free(directory);
+    if (mountOpts)
+        free(mountOpts);
     if (fullPath)
         free(fullPath);
 
-- 
1.6.2.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]