summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/ka.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/mdk-stage1/ka.c b/mdk-stage1/ka.c
index d3c98e2fc..5231f1d28 100644
--- a/mdk-stage1/ka.c
+++ b/mdk-stage1/ka.c
@@ -40,18 +40,18 @@ static void my_pause(void) {
read(0, &t, 1);
}
-static enum return_type ka_wait_for_stage2(void)
+static enum return_type ka_wait_for_stage2(int count)
{
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-o wner --sparse --file - )", NULL }; /* The command line for ka_launch */
+ 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);
+ close(1);
+ close(2);
execv(mkfs_launch[0], mkfs_launch); /* Formating the ramdisk */
printf("KA: Can't execute %s\n<press Enter>\n", mkfs_launch[0]);
my_pause();
@@ -64,7 +64,7 @@ static enum return_type ka_wait_for_stage2(void)
}
log_message("KA: Waiting for stage 2....");
- wait_message("Waiting for rescue from KA server");
+ wait_message("Waiting for rescue from KA server (Try %d/%d)", count, KA_MAX_RETRY);
pid_t pid; /* Process ID of the child process */
pid_t wpid; /* Process ID from wait() */
int status; /* Exit status from wait() */
@@ -74,9 +74,7 @@ static enum return_type ka_wait_for_stage2(void)
fprintf(stderr, "%s: Failed to fork()\n", strerror(errno));
exit(13);
} else if ( pid == 0 ) {
- fprintf(stderr, "%s: Failed to fork()\n", strerror(errno));
- exit(13);
- } else if ( pid == 0 ) {
+ // close(2);
execv(ka_launch[0], ka_launch);
} else {
// wpid = wait(&status); /* Child's exit status */
@@ -129,7 +127,7 @@ enum return_type perform_ka(void) {
log_message("KA: ka_wait_for_stage2");
do {
/* We are trying to get a valid stage 2 (rescue) */
- results=ka_wait_for_stage2();
+ results=ka_wait_for_stage2(server_failure);
if (results != RETURN_OK) {
return results;
} else {
@@ -160,6 +158,7 @@ enum return_type perform_ka(void) {
for (cpt=5; cpt>0; cpt--) {
wait_message("KA server not found ! (Try %d/%d in %d sec)",server_failure,KA_MAX_RETRY,cpt);
+ log_message("Ka not found %d/%d", server_failure,KA_MAX_RETRY);
sleep (1);
}
remove_wait_message();