@ai-ecoverse/slicc-kernel 1.117.2 → 1.117.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -616,14 +616,14 @@ Directories are renamed with `FileSystemHandle.move()` where available, else by
616
616
  - **cmd:** `12` `F_GETLK`, `13` `F_SETLK` or `14` `F_SETLKW`. Any other cmd is `EINVAL`.
617
617
  - **The struct:** musl's wasm32 `struct flock`, 32 bytes: `l_type` i16 at 0 (`0` read, `1` write, `2` unlock), `l_whence` i16 at 2 (`0` SET, `1` CUR, `2` END, resolved against the descriptor's offset or size), `l_start` i64 at 8, `l_len` i64 at 16 (`0` to EOF and beyond, negative before `l_start`), `l_pid` i32 at 24. The kernel reads and writes only those five fields and never the padding.
618
618
  - **F_GETLK:** with a conflicting lock, it writes that lock back (`l_whence` 0, its absolute start, its length, the holder's pid). Without one, it sets only `l_type` to `2`.
619
- - **Errors (WASI numbers):** `EAGAIN` for a conflict on `F_SETLK` (never `EACCES`), `EINTR` when a signal with a handler ends an `F_SETLKW` wait, `EDEADLK` for a wait that would close a cycle, `EBADF` for a bad descriptor or a lock type the descriptor's access mode doesn't allow, and `EINVAL` for a bad `l_type` or `l_whence` or a start before 0.
619
+ - **Errors (WASI numbers):** `EAGAIN` for a conflict on `F_SETLK` (never `EACCES`), `EINTR` when a signal with a handler ends an `F_SETLKW` wait (a handler installed with `SA_RESTART` runs and the wait goes on, [#931](https://github.com/ai-ecoverse/slicc-kernel/issues/931)), `EDEADLK` for a wait that would close a cycle, `EBADF` for a bad descriptor or a lock type the descriptor's access mode doesn't allow, and `EINVAL` for a bad `l_type` or `l_whence` or a start before 0.
620
620
  - **Semantics:** the same as Emscripten's, above. A libc that finds no import on an older kernel gets `ENOSYS` and keeps its local answer.
621
621
  - **Any kind of descriptor** ([#893](https://github.com/ai-ecoverse/slicc-kernel/issues/893)): a pipe, a socket or a terminal takes record locks too, as on Linux, keyed by the object (both ends of a pipe are one object, each socket is its own, a terminal is one object however often it's opened). `l_whence` `CUR` and `END` count from 0 there.
622
622
  - **`slicc.flock(fd, op) -> errno`** ([#893](https://github.com/ai-ecoverse/slicc-kernel/issues/893)): BSD `flock(2)` locks, with Linux's semantics, for a WASIX program on any descriptor: a regular file, a directory, a pipe, a socket, a terminal or a `/dev` device.
623
623
  - **op:** Linux's bits, `LOCK_SH` `1`, `LOCK_EX` `2` or `LOCK_UN` `8`, optionally with `LOCK_NB` `4`. Anything else is `EINVAL`.
624
624
  - **Owner:** the open file description, not the process. A `dup`'d descriptor and one a forked child or a spawned program inherits share it, so the child's `LOCK_EX|LOCK_NB` is granted and its `LOCK_UN` releases the lock for the parent too. So children that `flock(STDOUT)` an inherited STDOUT don't exclude each other, on Linux either: for that, each child opens a lock file itself. A second open of the same object is another description and conflicts: the file opened again (by any name of it), `/dev/tty` opened again, the other end of a pipe.
625
625
  - **Rules:** shared locks coexist, an exclusive one excludes every other description, and any access mode takes either kind, so `LOCK_EX` on a read-only open excludes (homescoop#758). A conversion drops the old lock before it takes the new one, as on Linux, so a refused `LOCK_NB` conversion leaves no lock. The lock goes with `LOCK_UN` or when the description's last descriptor closes, at exit or kill too. flock locks and `fcntl` record locks are separate and don't block each other.
626
- - **Errors (WASI numbers):** `EAGAIN` for a conflict with `LOCK_NB`, `EINTR` when a signal with a handler ends a wait (as for `F_SETLKW`: a libc that wants `SA_RESTART` asks again), `EBADF` for a bad descriptor, `EINVAL` for a bad op. There's no deadlock detection, as on Linux.
626
+ - **Errors (WASI numbers):** `EAGAIN` for a conflict with `LOCK_NB`, `EINTR` when a signal with a handler ends a wait (with `SA_RESTART` the handler runs and the wait goes on, [#931](https://github.com/ai-ecoverse/slicc-kernel/issues/931)), `EBADF` for a bad descriptor, `EINVAL` for a bad op. There's no deadlock detection, as on Linux.
627
627
  - **Limits:** locks are per kernel ([#675](https://github.com/ai-ecoverse/slicc-kernel/issues/675)). A file the program buffers itself is handed to the kernel at its first `flock`, with every other descriptor the program has open on it. A libc that finds no import on an older kernel gets `ENOSYS`; wasix-libc's `flock()` then keeps its old answer. Emscripten programs and the imports module's `tryLock` are unchanged.
628
628
  - **Rules on a mount:**
629
629
  - a rename across mounts is `EXDEV`, so `mv` copies;
@@ -1252,11 +1252,11 @@ A WASIX C program for `test/integration/wasix-locks.test.mjs` (#722). It calls `
1252
1252
 
1253
1253
  A WASIX C program for `test/integration/flock.test.mjs` (#893). It calls `slicc.flock` and `slicc.fcntl_lock` directly (`import_module("slicc")`). Its arguments are a sequence of steps, run in order:
1254
1254
  - `open SLOT r|w|rw PATH`, `pipe SLOT SLOT`, `pair SLOT SLOT` (a `socketpair`), `dup FROM TO`, `fd SLOT N` (names an inherited descriptor), `close SLOT`;
1255
- - `flock SLOT OP`, where OP is made of `sh`, `ex`, `un` and `nb` (`exnb` is `LOCK_EX|LOCK_NB`) or is a number; `badfd`; `fcntl SLOT r|w|u` (`F_SETLK` on the whole file);
1255
+ - `flock SLOT OP`, where OP is made of `sh`, `ex`, `un` and `nb` (`exnb` is `LOCK_EX|LOCK_NB`) or is a number; `badfd`; `fcntl SLOT r|w|u` (`F_SETLK` on the whole file), `fcntlw SLOT r|w` (`F_SETLKW`);
1256
1256
  - `fork … end` (the child runs the steps up to the matching `end`, its lines start with `child `, and the parent waits for it before it goes on after `end`);
1257
- - `touch PATH`, `await PATH`, `sleep MS`, `say TEXT`, `trap` (a `SIGUSR1` handler).
1257
+ - `touch PATH`, `await PATH`, `sleep MS`, `say TEXT`, `trap` (a `SIGUSR1` handler), `trapr` (one with `SA_RESTART` that prints `handler`).
1258
1258
 
1259
- **Build:** as `wlocktest`. Two builds give the same bytes: `bin/flocktest.wasm` is 58,442 bytes, sha256 `687ecf21c836adda4ef2e328b6032eed28ca7d37efc8e88d3aaefb8fc117115a`.
1259
+ **Build:** as `wlocktest`. Two builds give the same bytes: `bin/flocktest.wasm` is 58,907 bytes, sha256 `58b16f19911e0665ba1fbda3fa6d370d6228f4c59dfc13902f126c6e8b43b120`.
1260
1260
 
1261
1261
  ## License
1262
1262
 
@@ -6285,7 +6285,7 @@ function satisfies(version, range2) {
6285
6285
  }
6286
6286
 
6287
6287
  // src/version.ts
6288
- var KERNEL_VERSION = true ? "1.117.2" : "0.0.0-dev";
6288
+ var KERNEL_VERSION = true ? "1.117.3" : "0.0.0-dev";
6289
6289
  var OS_RELEASE = "6.0.0-slicc";
6290
6290
  function procVersion() {
6291
6291
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -3995,15 +3995,19 @@ var init_wasi_host = __esm({
3995
3995
  locked: () => this.fds.holdLocks(),
3996
3996
  promote: (fd) => this.fds.promote(fd),
3997
3997
  calls: {
3998
- flock: (fd, kind, wait2) => void this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} }),
3999
- set: (target, kind, start2, len, wait2) => void this.o.kernel.call({
4000
- op: "lk-set",
4001
- ...target,
4002
- kind,
4003
- start: start2,
4004
- len,
4005
- ...wait2 ? { wait: wait2 } : {}
4006
- }),
3998
+ flock: (fd, kind, wait2) => void this.fds.restarting(
3999
+ () => this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} })
4000
+ ),
4001
+ set: (target, kind, start2, len, wait2) => void this.fds.restarting(
4002
+ () => this.o.kernel.call({
4003
+ op: "lk-set",
4004
+ ...target,
4005
+ kind,
4006
+ start: start2,
4007
+ len,
4008
+ ...wait2 ? { wait: wait2 } : {}
4009
+ })
4010
+ ),
4007
4011
  get: (target, kind, start2, len) => this.o.kernel.call({ op: "lk-get", ...target, kind, start: start2, len })
4008
4012
  }
4009
4013
  }),
@@ -5377,7 +5381,7 @@ var KERNEL_VERSION, OS_RELEASE;
5377
5381
  var init_version = __esm({
5378
5382
  "src/version.ts"() {
5379
5383
  "use strict";
5380
- KERNEL_VERSION = true ? "1.117.2" : "0.0.0-dev";
5384
+ KERNEL_VERSION = true ? "1.117.3" : "0.0.0-dev";
5381
5385
  OS_RELEASE = "6.0.0-slicc";
5382
5386
  }
5383
5387
  });