From 017cb4cb15fbaa04825ba106e805a87a1d5ff78c Mon Sep 17 00:00:00 2001 From: John Franklin Date: Sat, 27 Apr 2019 20:04:56 -0500 Subject: [PATCH 01/10] Handle trailing newline in keyfile. --- vere/sist.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 4a0d1f2966..72e7159915 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1359,6 +1359,22 @@ u3_sist_boot(void) if ( 0 != u3_Host.ops_u.key_c ) { u3_noun des = u3m_file(u3_Host.ops_u.key_c); + + // handle trailing newline + // + { + c3_c* key_c = u3r_string(des); + c3_w len_w = strlen(key_c); + + if (len_w && (key_c[len_w - 1] == '\n')) { + key_c[len_w - 1] = '\0'; + u3z(des); + des = u3i_string(key_c); + } + + free(key_c); + } + sed = sist_key(des); } else if ( 0 != u3_Host.ops_u.gen_c ) { From e43da61505b2bc9aa6da965ac89417ae59197ecb Mon Sep 17 00:00:00 2001 From: Joseph Lukasik Date: Wed, 1 May 2019 13:24:34 -0700 Subject: [PATCH 02/10] Add `git` to default.nix dependencies Fixes a "No such file or directory: 'git': 'git'" error in running ./scripts/nixbuild on NixOS --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index b21daad11a..46112cd350 100644 --- a/default.nix +++ b/default.nix @@ -17,7 +17,7 @@ let with darwin.apple_sdk.frameworks; [ Cocoa CoreServices ]); - deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib + deps = [ cmark curl gcc git gmp libsigsegv meson ncurses ninja pkgconfig zlib re2c openssl ]; isGitDir = (path: type: type != "directory" || baseNameOf path != ".git"); From 3c1366180b1019977ea27261f81cf8b4cffa9791 Mon Sep 17 00:00:00 2001 From: Joseph Lukasik Date: Wed, 1 May 2019 15:18:51 -0700 Subject: [PATCH 03/10] Update link to docs for swap space help --- noun/manage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/manage.c b/noun/manage.c index d18138ae31..1153810eb8 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1527,7 +1527,7 @@ u3m_init(void) -1, 0); fprintf(stderr, "boot: mapping %dMB failed\r\n", (len_w / (1024 * 1024))); - fprintf(stderr, "see urbit.org/docs/getting-started#swap for adding swap space\r\n"); + fprintf(stderr, "see urbit.org/docs/getting-started/installing-urbit/#swap for adding swap space\r\n"); if ( -1 != (c3_ps)map_v ) { fprintf(stderr, "if porting to a new platform, try U3_OS_LoomBase %p\r\n", From 1604313207c71a1f506d3be20c5c91b0d41c4329 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 2 May 2019 10:42:26 -0700 Subject: [PATCH 04/10] removes duplicate manage.c init, fixes call sites --- pkg/urbit/noun/manage.c | 49 ++--------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 2a5c65c6f4..5bea1da68a 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1603,51 +1603,6 @@ u3m_init(void) } } -/* _cm_init_new(): start the environment. -*/ -void -_cm_init_new(void) -{ - _cm_limits(); - _cm_signals(); - - /* Make sure GMP uses our malloc. - */ - mp_set_memory_functions(u3a_malloc, u3a_realloc2, u3a_free2); - - /* Map at fixed address. - */ - { - c3_w len_w = u3a_bytes; - void* map_v; - - map_v = mmap((void *)u3_Loom, - len_w, - (PROT_READ | PROT_WRITE), - (MAP_ANON | MAP_FIXED | MAP_PRIVATE), - -1, 0); - - if ( -1 == (c3_ps)map_v ) { - void* dyn_v = mmap((void *)0, - len_w, - PROT_READ, - MAP_ANON | MAP_PRIVATE, - -1, 0); - - u3l_log("boot: mapping %dMB failed\r\n", (len_w / (1024 * 1024))); - u3l_log("see urbit.org/docs/getting-started/installing-urbit/#swap" - "for adding swap space\r\n"); - if ( -1 != (c3_ps)map_v ) { - u3l_log("if porting to a new platform, try U3_OS_LoomBase %p\r\n", - dyn_v); - } - exit(1); - } - - u3l_log("loom: mapped %dMB\r\n", len_w >> 20); - } -} - // XX orphaned, find a way to restore #if 0 /* _get_cmd_output(): Run a shell command and capture its output. @@ -1886,7 +1841,7 @@ u3m_boot_new(c3_c* dir_c) /* Activate the loom. */ - _cm_init_new(); + u3m_init(); /* Activate the storage system. */ @@ -1935,7 +1890,7 @@ u3m_boot_pier(void) { /* Activate the loom. */ - _cm_init_new(); + u3m_init(); /* Activate tracing. */ From 1565eede9445317378c552618e17752cd9ac4f93 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 2 May 2019 10:46:19 -0700 Subject: [PATCH 05/10] removes obsolete u3m_boot, renames new boot functions --- pkg/urbit/include/noun/manage.h | 14 +- pkg/urbit/noun/manage.c | 237 +------------------------------- pkg/urbit/vere/daemon.c | 2 +- pkg/urbit/worker/main.c | 2 +- 4 files changed, 10 insertions(+), 245 deletions(-) diff --git a/pkg/urbit/include/noun/manage.h b/pkg/urbit/include/noun/manage.h index 4efed35ef8..3affdafa1c 100644 --- a/pkg/urbit/include/noun/manage.h +++ b/pkg/urbit/include/noun/manage.h @@ -4,21 +4,15 @@ */ /** System management. **/ - /* u3m_boot(): start the u3 system. - */ - void - u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c); - - /* u3m_boot_new(): start the u3 system (new). return next event, - ** starting from 1. + /* u3m_boot(): start the u3 system. return next event, starting from 1. */ c3_d - u3m_boot_new(c3_c* dir_c); + u3m_boot(c3_c* dir_c); - /* u3m_boot_pier(): start without checkpointing. + /* u3m_boot_lite(): start without checkpointing. */ c3_d - u3m_boot_pier(void); + u3m_boot_lite(void); /* u3m_bail(): bail out. Does not return. ** diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 5bea1da68a..0096e6f666 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1603,239 +1603,10 @@ u3m_init(void) } } -// XX orphaned, find a way to restore -#if 0 -/* _get_cmd_output(): Run a shell command and capture its output. - Exits with an error if the command fails or produces no output. - The 'out_c' parameter should be an array of sufficient length to hold - the command's output, up to a max of len_c characters. -*/ -static void -_get_cmd_output(c3_c *cmd_c, c3_c *out_c, c3_w len_c) -{ - FILE *fp = popen(cmd_c, "r"); - if ( NULL == fp ) { - u3l_log("'%s' failed\n", cmd_c); - exit(1); - } - - if ( NULL == fgets(out_c, len_c, fp) ) { - u3l_log("'%s' produced no output\n", cmd_c); - exit(1); - } - - pclose(fp); -} - -/* _arvo_hash(): get a shortened hash of the last git commit - that modified the sys/ directory in arvo. - hax_c must be an array with length >= 11. -*/ -static void -_arvo_hash(c3_c *out_c, c3_c *arv_c) -{ - c3_c cmd_c[2048]; - - sprintf(cmd_c, "git -C %s log -1 HEAD --format=%%H -- sys/", arv_c); - _get_cmd_output(cmd_c, out_c, 11); - - out_c[10] = 0; // end with null-byte -} - -/* _git_pill_url(): produce a URL from which to download a pill - based on the location of an arvo git repository. -*/ -static void -_git_pill_url(c3_c *out_c, c3_c *arv_c) -{ - c3_c hax_c[11]; - - assert(NULL != arv_c); - - if ( 0 != system("which git >> /dev/null") ) { - u3l_log("Could not find git executable\n"); - exit(1); - } - - _arvo_hash(hax_c, arv_c); - sprintf(out_c, "https://bootstrap.urbit.org/git-%s.pill", hax_c); -} -#endif - -// XX deprecated, remove -#if 0 -/* _boot_home(): create ship directory. -*/ -static void -_boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c) -{ - c3_c* nam_c = "urbit.pill"; - c3_c ful_c[2048]; - - /* Create subdirectories. */ - { - mkdir(dir_c, 0700); - - snprintf(ful_c, 2048, "%s/.urb", dir_c); - mkdir(ful_c, 0700); - - snprintf(ful_c, 2048, "%s/.urb/get", dir_c); - mkdir(ful_c, 0700); - - snprintf(ful_c, 2048, "%s/.urb/put", dir_c); - mkdir(ful_c, 0700); - - snprintf(ful_c, 2048, "%s/.urb/sis", dir_c); - mkdir(ful_c, 0700); - } - /* Copy urbit.pill. */ - { - { - struct stat s; - snprintf(ful_c, 2048, "%s/.urb/%s", dir_c, nam_c); - if ( stat(ful_c, &s) == 0 ) { - /* we're in a "logical boot". awful hack, but bail here */ - u3l_log("%s confirmed to exist\r\n", ful_c); - return; - } - } - - /* Copy local pill file. */ - if ( pil_c != 0 ) { - snprintf(ful_c, 2048, "cp %s %s/.urb/%s", - pil_c, dir_c, nam_c); - u3l_log("%s\r\n", ful_c); - if ( 0 != system(ful_c) ) { - u3l_log("could not %s\n", ful_c); - exit(1); - } - } - /* Fetch remote pill over HTTP. */ - else { - CURL *curl; - CURLcode result; - FILE *file; - c3_c pil_c[2048]; - long cod_l; - - /* use arvo git hash and branch for pill url unless overridden */ - if ( NULL == url_c ) { - url_c = pil_c; - _git_pill_url(url_c, arv_c); - } - - snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c); - u3l_log("fetching %s to %s\r\n", url_c, ful_c); - if ( !(curl = curl_easy_init()) ) { - u3l_log("failed to initialize libcurl\n"); - exit(1); - } - if ( !(file = fopen(ful_c, "w")) ) { - u3l_log("failed to open %s\n", ful_c); - exit(1); - } - curl_easy_setopt(curl, CURLOPT_URL, url_c); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); - result = curl_easy_perform(curl); - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l); - fclose(file); - if ( CURLE_OK != result ) { - u3l_log("failed to fetch %s: %s\n", - url_c, curl_easy_strerror(result)); - u3l_log("please fetch it manually and specify the location with -B\n"); - exit(1); - } - if ( 300 <= cod_l ) { - u3l_log("error fetching %s: HTTP %ld\n", url_c, cod_l); - u3l_log("please fetch it manually and specify the location with -B\n"); - exit(1); - } - curl_easy_cleanup(curl); - } - } -} -#endif - -// XX deprecated, remove -#if 0 -/* u3m_boot(): start the u3 system (old). -*/ -void -u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, - c3_c *pil_c, c3_c *url_c, c3_c *arv_c) -{ - /* Activate the loom. - */ - u3m_init(); - - /* Activate the storage system. - */ - nuu_o = u3e_live(nuu_o, dir_c); - - /* Activate tracing. - */ - u3t_init(); - - /* Construct or activate the allocator. - */ - u3m_pave(nuu_o, bug_o); - - /* Initialize the jet system. - */ - u3j_boot(nuu_o); - - /* Install or reactivate the kernel. - */ - if ( _(nuu_o) ) { - c3_c ful_c[2048]; - - _boot_home(dir_c, pil_c, url_c, arv_c); - - snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c); - u3l_log("boot: loading %s\r\n", ful_c); - - { - u3_noun pil = u3m_file(ful_c); - u3_noun sys, bot; - - { - u3_noun pro = u3m_soft(0, u3ke_cue, u3k(pil)); - - if ( 0 != u3h(pro) ) { - u3l_log("boot: failed: unable to parse pill\r\n"); - exit(1); - } - - sys = u3k(u3t(pro)); - u3z(pro); - } - - // XX confirm trel of lists? - // - if ( c3n == u3r_trel(sys, &bot, 0, 0) ) { - u3l_log("boot: failed: obsolete pill structure\r\n"); - exit(1); - } - - u3v_boot(u3k(bot)); - - u3z(sys); - u3z(pil); - } - } - else { - u3v_hose(); - u3j_ream(); - u3n_ream(); - } -} -#endif - -/* u3m_boot_new(): start the u3 system (new). return next event, -** starting from 1. +/* u3m_boot(): start the u3 system. return next event, starting from 1. */ c3_d -u3m_boot_new(c3_c* dir_c) +u3m_boot(c3_c* dir_c) { c3_o nuu_o; @@ -1883,10 +1654,10 @@ u3m_boot_new(c3_c* dir_c) } } -/* u3m_boot_pier(): start without checkpointing. +/* u3m_boot_lite(): start without checkpointing. */ c3_d -u3m_boot_pier(void) +u3m_boot_lite(void) { /* Activate the loom. */ diff --git a/pkg/urbit/vere/daemon.c b/pkg/urbit/vere/daemon.c index 1612a78d9a..67469bafbe 100644 --- a/pkg/urbit/vere/daemon.c +++ b/pkg/urbit/vere/daemon.c @@ -840,7 +840,7 @@ u3_daemon_commence() sag_w = u3C.wag_w; u3C.wag_w |= u3o_hashless; - u3m_boot_pier(); + u3m_boot_lite(); // wire up signal controls // diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 924c2d0a32..08aa0b8a5a 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -928,7 +928,7 @@ main(c3_i argc, c3_c* argv[]) /* boot image */ { - u3V.sen_d = u3V.dun_d = u3m_boot_new(dir_c); + u3V.sen_d = u3V.dun_d = u3m_boot(dir_c); u3C.stderr_log_f = _worker_send_stdr; u3C.slog_f = _worker_send_slog; } From 08a181a6e20999e7ec2921a578fca5835df6a176 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 2 May 2019 11:35:52 -0700 Subject: [PATCH 06/10] removes obsolete u3v functions, refactor u3v_boot(_lite) --- pkg/urbit/include/noun/vortex.h | 29 +--- pkg/urbit/noun/trace.c | 2 +- pkg/urbit/noun/vortex.c | 246 ++++++++++---------------------- pkg/urbit/vere/daemon.c | 5 +- pkg/urbit/worker/main.c | 33 +---- 5 files changed, 86 insertions(+), 229 deletions(-) diff --git a/pkg/urbit/include/noun/vortex.h b/pkg/urbit/include/noun/vortex.h index b809550e70..c8a5296a79 100644 --- a/pkg/urbit/include/noun/vortex.h +++ b/pkg/urbit/include/noun/vortex.h @@ -39,36 +39,16 @@ /** Functions. **/ - /* u3v_do(): use a kernel function. - */ - u3_noun - u3v_do(const c3_c* txt_c, u3_noun arg); - /* u3v_boot(): evaluate boot sequence, making a kernel */ - void + c3_o u3v_boot(u3_noun eve); /* u3v_boot_lite(): light bootstrap sequence, just making a kernel. */ - void + c3_o u3v_boot_lite(u3_noun lit); - /* u3v_start(): start time. - */ - void - u3v_start(u3_noun now); - - /* u3v_arm(): load a kernel arm. - */ - u3_noun - u3v_arm(const c3_c* txt_c); - - /* u3v_pike(): poke with floating core. - */ - u3_noun - u3v_pike(u3_noun ovo, u3_noun cor); - /* u3v_do(): use a kernel function. */ u3_noun @@ -119,11 +99,6 @@ void u3v_plan(u3_noun pax, u3_noun fav); - /* u3v_plow(): queue multiple ova (external). - */ - void - u3v_plow(u3_noun ova); - /* u3v_mark(): mark arvo kernel. */ c3_w diff --git a/pkg/urbit/noun/trace.c b/pkg/urbit/noun/trace.c index c6c1f3bf53..5e9814296e 100644 --- a/pkg/urbit/noun/trace.c +++ b/pkg/urbit/noun/trace.c @@ -77,7 +77,7 @@ u3t_heck(u3_atom cog) u3R = &(u3H->rod_u); { if ( 0 == u3R->pro.day ) { - u3R->pro.day = u3v_do("doss", 0); + u3R->pro.day = u3do("doss", 0); } u3R->pro.day = u3dc("pi-heck", u3i_string(str_c), u3R->pro.day); } diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index ec0624fc77..7da37130d4 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -8,6 +8,80 @@ #define _CVX_POKE 47 #define _CVX_PEEK 46 +/* _cv_life(): execute initial lifecycle, producing Arvo core. +*/ +u3_noun +_cv_life(u3_noun eve) +{ + u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2)); + u3_noun gat = u3n_nock_on(eve, lyf); + u3_noun cor = u3k(u3x_at(7, gat)); + + u3z(gat); + return cor; +} + +/* u3v_boot(): evaluate boot sequence, making a kernel +*/ +c3_o +u3v_boot(u3_noun eve) +{ + u3_noun pro; + + // ensure zero-initialized kernel + // + u3A->roc = 0; + + pro = u3m_soft(0, _cv_life, eve); + + if ( u3_blip != u3h(pro) ) { + u3z(pro); + return c3n; + } + + u3A->roc = u3k(u3t(pro)); + + u3z(pro); + return c3y; +} + +/* _cv_lite(): load lightweight, core-only pill. +*/ +u3_noun +_cv_lite(u3_noun pil) +{ + u3_noun arv = u3ke_cue(pil); + u3_noun eve, pro; + + u3x_trel(arv, &eve, 0, 0); + + u3l_log("lite: arvo formula %x\r\n", u3r_mug(arv)); + pro = _cv_life(eve); + u3l_log("lite: core %x\r\n", u3r_mug(pro)); + + u3z(arv); + return pro; +} + +/* u3v_boot_lite(): light bootstrap sequence, just making a kernel. +*/ +c3_o +u3v_boot_lite(u3_atom lit) +{ + u3_noun pro = u3m_soft(0, _cv_lite, lit); + + if ( u3_blip != u3h(pro) ) { + u3z(pro); + return c3n; + } + + u3A->roc = u3k(u3t(pro)); + u3l_log("lite: final state %x\r\n", u3r_mug(u3A->roc)); + + u3z(pro); + return c3y; +} + /* _cv_nock_wish(): call wish through hardcoded interface. */ static u3_noun @@ -21,144 +95,6 @@ _cv_nock_wish(u3_noun txt) return pro; } -/* u3v_boot(): evaluate boot sequence, making a kernel -*/ -void -u3v_boot(u3_noun eve) -{ - u3_noun cor; - - // ensure zero-initialized kernel - // - u3A->roc = 0; - - { - // default namespace function: |=(a/{* *} ~) - // - u3_noun gul = u3nt(u3nt(1, 0, 0), 0, 0); - // lifecycle formula - // - u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2)); - // evalute lifecycle formula against the boot sequence - // in a virtualization context - // - u3_noun pro = u3m_soft_run(gul, u3n_nock_on, eve, lyf); - - if ( 0 != u3h(pro) ) { - u3l_log("boot: failed: invalid boot sequence (from pill)\r\n"); - u3z(pro); - return; - } - - cor = u3k(u3t(pro)); - u3z(pro); - } - - // save the Arvo core (at +7 of the Arvo gate) - // - u3A->roc = u3k(u3x_at(7, cor)); - u3z(cor); -} - -/* u3v_fire(): execute initial lifecycle. -*/ -u3_noun -u3v_fire(u3_noun sys) -{ - u3_noun fol = u3nt(2, u3nc(0, 3), u3nc(0, 2)); - - return u3n_nock_on(sys, fol); -} - -/* u3v_load(): loading sequence. -*/ -u3_noun -u3v_load(u3_noun pil) -{ - u3_noun sys = u3ke_cue(pil); - - u3l_log("load: mug: %x\r\n", u3r_mug(sys)); - { - u3_noun cor = u3v_fire(sys); - u3_noun pro; - - pro = u3k(u3r_at(7, cor)); - - u3z(cor); - return pro; - } -} - -/* u3v_lite(): load lightweight, core-only pill. -*/ -u3_noun -u3v_lite(u3_noun pil) -{ - u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2)); - u3_noun arv = u3ke_cue(pil); - u3_noun bot, cor, pro; - - u3x_trel(arv, &bot, 0, 0); - - u3l_log("lite: arvo formula %x\r\n", u3r_mug(arv)); - cor = u3n_nock_on(bot, lyf); - u3l_log("lite: core %x\r\n", u3r_mug(cor)); - - pro = u3k(u3r_at(7, cor)); - - u3z(cor); - u3z(arv); - return pro; -} - -// XX deprecated, remove -#if 0 -/* u3v_boot(): correct bootstrap sequence. -*/ -void -u3v_boot(c3_c* pas_c) -{ - u3_noun pru; - - if ( !u3A->sys ) { - u3A->sys = u3m_file(pas_c); - } - - pru = u3m_soft(0, u3v_load, u3k(u3A->sys)); - - if ( u3h(pru) != 0 ) { - u3l_log("boot failed\r\n"); - exit(1); - } - - u3l_log("boot: final state %x\r\n", u3r_mug(u3t(pru))); - - u3A->ken = 0; - u3A->roc = u3k(u3t(pru)); - - u3z(pru); -} -#endif - -/* u3v_boot_lite(): light bootstrap sequence, just making a kernel. -*/ -void -u3v_boot_lite(u3_atom lit) -{ - u3_noun pru = u3m_soft(0, u3v_lite, lit); - - if ( u3h(pru) != 0 ) { - u3l_log("boot failed\r\n"); - exit(1); - } - - u3l_log("lite: final state %x\r\n", u3r_mug(u3t(pru))); - - u3A->roc = u3k(u3t(pru)); - - u3z(pru); -} - /* u3v_wish(): text expression with cache. */ u3_noun @@ -185,40 +121,6 @@ u3v_wish(const c3_c* str_c) return exp; } -// XX deprecated, remove -#if 0 -/* _cv_mung(): formula wrapper with gate and sample. -*/ - static u3_noun - _cv_mung_in(u3_noun gam) - { - u3_noun pro = u3n_slam_on(u3k(u3h(gam)), u3k(u3t(gam))); - - u3z(gam); return pro; - } -static u3_noun -_cv_mung(c3_w sec_w, u3_noun gat, u3_noun sam) -{ - u3_noun gam = u3nc(gat, sam); - - return u3m_soft(0, _cv_mung_in, gam); -} -#endif - -// XX deprecated, remove -#if 0 -/* u3v_pike(): poke with floating core. -*/ -u3_noun -u3v_pike(u3_noun ovo, u3_noun cor) -{ - u3_noun fun = u3n_nock_on(cor, u3k(u3x_at(_CVX_POKE, cor))); - u3_noun sam = u3nc(u3k(u3A->now), ovo); - - return _cv_mung(0, fun, sam); -} -#endif - /* _cv_nock_poke(): call poke through hardcoded interface. */ static u3_noun diff --git a/pkg/urbit/vere/daemon.c b/pkg/urbit/vere/daemon.c index 67469bafbe..bdf9e14e7e 100644 --- a/pkg/urbit/vere/daemon.c +++ b/pkg/urbit/vere/daemon.c @@ -862,7 +862,10 @@ u3_daemon_commence() lit = u3i_bytes(u3_Ivory_length_w, u3_Ivory_pill_y); } - u3v_boot_lite(lit); + if ( c3n == u3v_boot_lite(lit)) { + u3l_log("lite: boot failed\r\n"); + exit(1); + } } /* listen on command socket diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 08aa0b8a5a..1a37ca7750 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -597,22 +597,6 @@ _worker_work_live(c3_d evt_d, u3_noun job) } } -/* _worker_boot_fire(): execute boot sequence. -*/ -static u3_noun -_worker_boot_fire(u3_noun eve) -{ - // XX virtualize? use u3v_boot? - // - u3_noun cor = u3n_nock_on(eve, u3nt(2, u3nc(0, 3), u3nc(0, 2))); - u3_noun pro; - - pro = u3k(u3r_at(7, cor)); - - u3z(cor); - return pro; -} - /* _worker_work_boot(): apply initial-stage event. */ static void @@ -629,28 +613,21 @@ _worker_work_boot(c3_d evt_d, u3_noun job) u3l_log("work: (%" PRIu64 ")| boot\r\n", evt_d); if ( u3V.len_w == evt_d ) { - u3_noun eve, pru; - - eve = u3kb_flop(u3V.roe); - u3V.roe = u3_nul; + u3_noun eve = u3kb_flop(u3V.roe); + u3V.roe = u3_nul; u3l_log("work: (%" PRIu64 ")| pill: %x\r\n", evt_d, u3r_mug(eve)); - pru = u3m_soft(0, _worker_boot_fire, eve); - - if ( u3_blip != u3h(pru) ) { - u3l_log("boot failed\r\n"); + if ( c3n == u3v_boot(eve) ) { + u3l_log("work: boot failed: invalid sequence (from pill)\r\n"); exit(1); } u3V.dun_d = evt_d; - u3A->ent_d = u3V.dun_d; - u3A->roc = u3k(u3t(pru)); u3V.mug_l = u3r_mug(u3A->roc); + u3A->ent_d = u3V.dun_d; u3l_log("work: (%" PRIu64 ")| core: %x\r\n", evt_d, u3V.mug_l); - - u3z(pru); } else { // prior to the evaluation of the entire lifecycle sequence, From ff0be870012376295b2b06b50d617db75478461f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 2 May 2019 15:27:02 -0700 Subject: [PATCH 07/10] removes unused .sys member of persistent u3A struct --- pkg/urbit/include/noun/vortex.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/urbit/include/noun/vortex.h b/pkg/urbit/include/noun/vortex.h index c8a5296a79..ddcac0d711 100644 --- a/pkg/urbit/include/noun/vortex.h +++ b/pkg/urbit/include/noun/vortex.h @@ -15,9 +15,6 @@ u3_noun sen; // instance string u3_noun our; // identity u3_noun fak; // c3y is fake - - u3_noun sys; // system pill - u3_noun roc; // kernel core } u3v_arvo; From a16450f62f14820192bc3c2534bff4274faec11b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 2 May 2019 17:10:09 -0700 Subject: [PATCH 08/10] use static keyword for local vortex.c functions --- pkg/urbit/noun/vortex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 7da37130d4..c4ae2adfb9 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -10,7 +10,7 @@ /* _cv_life(): execute initial lifecycle, producing Arvo core. */ -u3_noun +static u3_noun _cv_life(u3_noun eve) { u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2)); @@ -47,7 +47,7 @@ u3v_boot(u3_noun eve) /* _cv_lite(): load lightweight, core-only pill. */ -u3_noun +static u3_noun _cv_lite(u3_noun pil) { u3_noun arv = u3ke_cue(pil); From dc1bf0c7d215860515519c1a249add7ca0a2e642 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 3 May 2019 08:12:17 -0700 Subject: [PATCH 09/10] refactors u3v_boot/_lite, fixes reference miscount --- pkg/urbit/noun/vortex.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index c4ae2adfb9..cec664053b 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -26,22 +26,22 @@ _cv_life(u3_noun eve) c3_o u3v_boot(u3_noun eve) { - u3_noun pro; - // ensure zero-initialized kernel // u3A->roc = 0; - pro = u3m_soft(0, _cv_life, eve); + { + u3_noun pro = u3m_soft(0, _cv_life, eve); - if ( u3_blip != u3h(pro) ) { + if ( u3_blip != u3h(pro) ) { + u3z(pro); + return c3n; + } + + u3A->roc = u3k(u3t(pro)); u3z(pro); - return c3n; } - u3A->roc = u3k(u3t(pro)); - - u3z(pro); return c3y; } @@ -56,7 +56,7 @@ _cv_lite(u3_noun pil) u3x_trel(arv, &eve, 0, 0); u3l_log("lite: arvo formula %x\r\n", u3r_mug(arv)); - pro = _cv_life(eve); + pro = _cv_life(u3k(eve)); u3l_log("lite: core %x\r\n", u3r_mug(pro)); u3z(arv); @@ -68,17 +68,24 @@ _cv_lite(u3_noun pil) c3_o u3v_boot_lite(u3_atom lit) { - u3_noun pro = u3m_soft(0, _cv_lite, lit); + // ensure zero-initialized kernel + // + u3A->roc = 0; - if ( u3_blip != u3h(pro) ) { + { + u3_noun pro = u3m_soft(0, _cv_lite, lit); + + if ( u3_blip != u3h(pro) ) { + u3z(pro); + return c3n; + } + + u3A->roc = u3k(u3t(pro)); u3z(pro); - return c3n; } - u3A->roc = u3k(u3t(pro)); u3l_log("lite: final state %x\r\n", u3r_mug(u3A->roc)); - u3z(pro); return c3y; } From f3867966bb4e3a7211ab884d5e675233ab38f3c8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 3 May 2019 08:13:50 -0700 Subject: [PATCH 10/10] fixes u3m_soft early-return bail type --- pkg/urbit/noun/manage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 0096e6f666..b98822bcca 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1206,7 +1206,7 @@ u3m_soft(c3_w sec_w, // if ( 0 == u3A->roc ) { u3z(why); - return u3nc(2, u3_nul); + return u3nc(c3__fail, u3_nul); } else { u3_noun tax, cod, pro, mok;