Skip to content

Commit

Permalink
Merge develop to next/kelvin/410 (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova authored Jul 30, 2024
2 parents 699e6bf + 3e6219d commit ea50c2b
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/.user.bazelrc
/bazel-*
/urbit
MODULE.bazel
MODULE.bazel.lock

# Swap files.
*.swo
Expand Down
7 changes: 7 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ doesn't match the version of `clang` installed on your system. To address this,
run `clang --version` and pass the version number via
`--clang_version="<version_string>"` to the failing command.

If build fails on nix/NixOS, you should pass `ACLOCAL_PATH` environment
variable to bazel, using `--action_env=ACLOCAL_PATH=$ACLOCAL_PATH`, like so:

```
bazel build :urbit --action_env=ACLOCAL_PATH=$ACLOCAL_PATH
```

[^1]: If you're interested in digging into the details of the build system,
check out [`WORKSPACE.bazel`](WORKSPACE.bazel),
[`BUILD.bazel`](BUILD.bazel), [`bazel/`](bazel), and the multiple
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
3.1
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ versioned_http_archive(
build_file = "//bazel/third_party/natpmp:natpmp.BUILD",
sha256 = "0684ed2c8406437e7519a1bd20ea83780db871b3a3a5d752311ba3e889dbfc70",
strip_prefix = "libnatpmp-{version}",
url = "http://miniupnp.free.fr/files/libnatpmp-{version}.tar.gz",
url = "http://download.openpkg.org/components/cache/libnatpmp/libnatpmp-{version}.tar.gz",
version = "20230423",
)

Expand Down Expand Up @@ -264,7 +264,7 @@ versioned_http_archive(
build_file = "//bazel/third_party/openssl:openssl.BUILD",
sha256 = "cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8",
strip_prefix = "openssl-{version}",
url = "https://www.openssl.org/source/openssl-{version}.tar.gz",
url = "https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-{version}.tar.gz",
version = "1.1.1w",
)

Expand Down
2 changes: 1 addition & 1 deletion bazel/third_party/avahi/avahi.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configure_make(
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
configure_options = ["--with-dbus-system-address='unix:path=/var/run/dbus/system_bus_socket' --with-xml=none --disable-libevent --disable-glib --disable-gobject --disable-gdbm --disable-qt3 --disable-qt4 --disable-qt5 --disable-gtk --disable-gtk3 --disable-mono --disable-monodoc --disable-python --disable-libdaemon --enable-compat-libdns_sd --disable-rpath"],
configure_options = ["--with-dbus-system-address='unix:path=/var/run/dbus/system_bus_socket' --with-xml=none --disable-libevent --disable-glib --disable-gobject --disable-gdbm --disable-qt3 --disable-qt4 --disable-qt5 --disable-gtk --disable-gtk3 --disable-mono --disable-monodoc --disable-python --disable-libdaemon --enable-compat-libdns_sd --disable-rpath --with-distro=none"],
lib_source = ":all",
# out_include_dir = "avahi-compat-libdns_sd",
deps = ["@dbus"],
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,16 @@
]
++ (with pkgs; [
autoconf
autoconf-archive
automake
bazel_5
bazel_6
binutils # for `nm`
jdk11_headless
libtool
m4
pkg-config
git
perl
]);
extraBuildCommands = ''
chmod +w usr
Expand Down
55 changes: 34 additions & 21 deletions pkg/noun/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,37 +324,43 @@ u3e_fault(u3_post low_p, u3_post hig_p, u3_post off_p)
return u3e_flaw_good;
}

typedef enum {
_ce_img_good = 0,
_ce_img_fail = 1,
_ce_img_size = 2
} _ce_img_stat;

/* _ce_image_stat(): measure image.
*/
static c3_o
static _ce_img_stat
_ce_image_stat(u3e_image* img_u, c3_w* pgs_w)
{
struct stat buf_u;

if ( -1 == fstat(img_u->fid_i, &buf_u) ) {
fprintf(stderr, "loom: stat %s: %s\r\n", img_u->nam_c, strerror(errno));
u3_assert(0);
return c3n;
return _ce_img_fail;
}
else {
c3_z siz_z = buf_u.st_size;
c3_z pgs_z = (siz_z + (_ce_page - 1)) >> (u3a_page + 2);

if ( !siz_z ) {
*pgs_w = 0;
return c3y;
return _ce_img_good;
}
else if ( siz_z != _ce_len(pgs_z) ) {
fprintf(stderr, "loom: %s corrupt size %zu\r\n", img_u->nam_c, siz_z);
return c3n;
return _ce_img_size;
}
else if ( pgs_z > UINT32_MAX ) {
fprintf(stderr, "loom: %s overflow %zu\r\n", img_u->nam_c, siz_z);
return c3n;
return _ce_img_fail;
}
else {
*pgs_w = (c3_w)pgs_z;
return c3y;
return _ce_img_good;
}
}
}
Expand Down Expand Up @@ -397,7 +403,7 @@ _ce_ephemeral_open(c3_i* eph_i)

/* _ce_image_open(): open or create image.
*/
static c3_o
static _ce_img_stat
_ce_image_open(u3e_image* img_u, c3_c* ful_c)
{
c3_i mod_i = O_RDWR | O_CREAT;
Expand All @@ -406,14 +412,10 @@ _ce_image_open(u3e_image* img_u, c3_c* ful_c)
snprintf(pax_c, 8192, "%s/%s.bin", ful_c, img_u->nam_c);
if ( -1 == (img_u->fid_i = c3_open(pax_c, mod_i, 0666)) ) {
fprintf(stderr, "loom: c3_open %s: %s\r\n", pax_c, strerror(errno));
return c3n;
}
else if ( c3n == _ce_image_stat(img_u, &img_u->pgs_w) ) {
return c3n;
}
else {
return c3y;
return _ce_img_fail;
}

return _ce_image_stat(img_u, &img_u->pgs_w);
}

/* _ce_patch_write_control(): write control block file.
Expand Down Expand Up @@ -1371,13 +1373,18 @@ u3e_backup(c3_c* pux_c, c3_c* pax_c, c3_o ovw_o)
//
c3_c nux_c[8193];
snprintf(nux_c, 8192, "%s/%s.bin", pux_c, nux_u.nam_c);
if ( (0 != access(nux_c, F_OK)) || (c3n == _ce_image_open(&nux_u, pux_c)) ) {
if ( (0 != access(nux_c, F_OK))
|| (_ce_img_good != _ce_image_open(&nux_u, pux_c)) )
{
fprintf(stderr, "loom: couldn't open north image at %s\r\n", pux_c);
return c3n;
}

c3_c sux_c[8193];
snprintf(sux_c, 8192, "%s/%s.bin", pux_c, sux_u.nam_c);
if ( (0 != access(sux_c, F_OK)) || (c3n == _ce_image_open(&sux_u, pux_c)) ) {
if ( (0 != access(sux_c, F_OK))
|| (_ce_img_good != _ce_image_open(&sux_u, pux_c)) )
{
fprintf(stderr, "loom: couldn't open south image at %s\r\n", pux_c);
return c3n;
}
Expand Down Expand Up @@ -1487,9 +1494,9 @@ u3e_save(u3_post low_p, u3_post hig_p)
#ifdef U3_SNAPSHOT_VALIDATION
{
c3_w pgs_w;
u3_assert( c3y == _ce_image_stat(&u3P.nor_u, &pgs_w) );
u3_assert( _ce_img_good == _ce_image_stat(&u3P.nor_u, &pgs_w) );
u3_assert( pgs_w == u3P.nor_u.pgs_w );
u3_assert( c3y == _ce_image_stat(&u3P.sou_u, &pgs_w) );
u3_assert( _ce_img_good == _ce_image_stat(&u3P.sou_u, &pgs_w) );
u3_assert( pgs_w == u3P.sou_u.pgs_w );
}
#endif
Expand Down Expand Up @@ -1590,9 +1597,11 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
//
c3_c chk_c[8193];
snprintf(chk_c, 8193, "%s/.urb/chk", u3P.dir_c);
if ( (c3n == _ce_image_open(&u3P.nor_u, chk_c)) ||
(c3n == _ce_image_open(&u3P.sou_u, chk_c)) )
{

_ce_img_stat nor_e = _ce_image_open(&u3P.nor_u, chk_c);
_ce_img_stat sou_e = _ce_image_open(&u3P.sou_u, chk_c);

if ( (_ce_img_fail == nor_e) || (_ce_img_fail == sou_e) ) {
fprintf(stderr, "boot: image failed\r\n");
exit(1);
}
Expand All @@ -1609,6 +1618,10 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
_ce_patch_free(pat_u);
_ce_patch_delete();
}
else if ( (_ce_img_size == nor_e) || (_ce_img_size == sou_e) ) {
fprintf(stderr, "boot: image failed (size)\r\n");
exit(1);
}

nor_w = u3P.nor_u.pgs_w;
sou_w = u3P.sou_u.pgs_w;
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ u3m_init(size_t len_i)
-1, 0);

u3l_log("boot: mapping %zuMB failed", len_i >> 20);
u3l_log("see urbit.org/using/install/#about-swap-space"
u3l_log("see https://docs.urbit.org/manual/getting-started/self-hosted/cloud-hosting"
" for adding swap space");
if ( -1 != (c3_ps)map_v ) {
u3l_log("if porting to a new platform, try U3_OS_LoomBase %p",
Expand Down
81 changes: 64 additions & 17 deletions pkg/vere/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,18 +1123,39 @@ u3_disk_epoc_zero(u3_disk* log_u)
}

// create epoch version file, overwriting any existing file
c3_c epi_c[8193];
c3_c epv_c[8193];
snprintf(epi_c, sizeof(epv_c), "%s/epoc.tmp", epo_c);
snprintf(epv_c, sizeof(epv_c), "%s/epoc.txt", epo_c);
FILE* epv_f = fopen(epv_c, "w"); // XX errors
fprintf(epv_f, "%d", U3E_VERLAT);
fclose(epv_f);
FILE* epv_f = fopen(epi_c, "w"); // XX errors

if ( !epv_f
|| (0 > fprintf(epv_f, "%d", U3E_VERLAT))
|| fflush(epv_f)
|| (-1 == c3_sync(fileno(epv_f)))
|| fclose(epv_f)
|| (-1 == rename(epi_c, epv_c)) )
{
fprintf(stderr, "disk: write epoc.txt failed %s\r\n", strerror(errno));
goto fail3;
}

// create binary version file, overwriting any existing file
c3_c bii_c[8193];
c3_c biv_c[8193];
snprintf(biv_c, sizeof(biv_c), "%s/vere.txt", epo_c);
FILE* biv_f = fopen(biv_c, "w"); // XX errors
fprintf(biv_f, URBIT_VERSION); // XX append a sentinel for auto-rollover?
fclose(biv_f);
snprintf(bii_c, sizeof(biv_c), "%s/vere.tmp", epo_c);
snprintf(biv_c, sizeof(epv_c), "%s/vere.txt", epo_c);
FILE* biv_f = fopen(bii_c, "w");
if ( !biv_f
|| (0 > fprintf(biv_f, URBIT_VERSION))
|| fflush(biv_f)
|| (-1 == c3_sync(fileno(biv_f)))
|| fclose(biv_f)
|| (-1 == rename(bii_c, biv_c)) )
{
fprintf(stderr, "disk: write vere.txt failed %s\r\n", strerror(errno));
goto fail3;
}

if ( -1 == c3_sync(epo_i) ) { // XX fdatasync on linux?
fprintf(stderr, "disk: sync epoch dir 0i0 failed: %s\r\n", strerror(errno));
Expand Down Expand Up @@ -1205,18 +1226,44 @@ _disk_epoc_roll(u3_disk* log_u, c3_d epo_d)
}

// create epoch version file, overwriting any existing file
c3_c epi_c[8193];
c3_c epv_c[8193];
snprintf(epi_c, sizeof(epv_c), "%s/epoc.tmp", epo_c);
snprintf(epv_c, sizeof(epv_c), "%s/epoc.txt", epo_c);
FILE* epv_f = fopen(epv_c, "w"); // XX errors
fprintf(epv_f, "%d", U3E_VERLAT);
fclose(epv_f);
FILE* epv_f = fopen(epi_c, "w");

if ( !epv_f
|| (0 > fprintf(epv_f, "%d", U3E_VERLAT))
|| fflush(epv_f)
|| (-1 == c3_sync(fileno(epv_f)))
|| fclose(epv_f)
|| (-1 == rename(epi_c, epv_c)) )
{
fprintf(stderr, "disk: write epoc.txt failed %s\r\n", strerror(errno));
goto fail3;
}

// create binary version file, overwriting any existing file
c3_c bii_c[8193];
c3_c biv_c[8193];
snprintf(biv_c, sizeof(biv_c), "%s/vere.txt", epo_c);
FILE* biv_f = fopen(biv_c, "w"); // XX errors
fprintf(biv_f, URBIT_VERSION);
fclose(biv_f);
snprintf(bii_c, sizeof(biv_c), "%s/vere.tmp", epo_c);
snprintf(biv_c, sizeof(epv_c), "%s/vere.txt", epo_c);
FILE* biv_f = fopen(bii_c, "w");
if ( !biv_f
|| (0 > fprintf(biv_f, URBIT_VERSION))
|| fflush(biv_f)
|| (-1 == c3_sync(fileno(biv_f)))
|| fclose(biv_f)
|| (-1 == rename(bii_c, biv_c)) )
{
fprintf(stderr, "disk: write vere.txt failed %s\r\n", strerror(errno));
goto fail3;
}

if ( -1 == c3_sync(epo_i) ) { // XX fdatasync on linux?
fprintf(stderr, "disk: sync epoch dir 0i0 failed: %s\r\n", strerror(errno));
goto fail3;
}

// get metadata from old log
c3_d who_d[2];
Expand Down Expand Up @@ -1707,9 +1754,9 @@ _disk_epoc_load(u3_disk* log_u, c3_d lat_d)
return _epoc_gone;
}

if ( (1 != sscanf(ver_c, "%" SCNu32 "%n", &ver_w, &car_i))
&& (0 < car_i)
&& ('\0' == *(ver_c + car_i)) )
if ( !( (1 == sscanf(ver_c, "%" SCNu32 "%n", &ver_w, &car_i))
&& (0 < car_i)
&& ('\0' == *(ver_c + car_i)) ) )
{
fprintf(stderr, "disk: failed to parse epoch version: '%s'\r\n", ver_c);
return _epoc_fail;
Expand Down
Loading

0 comments on commit ea50c2b

Please sign in to comment.