Add -A option to locate initial galaxy sync files

This commit is contained in:
Raymond Pasco 2016-08-29 13:04:57 -04:00
parent b03519f64f
commit 228b0fb20d
3 changed files with 24 additions and 5 deletions

View File

@ -535,6 +535,7 @@
c3_c* who_c; // -T, begin with ticket
c3_c* tic_c; // -T, ticket value
c3_c* pil_c; // -B, bootstrap from
c3_c* arv_c; // -A, initial sync from
c3_w kno_w; // -k, kernel version
c3_w fuz_w; // -f, fuzz testing
c3_s por_s; // -p, ames port

View File

@ -82,7 +82,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.rep = c3n;
u3_Host.ops_u.kno_w = DefaultKernel;
while ( (ch_i=getopt(argc, argv,"B:I:w:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
while ( (ch_i=getopt(argc, argv,"B:A:I:w:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
switch ( ch_i ) {
case 'M': {
u3_Host.ops_u.mem = c3y;
@ -92,6 +92,10 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.pil_c = strdup(optarg);
break;
}
case 'A': {
u3_Host.ops_u.arv_c = strdup(optarg);
break;
}
case 'I': {
u3_Host.ops_u.imp_c = _main_presig(optarg);
break;
@ -170,6 +174,20 @@ _main_getopt(c3_i argc, c3_c** argv)
}
}
if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 ||
u3_Host.ops_u.nuu == c3n ) ) {
fprintf(stderr, "-A only makes sense when creating a new galaxy");
return c3n;
}
if ( u3_Host.ops_u.imp_c != 0 &&
u3_Host.ops_u.arv_c == 0 &&
u3_Host.ops_u.nuu == c3y ) {
fprintf(stderr, "can't create a new galaxy without specifying "
"the initial sync path with -A\n");
return c3n;
}
if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) {
fprintf(stderr, "The -r flag requires -l.\n");
return c3n;

View File

@ -1010,7 +1010,9 @@ _unix_initial_update_file(c3_c* pax_c)
return u3_nul;
}
else {
u3_noun pax = _unix_string_to_path_helper(pax_c + strlen(U3_LIB) + 6); /* XX VERY BAD */
u3_noun pax = _unix_string_to_path_helper(pax_c
+ strlen(u3_Host.ops_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));
@ -1445,9 +1447,7 @@ u3_unix_ef_move(void)
void
u3_unix_ef_initial_into()
{
c3_c* pax_c = _unix_down(U3_LIB, "arvo");
u3_noun can = _unix_initial_update_dir(pax_c);
free(pax_c);
u3_noun can = _unix_initial_update_dir(u3_Host.ops_u.arv_c);
u3v_plan(u3nq(u3_blip, c3__sync, u3k(u3A->sen), u3_nul),
u3nq(c3__into, u3_nul, c3y, can));