@ai-ecoverse/slicc-kernel 1.110.5 → 1.110.7

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.
@@ -2515,7 +2515,7 @@ var KERNEL_VERSION, OS_RELEASE;
2515
2515
  var init_version = __esm({
2516
2516
  "src/version.ts"() {
2517
2517
  "use strict";
2518
- KERNEL_VERSION = true ? "1.110.5" : "0.0.0-dev";
2518
+ KERNEL_VERSION = true ? "1.110.7" : "0.0.0-dev";
2519
2519
  OS_RELEASE = "6.0.0-slicc";
2520
2520
  }
2521
2521
  });
@@ -3241,6 +3241,7 @@ function useMounts(Fs, env = {}, live = false) {
3241
3241
  if (typeof Fs.open !== "function" || typeof writeFile !== "function") return;
3242
3242
  const { passwd, group } = accounts(env);
3243
3243
  const backing = { "/etc/mtab": "/proc/mounts" };
3244
+ const defaults = {};
3244
3245
  try {
3245
3246
  if (!live) writeFile.call(Fs, "/proc/mounts", mountTable());
3246
3247
  } catch {
@@ -3248,20 +3249,39 @@ function useMounts(Fs, env = {}, live = false) {
3248
3249
  }
3249
3250
  try {
3250
3251
  mkdirTree.call(Fs, "/dev/.etc");
3251
- writeFile.call(Fs, "/dev/.etc/passwd", passwd);
3252
- writeFile.call(Fs, "/dev/.etc/group", group);
3253
- writeFile.call(Fs, "/dev/.etc/hosts", hostsFile(hostnameOf(env)));
3254
- writeFile.call(Fs, "/dev/.etc/hostname", `${hostnameOf(env)}
3255
- `);
3256
- backing["/etc/passwd"] = "/dev/.etc/passwd";
3257
- backing["/etc/group"] = "/dev/.etc/group";
3258
- backing["/etc/hosts"] = "/dev/.etc/hosts";
3259
- backing["/etc/hostname"] = "/dev/.etc/hostname";
3252
+ const files = {
3253
+ passwd,
3254
+ group,
3255
+ hosts: hostsFile(hostnameOf(env)),
3256
+ hostname: `${hostnameOf(env)}
3257
+ `
3258
+ };
3259
+ for (const [name2, text] of Object.entries(files)) {
3260
+ writeFile.call(Fs, `/dev/.etc/${name2}`, text);
3261
+ backing[`/etc/${name2}`] = `/dev/.etc/${name2}`;
3262
+ defaults[`/etc/${name2}`] = text;
3263
+ }
3260
3264
  } catch {
3261
3265
  }
3262
3266
  const open = Fs.open.bind(Fs);
3267
+ const seed = (path, text) => {
3268
+ let stream;
3269
+ try {
3270
+ stream = open(path, O_WRONLY2 | O_CREAT | O_EXCL, 420);
3271
+ } catch {
3272
+ return;
3273
+ }
3274
+ try {
3275
+ const bytes = new TextEncoder().encode(text);
3276
+ Fs.write(stream, bytes, 0, bytes.length);
3277
+ } finally {
3278
+ Fs.closeStream(stream.fd);
3279
+ }
3280
+ };
3263
3281
  Fs.open = (path, flags, mode) => {
3264
3282
  const instead = backing[path];
3283
+ const text = defaults[path];
3284
+ if (text !== void 0 && (flags & (O_ACCMODE3 | O_CREAT)) !== 0) seed(path, text);
3265
3285
  if (!instead || (flags & (O_ACCMODE3 | O_CREAT)) !== 0) return open(path, flags, mode);
3266
3286
  try {
3267
3287
  return open(path, flags, mode);
@@ -3443,7 +3463,7 @@ function linuxDevices(Fs) {
3443
3463
  }
3444
3464
  }
3445
3465
  }
3446
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY2, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE3, O_CREAT, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
3466
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY2, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE3, O_CREAT, O_EXCL, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
3447
3467
  var init_process_fds = __esm({
3448
3468
  "src/process/process-fds.ts"() {
3449
3469
  "use strict";
@@ -3503,6 +3523,7 @@ var init_process_fds = __esm({
3503
3523
  CHAR_DEVICE = 8630;
3504
3524
  O_ACCMODE3 = 3;
3505
3525
  O_CREAT = 64;
3526
+ O_EXCL = 128;
3506
3527
  field = (text) => (text || "none").replace(/[\s\\]/g, (c) => `\\${c.charCodeAt(0).toString(8).padStart(3, "0")}`);
3507
3528
  rootKind = () => globalThis.navigator?.storage ? "opfs" : "memory";
3508
3529
  NAME = /^[a-z_][a-z0-9_-]*$/i;
@@ -3652,7 +3673,7 @@ function datesOf(real) {
3652
3673
  dates[key] = new Date(value2);
3653
3674
  return dates;
3654
3675
  }
3655
- var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, SEALED_PATH, STRERROR, CLIPBOARD_PATH, O_CREAT2, O_EXCL, O_NOCTTY, O_TRUNC2, O_DIRECTORY, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
3676
+ var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, SEALED_PATH, STRERROR, CLIPBOARD_PATH, O_CREAT2, O_EXCL2, O_NOCTTY, O_TRUNC2, O_DIRECTORY, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
3656
3677
  var init_kernel_streams = __esm({
3657
3678
  "src/process/kernel-streams.ts"() {
3658
3679
  "use strict";
@@ -3682,7 +3703,7 @@ var init_kernel_streams = __esm({
3682
3703
  };
3683
3704
  CLIPBOARD_PATH = "/dev/clipboard";
3684
3705
  O_CREAT2 = 64;
3685
- O_EXCL = 128;
3706
+ O_EXCL2 = 128;
3686
3707
  O_NOCTTY = 256;
3687
3708
  O_TRUNC2 = 512;
3688
3709
  O_DIRECTORY = 65536;
@@ -3983,13 +4004,13 @@ var init_kernel_streams = __esm({
3983
4004
  try {
3984
4005
  return open(path, flags, mode);
3985
4006
  } catch (err) {
3986
- const lost = err.errno === wasiErrno("EEXIST") && !(flags & O_EXCL);
4007
+ const lost = err.errno === wasiErrno("EEXIST") && !(flags & O_EXCL2);
3987
4008
  if (!lost) throw err;
3988
4009
  return open(path, flags, mode);
3989
4010
  }
3990
4011
  }
3991
4012
  refuseExclusiveLink(path, flags) {
3992
- if ((flags & (O_CREAT2 | O_EXCL)) !== (O_CREAT2 | O_EXCL)) return;
4013
+ if ((flags & (O_CREAT2 | O_EXCL2)) !== (O_CREAT2 | O_EXCL2)) return;
3993
4014
  let mode = 0;
3994
4015
  try {
3995
4016
  mode = this.Fs.stat?.(path, true)?.mode ?? 0;
@@ -4031,7 +4052,7 @@ var init_kernel_streams = __esm({
4031
4052
  vessel(open, kfd, at, terminal) {
4032
4053
  let stream;
4033
4054
  try {
4034
- stream = open("/dev/null", at.flags & ~(O_CREAT2 | O_EXCL | O_TRUNC2), at.mode);
4055
+ stream = open("/dev/null", at.flags & ~(O_CREAT2 | O_EXCL2 | O_TRUNC2), at.mode);
4035
4056
  } catch (e) {
4036
4057
  this.sys.close(kfd);
4037
4058
  throw e;
@@ -4370,7 +4391,7 @@ function restoreForkedStreams(Fs, streams2, table) {
4370
4391
  } else {
4371
4392
  const placed = place(
4372
4393
  Fs,
4373
- Fs.open(entry.path, entry.flags & ~(O_CREAT3 | O_EXCL2 | O_TRUNC3)),
4394
+ Fs.open(entry.path, entry.flags & ~(O_CREAT3 | O_EXCL3 | O_TRUNC3)),
4374
4395
  entry.fd
4375
4396
  );
4376
4397
  setCloseOnExec(placed, (entry.flags & O_CLOEXEC) !== 0);
@@ -4379,7 +4400,7 @@ function restoreForkedStreams(Fs, streams2, table) {
4379
4400
  }
4380
4401
  }
4381
4402
  }
4382
- var O_RDWR, O_ACCMODE4, O_CREAT3, O_EXCL2, O_TRUNC3, PLACEHOLDER_DIR, NAMED_DEVICES, ACCESS, DEVICES, FIFO_MODE, nextStreamIno, streamInos;
4403
+ var O_RDWR, O_ACCMODE4, O_CREAT3, O_EXCL3, O_TRUNC3, PLACEHOLDER_DIR, NAMED_DEVICES, ACCESS, DEVICES, FIFO_MODE, nextStreamIno, streamInos;
4383
4404
  var init_process_fork = __esm({
4384
4405
  "src/process/process-fork.ts"() {
4385
4406
  "use strict";
@@ -4387,7 +4408,7 @@ var init_process_fork = __esm({
4387
4408
  O_RDWR = 2;
4388
4409
  O_ACCMODE4 = 3;
4389
4410
  O_CREAT3 = 64;
4390
- O_EXCL2 = 128;
4411
+ O_EXCL3 = 128;
4391
4412
  O_TRUNC3 = 512;
4392
4413
  PLACEHOLDER_DIR = "/dev/slicc-fd";
4393
4414
  NAMED_DEVICES = {