FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Kubuntu Development

 
 
LinkBack Thread Tools
 
Old 04-08-2010, 02:58 PM
Ales Kozumplik
 
Default nfs: direct mounting of stage2.

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] == '')
+ return 1;
+ if ((substr[len] == '/') &&
+ (substr[len + 1] == ''))
+ /* 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] = '';
+}
+
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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-09-2010, 11:27 AM
Martin Sivak
 
Default nfs: direct mounting of stage2.

Well I have one serious objection:

I do not like (at all) the hardcoded name which must be present in url and works as a trigger for different kind of mount. I'd like to see the detection being based on .discinfo/.treeinfo/.whateverinfo file we have in the root directory of stage2 instead on name.

So if we pass nfs mount as stage2 and then find .xxxinfo file there, we could regard that as direct nfs version of stage2 and bind-mount it to proper place. If there is no such file, we would look for install.img as we do now.

This would result in cleaner code and would be usable even for support teams and independent developers.

Martin

----- "Ales Kozumplik" <akozumpl@redhat.com> wrote:

> 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] == '')
> + return 1;
> + if ((substr[len] == '/') &&
> + (substr[len + 1] == ''))
> + /* 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] = '';
> +}
> +
> 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@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-22-2010, 09:57 AM
Ales Kozumplik
 
Default nfs: direct mounting of stage2.

The patch allows us to NFS mount an uncompressed directory 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 | 32 +++++++++++++++++++++++++++++++-
3 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/loader/method.c b/loader/method.c
index 1937b5a..503f6c1 100644
--- a/loader/method.c
+++ b/loader/method.c
@@ -424,6 +424,27 @@ void umountStage2(void) {
umountLoopback("/mnt/runtime", "/dev/loop0");
}

+/** 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;
+}
+
/* mount a second stage, verify the stamp file, copy updates
* Returns 0 on success, 1 on failure to mount, -1 on bad stamp */
int mountStage2(char *stage2path) {
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..f24acec 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -57,6 +58,30 @@
/* boot flags */
extern uint64_t flags;

+/**
+ * Test whether the mounted stage2 path is an uncompreseed image, not a squashfs.
+ *
+ * Asusme path is readable.
+ */
+static int isNfsMountDirect(const char * path) {
+ struct stat stat_info;
+ if (stat(path, &stat_info))
+ return 0;
+
+ if (!S_ISDIR(stat_info.st_mode))
+ /* if it's not a directory, then it's not an uncompressed image */
+ return 0;
+
+ char * buildstamp;
+ checked_asprintf(&buildstamp, "%s/%s", path, ".buildstamp");
+ if (access(buildstamp, F_OK))
+ /* if it doesn't contain buildstamp, then it's not an uncompressed image */
+ return 0;
+ free(buildstamp);
+
+ return 1;
+}
+
static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) {
struct newtWinEntry entries[4];
char * buf;
@@ -257,7 +282,12 @@ char * mountNfsImage(struct installMethod * method,

if (!access(buf, R_OK)) {
logMessage(INFO, "can access %s", buf);
- rc = mountStage2(buf);
+ if (isNfsMountDirect(buf)) {
+ logMessage(INFO, "using uncompressed stage2 image");
+ 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-23-2010, 12:40 PM
Martin Sivak
 
Default nfs: direct mounting of stage2.

Ack.

--
Martin Sivák
msivak@redhat.com
Red Hat Czech
Anaconda team / Brno, CZ

----- "Ales Kozumplik" <akozumpl@redhat.com> wrote:

> The patch allows us to NFS mount an uncompressed directory 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 | 32 +++++++++++++++++++++++++++++++-
> 3 files changed, 53 insertions(+), 1 deletions(-)
>
> diff --git a/loader/method.c b/loader/method.c
> index 1937b5a..503f6c1 100644
> --- a/loader/method.c
> +++ b/loader/method.c
> @@ -424,6 +424,27 @@ void umountStage2(void) {
> umountLoopback("/mnt/runtime", "/dev/loop0");
> }
>
> +/** 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;
> +}
> +
> /* mount a second stage, verify the stamp file, copy updates
> * Returns 0 on success, 1 on failure to mount, -1 on bad stamp */
> int mountStage2(char *stage2path) {
> 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..f24acec 100644
> --- a/loader/nfsinstall.c
> +++ b/loader/nfsinstall.c
> @@ -30,6 +30,7 @@
> #include <unistd.h>
> #include <errno.h>
> #include <string.h>
> +#include <sys/stat.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <arpa/inet.h>
> @@ -57,6 +58,30 @@
> /* boot flags */
> extern uint64_t flags;
>
> +/**
> + * Test whether the mounted stage2 path is an uncompreseed image, not
> a squashfs.
> + *
> + * Asusme path is readable.
> + */
> +static int isNfsMountDirect(const char * path) {
> + struct stat stat_info;
> + if (stat(path, &stat_info))
> + return 0;
> +
> + if (!S_ISDIR(stat_info.st_mode))
> + /* if it's not a directory, then it's not an uncompressed
> image */
> + return 0;
> +
> + char * buildstamp;
> + checked_asprintf(&buildstamp, "%s/%s", path, ".buildstamp");
> + if (access(buildstamp, F_OK))
> + /* if it doesn't contain buildstamp, then it's not an
> uncompressed image */
> + return 0;
> + free(buildstamp);
> +
> + return 1;
> +}
> +
> static int nfsGetSetup(char ** hostptr, char ** dirptr, char **
> optsptr) {
> struct newtWinEntry entries[4];
> char * buf;
> @@ -257,7 +282,12 @@ char * mountNfsImage(struct installMethod *
> method,
>
> if (!access(buf, R_OK)) {
> logMessage(INFO, "can access %s", buf);
> - rc = mountStage2(buf);
> + if (isNfsMountDirect(buf)) {
> + logMessage(INFO, "using uncompressed stage2
> image");
> + 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@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

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

Thread Tools




All times are GMT. The time now is 01:02 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org