Merge remote-tracking branch 'ray/kingdom'

king.c and king protocol
This commit is contained in:
Raymond Pasco 2017-03-03 09:02:13 -05:00
commit 58efee0a82
10 changed files with 641 additions and 219 deletions

View File

@ -358,6 +358,7 @@ V_OFILES=\
vere/unix.o \
vere/save.o \
vere/serf.o \
vere/king.o \
vere/pier.o \
vere/foil.o \
vere/walk.o \
@ -405,6 +406,7 @@ links: urbit
$(LN) $(BIN)/urbit $(BIN)/urbit-worker
urbit: $(BIN)/urbit
booter: $(BIN)/booter
$(LIBED25519):
$(MAKE) -C outside/ed25519

View File

@ -25,6 +25,7 @@
# define c3__ash c3_s3('a','s','h')
# define c3__at c3_s2('a','t')
# define c3__atom c3_s4('a','t','o','m')
# define c3__auth c3_s4('a','u','t','h')
# define c3__axe c3_s3('a','x','e')
# define c3__axil c3_s4('a','x','i','l')
# define c3__axis c3_s4('a','x','i','s')
@ -312,6 +313,7 @@
# define c3__dojo c3_s4('d','o','j','o')
# define c3__dome c3_s4('d','o','m','e')
# define c3__done c3_s4('d','o','n','e')
# define c3__doom c3_s4('d','o','o','m')
# define c3__door c3_s4('d','o','o','r')
# define c3__dorn c3_s4('d','o','r','n')
# define c3__dost c3_s4('d','o','s','t')
@ -800,6 +802,7 @@
# define c3__pesk c3_s4('p','e','s','k')
# define c3__pfix c3_s4('p','f','i','x')
# define c3__pick c3_s4('p','i','c','k')
# define c3__pier c3_s4('p','i','e','r')
# define c3__pike c3_s4('p','i','k','e')
# define c3__pile c3_s4('p','i','l','e')
# define c3__pill c3_s4('p','i','l','l')
@ -1030,6 +1033,7 @@
# define c3__sub c3_s3('s','u','b')
# define c3__sunt c3_s4('s','u','n','t')
# define c3__sure c3_s4('s','u','r','e')
# define c3__susp c3_s4('s','u','s','p')
# define c3__sym c3_s3('s','y','m')
# define c3__sync c3_s4('s','y','n','c')
# define c3__sys c3_s3('s','y','s')
@ -1156,6 +1160,7 @@
# define c3__veer c3_s4('v','e','e','r')
# define c3__vega c3_s4('v','e','g','a')
# define c3__velt c3_s4('v','e','l','t')
# define c3__vent c3_s4('v','e','n','t')
# define c3__verb c3_s4('v','e','r','b')
# define c3__vern c3_s4('v','e','r','n')
# define c3__very c3_s4('v','e','r','y')

View File

@ -232,9 +232,9 @@
*/
typedef struct _u3_moat {
uv_pipe_t pyp_u; // input stream
u3_bail bal_f; // error response function
void* vod_p; // callback pointer
u3_poke pok_f; // action function
u3_bail bal_f; // error response function
struct _u3_mess* mes_u; // message in progress
c3_d len_d; // length of stray bytes
c3_y* rag_y; // stray bytes
@ -247,6 +247,18 @@
u3_bail bal_f; // error response function
} u3_mojo;
/* u3_moor: two-way message stream, linked list */
typedef struct _u3_moor {
uv_pipe_t pyp_u;
u3_bail bal_f;
void* vod_p;
u3_poke pok_f;
struct _u3_mess* mes_u;
c3_d len_d;
c3_y* rag_y;
struct _u3_moor* nex_u;
} u3_moor;
/* u3_foil: abstract chub-addressed file.
*/
typedef struct _u3_foil {
@ -439,7 +451,6 @@
uv_check_t syn_u; // fs sync check
uv_timer_t tim_u; // timer
u3_umon* mon_u; // mount points
u3_usig* sig_u; // signal list
c3_o alm; // timer set
c3_o dyr; // ready to update
#ifdef SYNCLOG
@ -640,14 +651,12 @@
c3_c* dir_c; // pier path (no trailing /)
c3_d now_d; // event tick
uv_loop_t* lup_u; // libuv event loop
u3_usig* sig_u; // signal list
u3_http* htp_u; // http servers
u3_cttp ctp_u; // http clients
u3_utel tel_u; // telnet listener
u3_utty* uty_u; // linked terminal list
u3_save sav_u; // autosave
u3_opts ops_u; // commandline options
u3_unix unx_u; // sync and clay
u3_behn teh_u; // behn timer
c3_o liv; // if u3_no, shut down
c3_i xit_i; // exit code for shutdown
void* ssl_u; // struct SSL_CTX*
@ -716,13 +725,17 @@
*/
typedef struct _u3_pier {
c3_c* pax_c; // pier directory
c3_c* sys_c; // pill directory
c3_c* sys_c; // pill file
c3_c* arv_c; // arvo directory
c3_d gen_d; // last event discovered
c3_d but_d; // boot barrier
c3_d key_d[4]; // save and passkey
u3_disk* log_u; // event log
u3_lord* god_u; // computer
u3_ames* sam_u; // packet interface
u3_ames* sam_u; // packet interface
u3_behn* teh_u; // behn timer
u3_unix* unx_u; // sync and clay
u3_save* sav_u; // autosave
u3_writ* ent_u; // entry of queue
u3_writ* ext_u; // exit of queue
} u3_pier;
@ -733,10 +746,10 @@
c3_w len_w; // number of lords used
c3_w all_w; // number of lords allocated
u3_pier** tab_u; // lord table
uv_pipe_t cmd_u; // command socket
u3_moor* cli_u; // connected clients
} u3_king;
static u3_king u3K;
# define u3L u3_Host.lup_u // global event loop
# define u3Z (&(u3_Raft))
# define u3S u3_Host.ssl_u
@ -1146,89 +1159,89 @@
/* u3_save_ef_chld(): report SIGCHLD.
*/
void
u3_save_ef_chld(void);
u3_save_ef_chld(u3_pier *pir_u);
/* u3_save_io_init(): initialize autosave.
*/
void
u3_save_io_init(void);
u3_save_io_init(u3_pier *pir_u);
/* u3_save_io_exit(): terminate autosave.
*/
void
u3_save_io_exit(void);
u3_save_io_exit(u3_pier *pir_u);
/* u3_save_io_poll(): update autosave state.
*/
void
u3_save_io_poll(void);
u3_save_io_poll(u3_pier *pir_u);
/** Storage, new school.
**/
/* u3_unix_ef_hold():
*/
void
u3_unix_ef_hold();
u3_unix_ef_hold(void);
/* u3_unix_ef_boot(): boot actions
*/
void
u3_unix_ef_boot(void);
u3_unix_ef_boot(u3_pier *pir_u);
/* u3_unix_ef_bake(): initial effects for new process.
*/
void
u3_unix_ef_bake(void);
u3_unix_ef_bake(u3_pier *pir_u);
/* u3_unix_ef_move():
*/
void
u3_unix_ef_move();
u3_unix_ef_move(void);
/* u3_unix_initial_into(): intialize filesystem from urb/zod
*/
void
u3_unix_ef_initial_into();
u3_unix_ef_initial_into(u3_pier *pir_u);
/* u3_unix_ef_look(): update filesystem from unix
*/
void
u3_unix_ef_look(u3_noun all);
u3_unix_ef_look(u3_pier *pir_u, u3_noun all);
/* u3_unix_ef_ergo(): update filesystem from urbit
*/
void
u3_unix_ef_ergo(u3_noun mon, u3_noun can);
u3_unix_ef_ergo(u3_pier *pir_u, u3_noun mon, u3_noun can);
/* u3_unix_ef_ogre(): delete mount point
*/
void
u3_unix_ef_ogre(u3_noun mon);
u3_unix_ef_ogre(u3_pier *pir_u, u3_noun mon);
/* u3_unix_ef_hill(): enumerate mount points
*/
void
u3_unix_ef_hill(u3_noun hil);
u3_unix_ef_hill(u3_pier *pir_u, u3_noun hil);
/* u3_unix_io_init(): initialize storage.
*/
void
u3_unix_io_init(void);
u3_unix_io_init(u3_pier *pir_u);
/* u3_unix_io_talk(): start listening for fs events.
*/
void
u3_unix_io_talk(void);
u3_unix_io_talk(u3_pier *pir_u);
/* u3_unix_io_exit(): terminate storage.
*/
void
u3_unix_io_exit(void);
u3_unix_io_exit(u3_pier *pir_u);
/* u3_unix_io_poll(): update storage state.
*/
void
u3_unix_io_poll(void);
u3_unix_io_poll(u3_pier *pir_u);
/** behn, just a timer.
@ -1383,17 +1396,17 @@
/* u3_behn_io_init(): initialize time timer.
*/
void
u3_behn_io_init(void);
u3_behn_io_init(u3_pier *pir_u);
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void);
u3_behn_io_exit(u3_pier *pir_u);
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void);
u3_behn_io_poll(u3_pier *pir_u);
/** HTTP client.
@ -1482,7 +1495,8 @@
*/
void
u3_pier_boot(c3_c* pax_c, // pier path
c3_c* sys_c); // path to boot pill
c3_c* sys_c, // path to boot pill
uv_prepare_t *pep_u);
/* u3_pier_tank(): dump single tank.
*/
@ -1498,3 +1512,6 @@
*/
void
u3_pier_sway(c3_l tab_l, u3_noun tax);
void
u3_king_commence();

View File

@ -24,9 +24,9 @@
/* u3_behn(): initialize time timer.
*/
void
u3_behn_io_init(void)
u3_behn_io_init(u3_pier *pir_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_behn* teh_u = pir_u->teh_u;
uv_timer_init(u3L, &teh_u->tim_u);
teh_u->alm = c3n;
@ -35,7 +35,7 @@ u3_behn_io_init(void)
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void)
u3_behn_io_exit(u3_pier *pir_u)
{
}
@ -44,14 +44,16 @@ u3_behn_io_exit(void)
static void
_behn_time_cb(uv_timer_t* tim_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_pier *pir_u = tim_u->data;
u3_behn* teh_u = pir_u->teh_u;
if(teh_u->run_w < 1024) {
teh_u->run_w++;
}
{
u3_pier_plan
(u3nt(u3_blip, c3__behn, u3_nul),
u3_pier_work
(pir_u,
u3nt(u3_blip, c3__behn, u3_nul),
u3nc(c3__wake, u3_nul));
}
}
@ -59,9 +61,9 @@ _behn_time_cb(uv_timer_t* tim_u)
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void)
u3_behn_io_poll(u3_pier *pir_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_behn* teh_u = pir_u->teh_u;
u3_noun wen = u3v_keep(u3nt(u3_blip, c3__behn, u3_nul));
if ( (u3_nul != wen) &&
@ -81,6 +83,7 @@ u3_behn_io_poll(void)
}
else teh_u->alm = c3y;
teh_u->tim_u.data = pir_u;
uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0);
}
else {

430
vere/king.c Normal file
View File

@ -0,0 +1,430 @@
#include <uv.h>
#include "all.h"
#include "vere/vere.h"
/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: wyrd: requires auth to a single relevant ship ::
:: doom: requires auth to the daemon itself ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
++ fate :: client to lord
$% $: $auth :: authenticate client
p/(unit ship) :: what to auth
q/@ :: auth secret
== ::
$% $: $wyrd :: ship action
p/ship :: which ship
q/wyrd :: the action
== ::
$: $doom :: daemon command
p/doom :: the command
== ::
== ::
:: ::
++ wyrd :: ship action
$% $: $susp :: release this pier
$~ ::
== ::
$: $vent :: generate event
p/ovum :: wire and card
== ::
== ::
:: ::
++ doom :: daemon command
$% $: $boot :: boot new pier
p/ship :: ship
q/@ :: generator or ticket
r/(map @t *) :: debug options
== ::
$: $exit :: end the daemon
$~ ::
== ::
$: $pier :: acquire a pier
p/(unit @t) :: unix path
== ::
$: $root :: admin ship actions
p/ship :: which ship
q/wyrd :: the action
== ::
++ cede :: lord to client
$% $: $cede :: send cards
p/ship :: sending ship
q/(list ovum) :: actions
== ::
$: $firm :: accept command
$~ ::
== ::
$: $deny :: reject command
p/@t :: error message
== ::
== ::
:: ::
*/
void _king_auth(u3_noun auth);
void _king_wyrd(u3_noun ship_wyrd);
void _king_susp(u3_atom ship, u3_noun susp);
void _king_vent(u3_atom ship, u3_noun vent);
void _king_doom(u3_noun doom);
void _king_boot(u3_noun boot);
void _king_exit(u3_noun exit);
void _king_pier(u3_noun pier);
void _king_root(u3_noun root);
/* _king_defy_fate(): invalid fate
*/
void
_king_defy_fate()
{
exit(1);
}
/* _king_fate(): top-level fate parser
*/
void
_king_fate(void *vod_p, u3_noun mat)
{
u3_noun fate = u3ke_cue(u3k(mat));
u3_noun load;
void (*next)(u3_noun);
c3_assert(_(u3a_is_cell(fate)));
c3_assert(_(u3a_is_cat(u3h(fate))));
switch ( u3h(fate) ) {
case c3__auth:
next = _king_auth;
break;
case c3__wyrd:
next = _king_wyrd;
break;
case c3__doom:
next = _king_doom;
break;
default:
_king_defy_fate();
}
load = u3k(u3t(fate));
u3z(fate);
next(load);
}
/* _king_auth(): auth parser
*/
void
_king_auth(u3_noun auth)
{
}
/* _king_wyrd(): wyrd parser
*/
void
_king_wyrd(u3_noun ship_wyrd)
{
u3_atom ship;
u3_noun wyrd;
u3_noun load;
void (*next)(u3_atom, u3_noun);
c3_assert(_(u3a_is_cell(ship_wyrd)));
c3_assert(_(u3a_is_atom(u3h(ship_wyrd))));
ship = u3k(u3h(ship_wyrd));
wyrd = u3k(u3t(ship_wyrd));
u3z(ship_wyrd);
c3_assert(_(u3a_is_cell(wyrd)));
c3_assert(_(u3a_is_cat(u3h(wyrd))));
switch ( u3h(wyrd) ) {
case c3__susp:
next = _king_susp;
break;
case c3__vent:
next = _king_vent;
break;
default:
_king_defy_fate();
}
load = u3k(u3t(wyrd));
u3z(wyrd);
next(ship, load);
}
/* _king_susp(): susp parser
*/
void
_king_susp(u3_atom ship, u3_noun susp)
{
}
/* _king_vent(): vent parser
*/
void
_king_vent(u3_atom ship, u3_noun vent)
{
/* stub; have to find pier from ship */
u3z(ship);
u3_pier_work(u3_pier_stub(), u3h(vent), u3t(vent));
u3z(vent);
}
/* _king_doom(): doom parser
*/
void
_king_doom(u3_noun doom)
{
u3_noun load;
void (*next)(u3_noun);
c3_assert(_(u3a_is_cell(doom)));
c3_assert(_(u3a_is_cat(u3h(doom))));
switch ( u3h(doom) ) {
case c3__boot:
next = _king_boot;
break;
case c3__exit:
next = _king_exit;
break;
case c3__pier:
next = _king_pier;
break;
case c3__root:
next = _king_root;
break;
default:
_king_defy_fate();
}
load = u3k(u3t(doom));
u3z(doom);
next(load);
}
/* _king_boot(): boot parser
*/
void
_king_boot(u3_noun boot)
{
u3_noun pax_n, sys_n;
c3_c *pax_c, *sys_c;
uv_prepare_t *pep_u = u3a_malloc(sizeof(uv_prepare_t)); /* put in u3_pier? */
pax_n = u3k(u3h(u3t(boot)));
sys_n = u3k(u3h(u3t(u3t(boot))));
u3z(boot);
pax_c = u3r_string(pax_n);
u3z(pax_n);
sys_c = u3r_string(sys_n);
u3z(sys_n);
fprintf(stderr, "boot %s %s\r\n", pax_c, sys_c);
u3_pier_boot(pax_c, sys_c, pep_u);
}
/* _king_exit(): exit parser
*/
void
_king_exit(u3_noun exit)
{
}
/* _king_pier(): pier parser
*/
void
_king_pier(u3_noun pier)
{
}
/* _king_root(): root parser
*/
void
_king_root(u3_noun root)
{
}
/* _king_bail(): bail for command socket newt
*/
void
_king_bail(u3_moor *vod_p, const c3_c *err_c)
{
u3_moor *free_p;
fprintf(stderr, "_king_bail: %s\r\n", err_c);
if ( vod_p == 0 ) {
free_p = u3K.cli_u;
u3K.cli_u = u3K.cli_u->nex_u;
u3a_free(free_p);
} else {
free_p = vod_p->nex_u;
vod_p->nex_u = vod_p->nex_u->nex_u;
u3a_free(free_p);
}
}
/* _king_socket_connect(): callback for new connections
*/
void
_king_socket_connect(uv_stream_t *sock, int status)
{
u3_moor *mor_u;
if ( u3K.cli_u == 0 ) {
u3K.cli_u = u3a_malloc(sizeof(u3_moor));
mor_u = u3K.cli_u;
mor_u->vod_p = 0;
mor_u->nex_u = 0;
} else {
for (mor_u = u3K.cli_u; mor_u->nex_u; mor_u = mor_u->nex_u);
mor_u->nex_u = u3a_malloc(sizeof(u3_moor));
mor_u->nex_u->vod_p = mor_u;
mor_u = mor_u->nex_u;
mor_u->nex_u = 0;
}
uv_pipe_init(u3L, &mor_u->pyp_u, 0);
mor_u->pok_f = _king_fate;
mor_u->bal_f = (u3_bail)_king_bail;
uv_accept(sock, (uv_stream_t *)&mor_u->pyp_u);
u3_newt_read((u3_moat *)mor_u);
}
/* _boothack_cb(): callback for the boothack self-connection
*/
void
_boothack_cb(uv_connect_t *conn, int status)
{
u3_mojo *moj_u = conn->data;
u3_atom doom;
u3_atom pax, sys;
pax = u3i_string(u3_Host.dir_c);
sys = u3i_string(u3_Host.ops_u.pil_c);
doom = u3ke_jam(u3nc(c3__doom,
u3nc(c3__boot,
u3nq(0, pax, sys, 0))));
u3_newt_write(moj_u, doom, 0);
}
/* _king_loop_init(): stuff that comes before the event loop
*/
void
_king_loop_init()
{
/* move signals out of unix.c */
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGTERM;
sig_u->nex_u = u3_Host.sig_u;
u3_Host.sig_u = sig_u;
}
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGINT;
sig_u->nex_u = u3_Host.sig_u;
u3_Host.sig_u = sig_u;
}
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGWINCH;
sig_u->nex_u = u3_Host.sig_u;
u3_Host.sig_u = sig_u;
}
/* boot hack */
{
u3_moor *mor_u = c3_malloc(sizeof(u3_moor));
uv_connect_t *conn = c3_malloc(sizeof(uv_connect_t));
conn->data = mor_u;
uv_pipe_init(u3L, &mor_u->pyp_u, 0);
uv_pipe_connect(conn, &mor_u->pyp_u, "/tmp/urbit.sock", _boothack_cb);
}
}
/* _king_loop_exit(): cleanup after event loop
*/
void
_king_loop_exit()
{
/* all needs to move extept unlink */
c3_l cod_l;
cod_l = u3a_lush(c3__unix);
u3_unix_io_exit(u3_pier_stub());
u3a_lop(cod_l);
cod_l = u3a_lush(c3__ames);
u3_ames_io_exit(u3_pier_stub());
u3a_lop(cod_l);
cod_l = u3a_lush(c3__term);
u3_term_io_exit();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__http);
u3_http_io_exit();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__cttp);
u3_cttp_io_exit();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_exit(u3_pier_stub());
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_exit(u3_pier_stub());
u3a_lop(cod_l);
unlink("/tmp/urbit.sock");
}
/* u3_king_commence(): start the daemon
*/
void
u3_king_commence()
{
u3_Host.lup_u = uv_default_loop();
/* start up a "fast-compile" arvo for internal use only
*/
u3m_boot_pier();
{
extern c3_w u3_Ivory_length_w;
extern c3_y u3_Ivory_pill_y[];
u3_noun lit;
lit = u3i_bytes(u3_Ivory_length_w, u3_Ivory_pill_y);
u3v_boot_lite(lit);
}
/* listen on command socket */
uv_pipe_init(u3L, &u3K.cmd_u, 0);
uv_pipe_bind(&u3K.cmd_u, "/tmp/urbit.sock");
uv_listen((uv_stream_t *)&u3K.cmd_u, 128, _king_socket_connect);
fprintf(stderr, "cmd socket up\r\n");
_king_loop_init();
uv_run(u3L, UV_RUN_DEFAULT);
_king_loop_exit();
exit(0);
}

View File

@ -545,7 +545,7 @@ main(c3_i argc,
}
}
u3_pier_boot(u3_Host.dir_c, u3_Host.ops_u.pil_c);
u3_king_commence();
}
return 0;
}

View File

@ -1262,6 +1262,9 @@ u3_pier_create(c3_c* pax_c, c3_c* sys_c)
pir_u->sys_c = c3_malloc(1 + strlen(sys_c));
strcpy(pir_u->sys_c, sys_c);
pir_u->arv_c = c3_malloc(1 + strlen(u3_Host.ops_u.arv_c)); /* parametrize */
strcpy(pir_u->arv_c, u3_Host.ops_u.arv_c);
pir_u->gen_d = 0;
pir_u->key_d[0] = pir_u->key_d[1] = pir_u->key_d[2] = pir_u->key_d[3] = 0;
@ -1271,6 +1274,12 @@ u3_pier_create(c3_c* pax_c, c3_c* sys_c)
pir_u->sam_u = c3_malloc(sizeof(u3_ames));
memset(pir_u->sam_u, 0, sizeof(u3_ames));
pir_u->teh_u = c3_malloc(sizeof(u3_behn));
memset(pir_u->teh_u, 0, sizeof(u3_behn));
pir_u->unx_u = c3_malloc(sizeof(u3_unix));
memset(pir_u->unx_u, 0, sizeof(u3_unix));
pir_u->sav_u = c3_malloc(sizeof(u3_save));
memset(pir_u->sav_u, 0, sizeof(u3_save));
}
/* start process
@ -1397,10 +1406,6 @@ _pier_loop_init(void)
{
c3_l cod_l;
cod_l = u3a_lush(c3__unix);
u3_unix_io_init();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__term);
u3_term_io_init();
u3a_lop(cod_l);
@ -1412,14 +1417,6 @@ _pier_loop_init(void)
cod_l = u3a_lush(c3__cttp);
u3_cttp_io_init();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_init();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_init();
u3a_lop(cod_l);
}
/* _pier_loop_init_pier(): initialize loop handlers.
@ -1432,6 +1429,18 @@ _pier_loop_init_pier(u3_pier* pir_u)
cod_l = u3a_lush(c3__ames);
u3_ames_io_init(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_init(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__unix);
u3_unix_io_init(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_init(pir_u);
u3a_lop(cod_l);
}
/* _pier_loop_wake(): initialize listeners and send initial events.
@ -1442,8 +1451,8 @@ _pier_loop_wake(u3_pier* pir_u)
c3_l cod_l;
cod_l = u3a_lush(c3__unix);
u3_unix_io_talk();
u3_unix_ef_bake();
u3_unix_io_talk(pir_u);
u3_unix_ef_bake(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__ames);
@ -1470,7 +1479,7 @@ _pier_loop_exit(void)
c3_l cod_l;
cod_l = u3a_lush(c3__unix);
u3_unix_io_exit();
u3_unix_io_exit(u3_pier_stub());
u3a_lop(cod_l);
cod_l = u3a_lush(c3__ames);
@ -1490,11 +1499,11 @@ _pier_loop_exit(void)
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_exit();
u3_save_io_exit(u3_pier_stub());
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_exit();
u3_behn_io_exit(u3_pier_stub());
u3a_lop(cod_l);
}
@ -1518,15 +1527,15 @@ _pier_loop_poll(u3_pier* pir_u)
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_poll();
u3_save_io_poll(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__unix);
u3_unix_io_poll();
u3_unix_io_poll(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_poll();
u3_behn_io_poll(pir_u);
u3a_lop(cod_l);
}
@ -1650,7 +1659,7 @@ _pier_boot_complete(u3_pier* pir_u,
/* another anomaly
*/
u3_unix_ef_boot();
u3_unix_ef_boot(pir_u);
}
}
@ -1818,41 +1827,21 @@ _pier_boot_make(c3_c* pax_c,
*/
void
u3_pier_boot(c3_c* pax_c, // pier path
c3_c* sys_c) // path to boot pill
c3_c* sys_c, // path to boot pill
uv_prepare_t *pep_u)
{
uv_prepare_t pep_u;
u3_Host.lup_u = uv_default_loop();
/* start up a "fast-compile" arvo for internal use only
*/
u3m_boot_pier();
{
extern c3_w u3_Ivory_length_w;
extern c3_y u3_Ivory_pill_y[];
u3_noun lit;
lit = u3i_bytes(u3_Ivory_length_w, u3_Ivory_pill_y);
u3v_boot_lite(lit);
}
/* make initial pier
*/
_pier_boot_make(pax_c, sys_c);
/* initialize polling handle
*/
uv_prepare_init(u3_Host.lup_u, &pep_u);
uv_prepare_start(&pep_u, _pier_loop_prepare);
uv_prepare_init(u3_Host.lup_u, pep_u);
uv_prepare_start(pep_u, _pier_loop_prepare);
/* initialize loop - move to _pier_boot_make().
*/
_pier_loop_init();
/* enter loop
*/
uv_run(u3L, UV_RUN_DEFAULT);
_pier_loop_exit();
exit(0);
/* remember to deal with _pier_loop_exit stuff */
}

View File

@ -166,15 +166,15 @@ _reck_kick_sync(u3_pier* pir_u, u3_noun pox, u3_noun fav)
u3_noun mon = u3k(u3h(u3t(fav)));
u3_noun can = u3k(u3t(u3t(fav)));
u3_unix_ef_ergo(mon, can);
u3_unix_ef_ergo(pir_u, mon, can);
u3z(pox); u3z(fav); return c3y;
} break;
case c3__ogre: {
u3_unix_ef_ogre(u3k(u3t(fav)));
u3_unix_ef_ogre(pir_u, u3k(u3t(fav)));
u3z(pox); u3z(fav); return c3y;
}
case c3__hill: {
u3_unix_ef_hill(u3k(u3t(fav)));
u3_unix_ef_hill(pir_u, u3k(u3t(fav)));
u3z(pox); u3z(fav); return c3y;
}
}

View File

@ -22,7 +22,8 @@
static void
_save_time_cb(uv_timer_t* tim_u)
{
u3_save* sav_u = &u3_Host.sav_u;
u3_pier *pir_u = tim_u->data;
u3_save* sav_u = pir_u->sav_u;
if ( sav_u->pid_w ) {
return;
@ -41,9 +42,9 @@ _save_time_cb(uv_timer_t* tim_u)
/* u3_save_ef_chld(): report save termination.
*/
void
u3_save_ef_chld(void)
u3_save_ef_chld(u3_pier *pir_u)
{
u3_save* sav_u = &u3_Host.sav_u;
u3_save* sav_u = pir_u->sav_u;
c3_i loc_i;
c3_w pid_w;
@ -63,13 +64,14 @@ u3_save_ef_chld(void)
/* u3_save_io_init(): initialize autosave.
*/
void
u3_save_io_init(void)
u3_save_io_init(u3_pier *pir_u)
{
u3_save* sav_u = &u3_Host.sav_u;
u3_save* sav_u = pir_u->sav_u;
sav_u->ent_d = 0;
sav_u->pid_w = 0;
sav_u->tim_u.data = pir_u;
uv_timer_init(u3L, &sav_u->tim_u);
uv_timer_start(&sav_u->tim_u, _save_time_cb, 120000, 120000);
}
@ -77,13 +79,13 @@ u3_save_io_init(void)
/* u3_save_io_exit(): terminate save I/O.
*/
void
u3_save_io_exit(void)
u3_save_io_exit(u3_pier *pir_u)
{
}
/* u3_save_io_poll(): poll kernel for save I/O.
*/
void
u3_save_io_poll(void)
u3_save_io_poll(u3_pier *pir_u)
{
}

View File

@ -66,8 +66,8 @@ _unix_string_to_path_helper(c3_c* pax_c) {
}
}
static u3_noun
_unix_string_to_path(c3_c* pax_c) {
pax_c += strlen(u3_Host.dir_c) + 1;
_unix_string_to_path(u3_pier *pir_u, c3_c* pax_c) {
pax_c += strlen(pir_u->pax_c) + 1;
c3_c* pox_c = strchr(pax_c, '/');
if ( !pox_c ) {
pox_c = strchr(pax_c, '.');
@ -258,12 +258,12 @@ _unix_write_file_soft_go:
static void
_unix_watch_dir(u3_udir* dir_u, u3_udir* par_u, c3_c* pax_c);
static void
_unix_watch_file(u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c);
_unix_watch_file(u3_pier *pir_u, u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c);
/* _unix_get_mount_point(): retrieve or create mount point
*/
static u3_umon*
_unix_get_mount_point(u3_noun mon)
_unix_get_mount_point(u3_pier *pir_u, u3_noun mon)
{
if ( c3n == u3ud(mon) ) {
c3_assert(!"mount point must be an atom");
@ -274,7 +274,7 @@ _unix_get_mount_point(u3_noun mon)
c3_c* nam_c = u3r_string(mon);
u3_umon* mon_u;
for ( mon_u = u3_Host.unx_u.mon_u;
for ( mon_u = pir_u->unx_u->mon_u;
mon_u && 0 != strcmp(nam_c, mon_u->nam_c);
mon_u = mon_u->nex_u )
{
@ -285,12 +285,12 @@ _unix_get_mount_point(u3_noun mon)
mon_u->nam_c = nam_c;
mon_u->dir_u.dir = c3y;
mon_u->dir_u.dry = c3n;
mon_u->dir_u.pax_c = strdup(u3_Host.dir_c);
mon_u->dir_u.pax_c = strdup(pir_u->pax_c);
mon_u->dir_u.par_u = NULL;
mon_u->dir_u.nex_u = NULL;
mon_u->dir_u.kid_u = NULL;
mon_u->nex_u = u3_Host.unx_u.mon_u;
u3_Host.unx_u.mon_u = mon_u;
mon_u->nex_u = pir_u->unx_u->mon_u;
pir_u->unx_u->mon_u = mon_u;
}
else {
@ -305,7 +305,7 @@ _unix_get_mount_point(u3_noun mon)
/* _unix_scan_mount_point(): scan unix for already-existing mount point
*/
static void
_unix_scan_mount_point(u3_umon* mon_u)
_unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u)
{
DIR* rid_u = opendir(mon_u->dir_u.pax_c);
if ( !rid_u ) {
@ -368,14 +368,14 @@ _unix_scan_mount_point(u3_umon* mon_u)
}
else {
u3_ufil* fil_u = c3_malloc(sizeof(u3_ufil));
_unix_watch_file(fil_u, &mon_u->dir_u, pax_c);
_unix_watch_file(pir_u, fil_u, &mon_u->dir_u, pax_c);
}
}
}
}
}
static u3_noun _unix_free_node(u3_unod* nod_u);
static u3_noun _unix_free_node(u3_pier *pir_u, u3_unod* nod_u);
/* _unix_free_file(): free file, unlinking it
*/
@ -420,7 +420,7 @@ _unix_free_dir(uv_handle_t* was_u)
* also deletes from parent list if in it
*/
static u3_noun
_unix_free_node(u3_unod* nod_u)
_unix_free_node(u3_pier *pir_u, u3_unod* nod_u)
{
u3_noun can;
if ( nod_u->par_u ) {
@ -445,14 +445,14 @@ _unix_free_node(u3_unod* nod_u)
u3_unod* nud_u = ((u3_udir*) nod_u)->kid_u;
while ( nud_u ) {
u3_unod* nex_u = nud_u->nex_u;
can = u3kb_weld(_unix_free_node(nud_u), can);
can = u3kb_weld(_unix_free_node(pir_u, nud_u), can);
nud_u = nex_u;
}
uv_close((uv_handle_t*)&nod_u->was_u, _unix_free_dir);
}
else {
can = u3nc(u3nc(_unix_string_to_path(nod_u->pax_c), u3_nul),
can = u3nc(u3nc(_unix_string_to_path(pir_u, nod_u->pax_c), u3_nul),
u3_nul);
uv_close((uv_handle_t*)&nod_u->was_u, _unix_free_file);
}
@ -469,12 +469,12 @@ _unix_free_node(u3_unod* nod_u)
* tread carefully
*/
static void
_unix_free_mount_point(u3_umon* mon_u)
_unix_free_mount_point(u3_pier *pir_u, u3_umon* mon_u)
{
u3_unod* nod_u;
for ( nod_u = mon_u->dir_u.kid_u; nod_u; ) {
u3_unod* nex_u = nod_u->nex_u;
u3z(_unix_free_node(nod_u));
u3z(_unix_free_node(pir_u, nod_u));
nod_u = nex_u;
}
@ -486,7 +486,7 @@ _unix_free_mount_point(u3_umon* mon_u)
/* _unix_delete_mount_point(): remove mount point from list and free
*/
static void
_unix_delete_mount_point(u3_noun mon)
_unix_delete_mount_point(u3_pier *pir_u, u3_noun mon)
{
if ( c3n == u3ud(mon) ) {
c3_assert(!"mount point must be an atom");
@ -498,14 +498,14 @@ _unix_delete_mount_point(u3_noun mon)
u3_umon* mon_u;
u3_umon* tem_u;
mon_u = u3_Host.unx_u.mon_u;
mon_u = pir_u->unx_u->mon_u;
if ( !mon_u ) {
uL(fprintf(uH, "mount point already gone: %s\r\n", nam_c));
goto _delete_mount_point_out;
}
if ( 0 == strcmp(nam_c, mon_u->nam_c) ) {
u3_Host.unx_u.mon_u = mon_u->nex_u;
_unix_free_mount_point(mon_u);
pir_u->unx_u->mon_u = mon_u->nex_u;
_unix_free_mount_point(pir_u, mon_u);
goto _delete_mount_point_out;
}
@ -522,7 +522,7 @@ _unix_delete_mount_point(u3_noun mon)
tem_u = mon_u->nex_u;
mon_u->nex_u = mon_u->nex_u->nex_u;
_unix_free_mount_point(tem_u);
_unix_free_mount_point(pir_u, tem_u);
_delete_mount_point_out:
free(nam_c);
@ -535,8 +535,9 @@ static void
_unix_time_cb(uv_timer_t* tim_u)
{
{
u3_Host.unx_u.alm = c3n;
u3_Host.unx_u.dyr = c3y;
u3_pier *pir_u = tim_u->data;
pir_u->unx_u->alm = c3n;
pir_u->unx_u->dyr = c3y;
}
}
@ -557,6 +558,7 @@ _unix_fs_event_cb(uv_fs_event_t* was_u,
// * this is what we get out of libuv down below
// * thus a cast is cool
u3_unod* nod_u = (u3_unod*) was_u;
u3_pier *pir_u = was_u->data;
while ( nod_u ) {
nod_u->dry = c3n;
@ -567,22 +569,23 @@ _unix_fs_event_cb(uv_fs_event_t* was_u,
// the extra time is so that the fs "settles down".
// vim, for example, tends to delete and re-add files
// for safety purposes.
if ( c3y == u3_Host.unx_u.alm ) {
uv_timer_stop(&u3_Host.unx_u.tim_u);
if ( c3y == pir_u->unx_u->alm ) {
uv_timer_stop(&pir_u->unx_u->tim_u);
}
else {
u3_Host.unx_u.alm = c3y;
pir_u->unx_u->alm = c3y;
}
u3_Host.unx_u.dyr = c3n;
pir_u->unx_u->dyr = c3n;
uv_timer_start(&u3_Host.unx_u.tim_u, _unix_time_cb, 100, 0);
pir_u->unx_u->tim_u.data = pir_u;
uv_timer_start(&pir_u->unx_u->tim_u, _unix_time_cb, 100, 0);
}
/* _unix_watch_file(): initialize file
*/
static void
_unix_watch_file(u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c)
_unix_watch_file(u3_pier *pir_u, u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c)
{
// initialize fil_u
@ -609,6 +612,7 @@ _unix_watch_file(u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c)
c3_assert(0);
}
fil_u->was_u.data = pir_u;
ret_w = uv_fs_event_start(&fil_u->was_u, _unix_fs_event_cb, pax_c, 0);
if ( 0 != ret_w ){
uL(fprintf(uH, "file event start %s: %s\n", fil_u->pax_c, uv_strerror(ret_w)));
@ -674,7 +678,7 @@ _unix_create_dir(u3_udir* dir_u, u3_udir* par_u, u3_noun nam)
_unix_watch_dir(dir_u, par_u, pax_c);
}
static u3_noun _unix_update_node(u3_unod* nod_u);
static u3_noun _unix_update_node(u3_pier *pir_u, u3_unod* nod_u);
/* _unix_update_file(): update file, producing list of changes
*
@ -685,7 +689,7 @@ static u3_noun _unix_update_node(u3_unod* nod_u);
* mug_w with new mug and add path plus data to %into event.
*/
static u3_noun
_unix_update_file(u3_ufil* fil_u)
_unix_update_file(u3_pier *pir_u, u3_ufil* fil_u)
{
c3_assert( c3n == fil_u->dir );
@ -702,7 +706,7 @@ _unix_update_file(u3_ufil* fil_u)
if ( fid_i < 0 || fstat(fid_i, &buf_u) < 0 ) {
if ( ENOENT == errno ) {
return u3nc(u3nc(_unix_string_to_path(fil_u->pax_c), u3_nul), u3_nul);
return u3nc(u3nc(_unix_string_to_path(pir_u, fil_u->pax_c), u3_nul), u3_nul);
}
else {
uL(fprintf(uH, "error opening file %s: %s\r\n",
@ -760,7 +764,7 @@ _unix_update_file(u3_ufil* fil_u)
else {
fil_u->mug_w = mug_w;
u3_noun pax = _unix_string_to_path(fil_u->pax_c);
u3_noun pax = _unix_string_to_path(pir_u, fil_u->pax_c);
u3_noun mim = u3nt(c3__text, u3i_string("plain"), u3_nul);
u3_noun dat = u3nt(mim, len_ws, u3i_bytes(len_ws, dat_y));
@ -776,7 +780,7 @@ _unix_update_file(u3_ufil* fil_u)
* _unix_initial_update_dir()
*/
static u3_noun
_unix_update_dir(u3_udir* dir_u)
_unix_update_dir(u3_pier *pir_u, u3_udir* dir_u)
{
u3_noun can = u3_nul;
@ -802,7 +806,7 @@ _unix_update_dir(u3_udir* dir_u)
DIR* red_u = opendir(nod_u->pax_c);
if ( 0 == red_u ) {
u3_unod* nex_u = nod_u->nex_u;
can = u3kb_weld(_unix_free_node(nod_u), can);
can = u3kb_weld(_unix_free_node(pir_u, nod_u), can);
nod_u = nex_u;
}
else {
@ -821,7 +825,7 @@ _unix_update_dir(u3_udir* dir_u)
}
u3_unod* nex_u = nod_u->nex_u;
can = u3kb_weld(_unix_free_node(nod_u), can);
can = u3kb_weld(_unix_free_node(pir_u, nod_u), can);
nod_u = nex_u;
}
else {
@ -905,12 +909,12 @@ _unix_update_dir(u3_udir* dir_u)
}
u3_ufil* fil_u = c3_malloc(sizeof(u3_ufil));
_unix_watch_file(fil_u, dir_u, pax_c);
_unix_watch_file(pir_u, fil_u, dir_u, pax_c);
}
else {
u3_udir* dis_u = c3_malloc(sizeof(u3_udir));
_unix_watch_dir(dis_u, dir_u, pax_c);
can = u3kb_weld(_unix_update_dir(dis_u), can); // XXX unnecessary?
can = u3kb_weld(_unix_update_dir(pir_u, dis_u), can); // XXX unnecessary?
}
}
}
@ -923,13 +927,13 @@ _unix_update_dir(u3_udir* dir_u)
}
if ( !dir_u->kid_u ) {
return u3kb_weld(_unix_free_node((u3_unod*) dir_u), can);
return u3kb_weld(_unix_free_node(pir_u, (u3_unod*) dir_u), can);
}
// get change list
for ( nod_u = dir_u->kid_u; nod_u; nod_u = nod_u->nex_u ) {
can = u3kb_weld(_unix_update_node(nod_u), can);
can = u3kb_weld(_unix_update_node(pir_u, nod_u), can);
}
return can;
@ -938,29 +942,30 @@ _unix_update_dir(u3_udir* dir_u)
/* _unix_update_node(): update node, producing list of changes
*/
static u3_noun
_unix_update_node(u3_unod* nod_u)
_unix_update_node(u3_pier *pir_u, u3_unod* nod_u)
{
if ( c3y == nod_u->dir ) {
return _unix_update_dir((void*)nod_u);
return _unix_update_dir(pir_u, (void*)nod_u);
}
else {
return _unix_update_file((void*)nod_u);
return _unix_update_file(pir_u, (void*)nod_u);
}
}
/* _unix_update_mount(): update mount point
*/
static void
_unix_update_mount(u3_umon* mon_u, u3_noun all)
_unix_update_mount(u3_pier *pir_u, u3_umon* mon_u, u3_noun all)
{
if ( c3n == mon_u->dir_u.dry ) {
u3_noun can = u3_nul;
u3_unod* nod_u;
for ( nod_u = mon_u->dir_u.kid_u; nod_u; nod_u = nod_u->nex_u ) {
can = u3kb_weld(_unix_update_node(nod_u), can);
can = u3kb_weld(_unix_update_node(pir_u, nod_u), can);
}
u3_pier_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul),
u3_pier_work(pir_u,
u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul),
u3nq(c3__into, u3i_string(mon_u->nam_c), all, can));
}
}
@ -968,7 +973,7 @@ _unix_update_mount(u3_umon* mon_u, u3_noun all)
/* _unix_initial_update_file(): read file, but don't watch
*/
static u3_noun
_unix_initial_update_file(c3_c* pax_c)
_unix_initial_update_file(u3_pier *pir_u, c3_c* pax_c)
{
struct stat buf_u;
c3_i fid_i = open(pax_c, O_RDONLY, 0644);
@ -1010,7 +1015,7 @@ _unix_initial_update_file(c3_c* pax_c)
}
else {
u3_noun pax = _unix_string_to_path_helper(pax_c
+ strlen(u3_Host.ops_u.arv_c)
+ strlen(pir_u->arv_c)
+ 1); /* XX slightly less VERY BAD than before*/
u3_noun mim = u3nt(c3__text, u3i_string("plain"), u3_nul);
u3_noun dat = u3nt(mim, len_ws, u3i_bytes(len_ws, dat_y));
@ -1023,7 +1028,7 @@ _unix_initial_update_file(c3_c* pax_c)
/* _unix_initial_update_dir(): read directory, but don't watch
*/
static u3_noun
_unix_initial_update_dir(c3_c* pax_c)
_unix_initial_update_dir(u3_pier *pir_u, c3_c* pax_c)
{
u3_noun can = u3_nul;
@ -1063,10 +1068,10 @@ _unix_initial_update_dir(c3_c* pax_c)
}
else {
if ( S_ISDIR(buf_u.st_mode) ) {
can = u3kb_weld(_unix_initial_update_dir(pox_c), can);
can = u3kb_weld(_unix_initial_update_dir(pir_u, pox_c), can);
}
else {
can = u3kb_weld(_unix_initial_update_file(pox_c), can);
can = u3kb_weld(_unix_initial_update_file(pir_u, pox_c), can);
}
free(pox_c);
}
@ -1112,7 +1117,7 @@ _unix_ef_sync(uv_check_t* han_u)
/* _unix_sync_file(): sync file to unix
*/
static void
_unix_sync_file(u3_udir* par_u, u3_noun nam, u3_noun ext, u3_noun mim)
_unix_sync_file(u3_pier *pir_u, u3_udir* par_u, u3_noun nam, u3_noun ext, u3_noun mim)
{
c3_assert( par_u );
c3_assert( c3y == par_u->dir );
@ -1150,7 +1155,7 @@ _unix_sync_file(u3_udir* par_u, u3_noun nam, u3_noun ext, u3_noun mim)
if ( u3_nul == mim ) {
if ( nod_u ) {
u3z(_unix_free_node(nod_u));
u3z(_unix_free_node(pir_u, nod_u));
}
}
else {
@ -1158,7 +1163,7 @@ _unix_sync_file(u3_udir* par_u, u3_noun nam, u3_noun ext, u3_noun mim)
if ( !nod_u ) {
c3_w gum_w = _unix_write_file_hard(pax_c, u3k(u3t(mim)));
u3_ufil* fil_u = c3_malloc(sizeof(u3_ufil));
_unix_watch_file(fil_u, par_u, pax_c);
_unix_watch_file(pir_u, fil_u, par_u, pax_c);
fil_u->gum_w = gum_w;
goto _unix_sync_file_out;
}
@ -1176,7 +1181,7 @@ _unix_sync_file_out:
/* _unix_sync_change(): sync single change to unix
*/
static void
_unix_sync_change(u3_udir* dir_u, u3_noun pax, u3_noun mim)
_unix_sync_change(u3_pier *pir_u, u3_udir* dir_u, u3_noun pax, u3_noun mim)
{
c3_assert( c3y == dir_u->dir );
@ -1201,7 +1206,7 @@ _unix_sync_change(u3_udir* dir_u, u3_noun pax, u3_noun mim)
u3_noun tt_pax = u3t(t_pax);
if ( u3_nul == tt_pax ) {
_unix_sync_file(dir_u, u3k(i_pax), u3k(it_pax), mim);
_unix_sync_file(pir_u, dir_u, u3k(i_pax), u3k(it_pax), mim);
}
else {
c3_c* nam_c = u3r_string(i_pax);
@ -1226,7 +1231,7 @@ _unix_sync_change(u3_udir* dir_u, u3_noun pax, u3_noun mim)
c3_assert(0);
}
_unix_sync_change((u3_udir*) nod_u, u3k(t_pax), mim);
_unix_sync_change(pir_u, (u3_udir*) nod_u, u3k(t_pax), mim);
}
}
u3z(pax);
@ -1235,13 +1240,13 @@ _unix_sync_change(u3_udir* dir_u, u3_noun pax, u3_noun mim)
/* _unix_sync_ergo(): sync list of changes to unix
*/
static void
_unix_sync_ergo(u3_umon* mon_u, u3_noun can)
_unix_sync_ergo(u3_pier *pir_u, u3_umon* mon_u, u3_noun can)
{
u3_noun nac = can;
u3_noun nam = u3i_string(mon_u->nam_c);
while ( u3_nul != nac) {
_unix_sync_change(&mon_u->dir_u,
_unix_sync_change(pir_u, &mon_u->dir_u,
u3nc(u3k(nam), u3k(u3h(u3h(nac)))),
u3k(u3t(u3h(nac))));
nac = u3t(nac);
@ -1254,77 +1259,46 @@ _unix_sync_ergo(u3_umon* mon_u, u3_noun can)
/* u3_unix_ef_ergo(): update filesystem from urbit
*/
void
u3_unix_ef_ergo(u3_noun mon, u3_noun can)
u3_unix_ef_ergo(u3_pier *pir_u, u3_noun mon, u3_noun can)
{
u3_umon* mon_u = _unix_get_mount_point(mon);
u3_umon* mon_u = _unix_get_mount_point(pir_u, mon);
_unix_sync_ergo(mon_u, can);
_unix_sync_ergo(pir_u, mon_u, can);
}
/* u3_unix_ef_ogre(): delete mount point
*/
void
u3_unix_ef_ogre(u3_noun mon)
u3_unix_ef_ogre(u3_pier *pir_u, u3_noun mon)
{
_unix_delete_mount_point(mon);
_unix_delete_mount_point(pir_u, mon);
}
/* u3_unix_ef_hill(): enumerate mount points
*/
void
u3_unix_ef_hill(u3_noun hil)
u3_unix_ef_hill(u3_pier *pir_u, u3_noun hil)
{
u3_noun mon;
for ( mon = hil; c3y == u3du(mon); mon = u3t(mon) ) {
u3_umon* mon_u = _unix_get_mount_point(u3k(u3h(mon)));
_unix_scan_mount_point(mon_u);
u3_umon* mon_u = _unix_get_mount_point(pir_u, u3k(u3h(mon)));
_unix_scan_mount_point(pir_u, mon_u);
}
u3z(hil);
u3_Host.unx_u.dyr = c3y;
u3_unix_ef_look(c3y);
pir_u->unx_u->dyr = c3y;
u3_unix_ef_look(pir_u, c3y);
}
/* u3_unix_io_init(): initialize unix sync.
*/
void
u3_unix_io_init(void)
u3_unix_io_init(u3_pier *pir_u)
{
u3_unix* unx_u = &u3_Host.unx_u;
u3_unix* unx_u = pir_u->unx_u;
unx_u->mon_u = NULL;
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGTERM;
sig_u->nex_u = unx_u->sig_u;
unx_u->sig_u = sig_u;
}
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGINT;
sig_u->nex_u = unx_u->sig_u;
unx_u->sig_u = sig_u;
}
{
u3_usig* sig_u;
sig_u = c3_malloc(sizeof(u3_usig));
uv_signal_init(u3L, &sig_u->sil_u);
sig_u->num_i = SIGWINCH;
sig_u->nex_u = unx_u->sig_u;
unx_u->sig_u = sig_u;
}
uv_check_init(u3_Host.lup_u, &u3_Host.unx_u.syn_u);
uv_check_init(u3L, &pir_u->unx_u->syn_u);
uv_timer_init(u3L, &unx_u->tim_u);
unx_u->alm = c3n;
@ -1413,10 +1387,9 @@ u3_unix_release(c3_c* pax_c)
void
u3_unix_ef_hold(void)
{
u3_unix* unx_u = &u3_Host.unx_u;
u3_usig* sig_u;
for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) {
for ( sig_u = u3_Host.sig_u; sig_u; sig_u = sig_u->nex_u ) {
uv_signal_stop(&sig_u->sil_u);
}
}
@ -1424,9 +1397,10 @@ u3_unix_ef_hold(void)
/* u3_unix_ef_bake(): initial effects for new process.
*/
void
u3_unix_ef_bake(void)
u3_unix_ef_bake(u3_pier *pir_u)
{
u3_pier_plan(u3nt(u3_blip, c3__boat, u3_nul),
u3_pier_work(pir_u,
u3nt(u3_blip, c3__boat, u3_nul),
u3nc(c3__boat, u3_nul));
}
@ -1436,10 +1410,9 @@ u3_unix_ef_bake(void)
void
u3_unix_ef_move(void)
{
u3_unix* unx_u = &u3_Host.unx_u;
u3_usig* sig_u;
for ( sig_u = unx_u->sig_u; sig_u; sig_u = sig_u->nex_u ) {
for ( sig_u = u3_Host.sig_u; sig_u; sig_u = sig_u->nex_u ) {
uv_signal_start(&sig_u->sil_u, _unix_sign_cb, sig_u->num_i);
}
}
@ -1447,12 +1420,13 @@ u3_unix_ef_move(void)
/* u3_unix_ef_boot(): boot actions
*/
void
u3_unix_ef_boot(void)
u3_unix_ef_boot(u3_pier *pir_u)
{
if ( u3_Host.ops_u.imp_c ) {
u3_noun can = _unix_initial_update_dir(u3_Host.ops_u.arv_c);
u3_noun can = _unix_initial_update_dir(pir_u, pir_u->arv_c);
u3_pier_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul),
u3_pier_work(pir_u,
u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul),
u3nq(c3__into, u3_nul, c3y, can));
}
}
@ -1460,14 +1434,14 @@ u3_unix_ef_boot(void)
/* u3_unix_ef_look(): update the root.
*/
void
u3_unix_ef_look(u3_noun all)
u3_unix_ef_look(u3_pier *pir_u, u3_noun all)
{
if ( c3y == u3_Host.unx_u.dyr ) {
u3_Host.unx_u.dyr = c3n;
if ( c3y == pir_u->unx_u->dyr ) {
pir_u->unx_u->dyr = c3n;
u3_umon* mon_u;
for ( mon_u = u3_Host.unx_u.mon_u; mon_u; mon_u = mon_u->nex_u ) {
_unix_update_mount(mon_u, all);
for ( mon_u = pir_u->unx_u->mon_u; mon_u; mon_u = mon_u->nex_u ) {
_unix_update_mount(pir_u, mon_u, all);
}
}
}
@ -1475,25 +1449,25 @@ u3_unix_ef_look(u3_noun all)
/* u3_unix_io_talk(): start listening for fs events.
*/
void
u3_unix_io_talk()
u3_unix_io_talk(u3_pier *pir_u)
{
u3_unix_acquire(u3_Host.dir_c);
u3_unix_acquire(pir_u->pax_c);
u3_unix_ef_move();
uv_check_start(&u3_Host.unx_u.syn_u, _unix_ef_sync);
uv_check_start(&pir_u->unx_u->syn_u, _unix_ef_sync);
}
/* u3_unix_io_exit(): terminate unix I/O.
*/
void
u3_unix_io_exit(void)
u3_unix_io_exit(u3_pier *pir_u)
{
uv_check_stop(&u3_Host.unx_u.syn_u);
u3_unix_release(u3_Host.dir_c);
uv_check_stop(&pir_u->unx_u->syn_u);
u3_unix_release(pir_u->pax_c);
}
/* u3_unix_io_poll(): update unix IO state.
*/
void
u3_unix_io_poll(void)
u3_unix_io_poll(u3_pier *pir_u)
{
}