diff options
author | Antoine Ginies <aginies@mandriva.com> | 2004-10-13 06:39:38 +0000 |
---|---|---|
committer | Antoine Ginies <aginies@mandriva.com> | 2004-10-13 06:39:38 +0000 |
commit | 536f4e80aa75e99ba38e9f3037f169336ad10f61 (patch) | |
tree | 763ce5183ecbe1f05b1feb5a6680b480973aab11 /mdk-stage1/url.c | |
parent | 6cc57924776dd164351f363ba48f4c453792ba62 (diff) | |
download | drakx-536f4e80aa75e99ba38e9f3037f169336ad10f61.tar drakx-536f4e80aa75e99ba38e9f3037f169336ad10f61.tar.gz drakx-536f4e80aa75e99ba38e9f3037f169336ad10f61.tar.bz2 drakx-536f4e80aa75e99ba38e9f3037f169336ad10f61.tar.xz drakx-536f4e80aa75e99ba38e9f3037f169336ad10f61.zip |
add new installation method (ka)
Diffstat (limited to 'mdk-stage1/url.c')
-rw-r--r-- | mdk-stage1/url.c | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c index 0c4dbbedf..6b48c3c9b 100644 --- a/mdk-stage1/url.c +++ b/mdk-stage1/url.c @@ -37,6 +37,7 @@ #include <sys/types.h> #include <unistd.h> #include <sys/poll.h> +#include <sys/mount.h> #include <netinet/in.h> #include <netinet/ip.h> @@ -47,11 +48,14 @@ #include "tools.h" #include "url.h" +#include "mount.h" +#include <sys/wait.h> #define TIMEOUT_SECS 60 #define BUFFER_SIZE 4096 +void my_pause(void) { unsigned char t; fflush(stdout); read(0, &t, 1); } static int ftp_check_response(int sock, char ** str) { @@ -509,6 +513,80 @@ int http_download_file(char * hostname, char * remotename, int * size, char * pr *size = charstar_to_int(buf + strlen(header_content_length)); else *size = 0; - return sock; } + +enum return_type ka_wait_for_stage2(void) +{ + char * ramdisk = "/dev/ram3"; /* warning, verify that this file exists in the initrd*/ + char * ka_launch[] = { "/ka/ka-d-client", "-w","-s","getstage2","-e","(cd /tmp/stage2; tar --extract --read-full-records --same-permissions --numeric-owner --sparse --file - )", NULL }; /* The command line for ka_launch */ + char * mkfs_launch[] = { "/sbin/mke2fs", ramdisk, NULL}; /* The mkfs command for formating the ramdisk */ + + + log_message("KA: Preparing to receive stage 2...."); + int pida, wait_status; + + if (!(pida = fork())) { /* Forking current process for running mkfs */ + close(1); + close(2); + execve(mkfs_launch[0], mkfs_launch,grab_env()); /* Formating the ramdisk */ + printf("KA: Can't execute %s\n<press Enter>\n", mkfs_launch[0]); + my_pause(); + return KAERR_CANTFORK; + } + while (wait4(-1, &wait_status, 0, NULL) != pida) {}; /* Waiting the end of mkfs */ + + if (my_mount(ramdisk, STAGE2_LOCATION, "ext2", 1)) {/* Trying to mount the ramdisk */ + return RETURN_ERROR; + } + + log_message("KA: Waiting for stage 2...."); + wait_message("Waiting for rescue from KA server"); + pid_t pid; /* Process ID of the child process */ + pid_t wpid; /* Process ID from wait() */ + int status; /* Exit status from wait() */ + + pid = fork(); + if ( pid == -1 ) { + fprintf(stderr, "%s: Failed to fork()\n", strerror(errno)); + exit(13); + } else if ( pid == 0 ) { + execve(ka_launch[0], ka_launch, grab_env()); + } else { + // wpid = wait(&status); /* Child's exit status */ + wpid = wait4(-1, &status, 0, NULL); + if ( wpid == -1 ) { + fprintf(stderr,"%s: wait()\n", strerror(errno)); + return RETURN_ERROR; + } else if ( wpid != pid ) + abort(); + else { + if ( WIFEXITED(status) ) { + printf("Exited: $? = %d\n", WEXITSTATUS(status)); + } else if ( WIFSIGNALED(status) ) { + printf("Signal: %d%s\n", WTERMSIG(status), WCOREDUMP(status) ? " with core file." : ""); + } + } + + } + + remove_wait_message(); + return RETURN_OK; + // if (!(pid = fork())) { /* Froking current process for running ka-deploy (client side) */ + // close(1); /* Closing stdout */ + // close(2); /* Closing stderr */ + // execve(ka_launch[0], ka_launch,grab_env()); /* Running ka-deploy (client side) */ + // printf("KA: Can't execute %s\n<press Enter>\n", ka_launch[0]); + // log_message("KA: Can't execute %s\n<press Enter>\n", ka_launch[0]); + // my_pause(); + // return KAERR_CANTFORK; + //} + + //while (wait4(-1, &wait_status, 0, NULL) != pid) {}; /* Waiting the end of duplication */ + // log_message("kalaunch ret %d\n", WIFEXITED(wait_status)); + // remove_wait_message(); + //sleep(100000); + // return RETURN_OK; +} + + |