Index: ka.h =================================================================== --- ka.h (revision 231044) +++ ka.h (working copy) @@ -16,5 +16,6 @@ #define KAERR_CANTFORK -20 enum return_type perform_ka(void); +enum return_type perform_dolly(void); #endif Index: automatic.c =================================================================== --- automatic.c (revision 231044) +++ automatic.c (working copy) @@ -80,7 +80,8 @@ { "netmask", "netm" }, { "adsluser", "adslu" }, { "adslpass", "adslp" }, { "hostname", "hos" }, { "domain", "dom" }, { "server", "ser" }, { "directory", "dir" }, { "user", "use" }, { "pass", "pas" }, { "disk", "dis" }, { "partition", "par" }, { "proxy_host", "proxh" }, - { "proxy_port", "proxp" }, { NULL, NULL } }; + { "proxy_port", "proxp" }, { NULL, NULL }, + { "proxy_port", "proxp" }, { "dolly_timeout", "dolt" }, { NULL, NULL } }; struct param_elem * ptr_alias = short_aliases; while (ptr_alias->name) { if (streq(auto_param, ptr_alias->name)) Index: network.c =================================================================== --- network.c (revision 231044) +++ network.c (working copy) @@ -506,6 +506,9 @@ domain = guess_domain_from_hostname(dnshostname); if (domain) { log_message("got hostname and domain from dns entry, %s and %s", dnshostname, domain); + // in fact there is no gethostbyname in stage1, so we use IP address has hostname + sethostname(inet_ntoa(intf->ip), strlen(inet_ntoa(intf->ip))); + return RETURN_OK; } } else @@ -1207,3 +1210,22 @@ return perform_ka(); } #endif + +#ifndef DISABLE_DOLLY +enum return_type dolly_prepare(void) +{ + enum return_type results; + + if (!ramdisk_possible()) { + stg1_error_message("Dolly install needs more than %d Mbytes of memory (detected %d Mbytes).", + MEM_LIMIT_DRAKX, total_memory()); + return RETURN_ERROR; + } + + results = intf_select_and_up(); + if (results != RETURN_OK) + return results; + + return perform_dolly(); +} +#endif Index: Makefile =================================================================== --- Makefile (revision 231044) +++ Makefile (working copy) @@ -99,9 +99,10 @@ DISKSRC = disk.c directory.c partition.c NETWORKSRC = network.c nfsmount.c dhcp.c url.c dns.c adsl.c directory.c wireless.c KASRC = ka.c +DOLLYSRC = dolly.c # use sort to remove duplicates -STAGE1_ALLSRC = $(sort $(STAGE1SRC) $(CDROMSRC) $(DISKSRC) $(NETWORKSRC) $(KASRC)) +STAGE1_ALLSRC = $(sort $(STAGE1SRC) $(CDROMSRC) $(DISKSRC) $(NETWORKSRC) $(KASRC) $(DOLLYSRC)) ALLSRC = $(INITSRC) $(STAGE1_ALLSRC) @@ -111,12 +112,12 @@ STAGE1OBJS-NETWORK = $(subst .c,-NETWORK.o,$(STAGE1SRC) $(NETWORKSRC)) -NETWORK_DEFS = -DSPAWN_SHELL -DDISABLE_CDROM -DDISABLE_DISK -DDISABLE_KA +NETWORK_DEFS = -DSPAWN_SHELL -DDISABLE_CDROM -DDISABLE_DISK -DDISABLE_KA -DDISABLE_DOLLY STAGE1OBJS-NETWORK-STANDALONE = $(subst .c,-NETWORK-STANDALONE.o,$(STAGE1SRC) $(NETWORKSRC)) -NETWORK_STANDALONE_DEFS = -DDISABLE_CDROM -DDISABLE_DISK -DENABLE_NETWORK_STANDALONE -DDISABLE_KA +NETWORK_STANDALONE_DEFS = -DDISABLE_CDROM -DDISABLE_DISK -DENABLE_NETWORK_STANDALONE -DDISABLE_KA -DDISABLE_DOLLY STAGE1OBJS-FULL = $(subst .c,-FULL.o,$(STAGE1_ALLSRC)) @@ -134,11 +135,13 @@ ifeq (i386,$(ARCH)) PCMCIA_LIB = pcmcia/libpcmcia.a sysfs/libsysfs.a -PCMCIA_DEFS = -DENABLE_PCMCIA +PCMCIA_DEFS = +#-DENABLE_PCMCIA endif ifeq (x86_64,$(ARCH)) PCMCIA_LIB = pcmcia/libpcmcia.a sysfs/libsysfs.a -PCMCIA_DEFS = -DENABLE_PCMCIA +PCMCIA_DEFS = +#-DENABLE_PCMCIA endif Index: network.h =================================================================== --- network.h (revision 231044) +++ network.h (working copy) @@ -34,8 +34,12 @@ #ifndef DISABLE_KA enum return_type ka_prepare(void); #endif +#ifndef DISABLE_DOLLY +enum return_type dolly_prepare(void); +#endif + enum boot_proto_type { BOOTPROTO_STATIC, BOOTPROTO_DHCP, BOOTPROTO_ADSL_PPPOE }; enum auto_detection_type { AUTO_DETECTION_NONE, AUTO_DETECTION_ALL, AUTO_DETECTION_WIRED }; Index: stage1.c =================================================================== --- stage1.c (revision 231044) +++ stage1.c (working copy) @@ -266,7 +266,11 @@ #ifndef DISABLE_KA char * network_ka_install = "KA server"; char * network_ka_install_auto = "ka"; #endif +#ifndef DISABLE_DOLLY + char * network_dolly_install = "Dolly Client"; char * network_dolly_install_auto = "dolly"; #endif + +#endif char * thirdparty_install = "Load third party modules"; char * thirdparty_install_auto = "thirdparty"; i = 0; @@ -277,7 +281,11 @@ #ifndef DISABLE_KA means[i] = network_ka_install; means_auto[i++] = network_ka_install_auto; #endif +#ifndef DISABLE_DOLLY + means[i] = network_dolly_install; means_auto[i++] = network_dolly_install_auto; #endif + +#endif #ifndef DISABLE_CDROM means[i] = cdrom_install; means_auto[i++] = cdrom_install_auto; #endif @@ -318,7 +326,11 @@ if (!strcmp(choice, network_ka_install)) results = ka_prepare(); #endif +#ifndef DISABLE_DOLLY + if (!strcmp(choice, network_dolly_install)) + results = dolly_prepare(); #endif +#endif if (!strcmp(choice, thirdparty_install)) { thirdparty_load_modules(); Index: stage1.h =================================================================== --- stage1.h (revision 231044) +++ stage1.h (working copy) @@ -53,6 +53,8 @@ #define IS_RECOVERY (get_param(MODE_RECOVERY)) #define KEEP_MOUNTED (!IS_RESCUE || get_param(MODE_KEEP_MOUNTED)) +#define DOLLY_MAX_RETRY 3 + void fatal_error(char *msg) __attribute__ ((noreturn)); Index: ka.c =================================================================== --- ka.c (revision 231044) +++ ka.c (working copy) @@ -40,18 +40,18 @@ 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 /sysroot/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\n", mkfs_launch[0]); my_pause(); @@ -64,7 +64,7 @@ } 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 @@ 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 @@ 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 @@ 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();