[master 3/3] nfs: direct mounting of stage2.

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

 



The patch allows us to mount a directory called squashfs-root/ as stage2,
for instance like this:

stage2=nfs:10.34.27.9:/pub/pungi/20100407/i386/os/images/squashfs-root

During development this is useful because we can avoid lengthy mksquashfs
calls.
---
 loader/method.c     |   21 +++++++++++++++++++++
 loader/method.h     |    1 +
 loader/nfsinstall.c |   41 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/loader/method.c b/loader/method.c
index 969a47e..5f8b062 100644
--- a/loader/method.c
+++ b/loader/method.c
@@ -433,6 +433,27 @@ int mountStage2(char *stage2path) {
     return 0;
 }
 
+/** Bind the uncompressed second stage to /mnt/runtime.
+ *
+ * return 0 on success, 1 on failure to mount.
+ */
+int mountStage2Direct(char *stage2Path) {
+    if (access(stage2Path, R_OK)) {
+        return 1;
+    }
+
+    char *target = "/mnt/runtime";
+    char *error = NULL;
+    if (doBindMount(stage2Path, target, &error)) {
+        logMessage(ERROR, "failed to bind %s to %s: %s",
+                   stage2Path, target, error);
+        free(error);
+        return 1;
+    }
+    logMessage(INFO, "successfully bound %s to %s", stage2Path, target);
+    return 0;
+}
+
 /* copies a second stage from fd to dest and mounts on mntpoint */
 int copyFileAndLoopbackMount(int fd, char * dest, char * device, char * mntpoint,
                              progressCB pbcb, struct progressCBdata *data,
diff --git a/loader/method.h b/loader/method.h
index 1b5e2d3..7d2a3f6 100644
--- a/loader/method.h
+++ b/loader/method.h
@@ -47,6 +47,7 @@ void queryIsoMediaCheck(char * isoDir);
 
 void umountStage2(void);
 int mountStage2(char *stage2path);
+int mountStage2Direct(char *stage2path);
 int copyFileAndLoopbackMount(int fd, char *dest, char *device, char *mntpoint,
                              progressCB pbcb, struct progressCBdata *data, long long total);
 int getFileFromBlockDevice(char *device, char *path, char * dest);
diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index ae13874..b04ef63 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -57,6 +57,27 @@
 /* boot flags */
 extern uint64_t flags;
 
+static const char * DIRECT_IMAGE_DIRNAME = "squashfs-root";
+
+/**
+ * Test whether the mounted directory is an uncompreseed image, not a squashfs.
+ */
+static int isNfsMountDirect(const char * directory) {
+    char * substr = strstr(directory, DIRECT_IMAGE_DIRNAME);
+    const int len = strlen(DIRECT_IMAGE_DIRNAME);
+
+    if (substr) {
+        if (substr[len] == '\0')
+            return 1;
+        if ((substr[len] == '/') &&
+            (substr[len + 1] == '\0'))
+            /* trailing slash */
+            return 1;
+    }
+
+    return 0;
+}
+
 static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) {
     struct newtWinEntry entries[4];
     char * buf;
@@ -111,6 +132,15 @@ static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) {
     return 0;
 }
 
+static void stripTrailingSlash(char *directory) {
+    size_t len = strlen(directory);
+
+    if (len == 0)
+        return;
+    if (directory[len-1] == '/')
+        directory[len-1] = '\0';
+}
+
 void parseNfsHostPathOpts(char *url, char **host, char **path, char **opts) {
     char *tmp;
     char *hostsrc;
@@ -188,6 +218,10 @@ char * mountNfsImage(struct installMethod * method,
                 }
 
                 logMessage(INFO, "host is %s, dir is %s, opts are '%s'", host, directory, mountOpts);
+                if (isNfsMountDirect(directory)) {
+                    logMessage(INFO, "stage 2 directory is not compressed");
+                    stripTrailingSlash(directory);
+                }
 
                 if (!host || !directory) {
                     logMessage(ERROR, "missing host or directory specification");
@@ -257,7 +291,12 @@ char * mountNfsImage(struct installMethod * method,
 
                 if (!access(buf, R_OK)) {
                     logMessage(INFO, "can access %s", buf);
-                    rc = mountStage2(buf);
+
+                    if (isNfsMountDirect(directory)) {
+                        rc = mountStage2Direct(buf);
+                    } else {
+                        rc = mountStage2(buf);
+                    }
 
                     if (rc == 0) {
                         stage = NFS_STAGE_UPDATES;
-- 
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux