diff --git a/CHANGELOG.md b/CHANGELOG.md index b449122..1e5b762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,46 @@ +## 0.14.0 (2026-11-26) + +### Features + +- `env_scrub.childClearNames` returns the install-location names in + `src/env-scrub.json`, in the order `eb-local env` prints them. +- `logs.gzipInPlaceAtStep` compresses a log as `logs.gzipInPlace` does, and on an error sets a `logs.GzipStep` that says whether the error came before the archive was in place (`archive`) or from the sync of its directory afterwards (`directory_sync`). `gzipInPlace` keeps its signature and calls it. + +### Fixes + +- `atomic.atomicWrite` and `atomic.atomicWriteAt` sync and close the temporary file before renaming it over the destination. A failed close is returned as `sys.Error`, the destination is left as it was, and the temporary file is removed. `atomicWrite` puts that errno in `why` with no path, as it does for a failed write or fsync. Before this change, `atomicWrite` ignored the close, and `atomicWriteAt` closed only after the rename and ignored the result. A write that the Network File System (NFS) reported lost at the close then replaced the destination and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The call is replaceable through `atomic.ops.close` in the same builds as the other `atomic.ops` calls. +- `fsx.TempDir.get` does not keep a directory whose probe file close fails, so a write that a network file system (NFS) reported lost at the close is not committed as the temporary directory. The probe file is removed. A close that `EINTR` interrupts counts as success and is not retried. The close goes through `fsx.temp_probe_ops`. +- `fsx.absPath` returns `Error` as well as `Allocator.Error` in its error set, which is a source-breaking change for callers that switch exhaustively on its errors. It handles a removed working directory, reporting `error.NotFound`. +- `fsx.appendLine` closes the list after the line is written and returns that close. A failed close is returned as `sys.Error` with `sys.last_errno` set. The line is not removed, because the descriptor is already gone and the file is not shortened back to its old size. Before this change the close result was ignored, so a write that a network file system (NFS) reported lost at the close was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The close is replaceable through `fsx.publish_ops` in the same builds as `atomic.ops`. A cleanup close on an earlier error still ignores its result so the earlier error keeps its errno. +- `fsx.copyTo` closes the temporary file before the rename that publishes it. A failed close is returned with `sys.last_errno` set, the destination keeps its old contents, and the temporary file is removed. A close that `EINTR` interrupts counts as success and is not retried. The caller still gets an open descriptor of the published file. +- `fsx.moveAcross` closes a copied directory after syncing it and before the rename that publishes the copy, including each directory of a copied tree. `fsx.copyTo` and `moveAcross` close the parent directory after the sync that makes the new name durable. `atomic.fsyncDir` and the parent directory sync in `atomic.atomicWrite` check that close as well, as does the directory sync at the end of `logs.gzipInPlace`. A failed close is returned as `sys.Error`. A close on the way out of an earlier error is ignored and that errno is kept. Before this change those closes were ignored, so a directory sync that a network file system (NFS) reported lost only at the close was returned as success. Before the rename, a failure leaves the destination name as it was and removes the temporary path. After the rename, the published name keeps what the rename put there. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The closes go through `fsx.publish_ops`, `atomic.ops.close` and `logs.gzip_ops` in the same builds as the other replaceable calls. +- `fsx.replaceContents` closes the file before the rename that publishes it. So does the cross-device copy inside `fsx.moveAcross`, for a regular file and for each regular file of a copied tree. A failed close is returned as `sys.Error`, the destination is left as it was, and the temporary path is removed. Before this change, the close of `replaceContents` ran after the rename, and the copy ignored the result of its close. A write that the Network File System (NFS) reported lost at the close was then published and returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The close is replaceable through `fsx.publish_ops` in the same builds as `atomic.ops`. +- `logs.gzipInPlace` and `logs.gzipInPlaceAtStep` sync and close the temporary archive before renaming it over `name.gz`. A failed close is returned as `sys.Error`, the temporary file is removed, and the log and any existing archive are left as they were. Before this change the archive was closed after the rename and the close error was dropped, so a write that a network file system (NFS) reported lost at the close published `name.gz`, removed the log, and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The call is replaceable through `logs.gzip_ops` in the same builds as `atomic.ops`. +- `state.RootLock.release` reports a failed release of the state-root lock. It closes both lock files and returns the first error as `sys.Error`. It used to drop that error, so callers that discarded the result have to handle it. +- `state.createPrivateAt` returns a failed close of the file it creates as `sys.Error`, with that errno in `sys.last_errno`. The created name is left in place, including when the close fails. Before this change the close was ignored, so a write that a network file system (NFS) reported lost at the close was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. After an earlier error, the cleanup close ignores its result and keeps that error's errno. The close goes through `state.write_ops.close`, the same replaceable call `state.writePrivate` uses. +- `state.writePrivate` syncs and closes the temporary file before it renames it over the name. A failed fsync or close is returned as `sys.Error`, the name is left as it was, and the temporary file is removed. Before this change the file was closed after the rename and the close error was dropped, so a write that a network file system (NFS) reported lost at the close replaced the name and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The calls are replaceable through `state.write_ops` in the same builds as `state.lock_ops`. + +### Documentation + +- The API reference and the compress-and-mark-logs how-to list `logs.GzipStep` and `logs.gzipInPlaceAtStep`, and the how-to shows how to read the step an error came from. +- The README module table lists `argparse`, and COMPAT.md names eb-local as a consumer of 0.13.0. +- `logs.GzipStep` says that an `archive` error from opening `name` changes nothing, so a `name` that was already absent stays absent and any `name.gz` already there is left alone, that after a later `archive` error the original is still there and `name.gz` is absent unless it existed before or both the removal of the original and the removal of the archive failed, and that `directory_sync` follows one rename and one unlink. + +### Miscellaneous + +- Add a descriptor count around the `proc` paths that call `sys.keepAboveStdio`, checking `/proc/self/fd` before and after so a leaked descriptor fails the test. +- Add a test that `state.RootLock.release` returns the error when the `fcntl` or `flock` release fails through `state.lock_ops`, returns the record lock error when both fail, and closes both lock descriptors in each case. +- Add a test that `sys.keepAboveStdio` returns `error.Unexpected` and leaves the original descriptor open when duplication fails with `EMFILE`. +- Add tests that `state.writePrivate` returns a failed `fsync` or `close` injected through `state.write_ops`, closes the descriptor once, leaves the name and no temporary file, retries an `fsync` that `EINTR` interrupts, and treats a `close` that `EINTR` interrupts as success without a retry. +- Move the forked-child wait that retries an interrupted `wait4` into the shared test helper. +- Move the open-descriptor count into a shared test helper and return an error when reading `/proc/self/fd` fails. +- Move the scratch directory the `logs` tests and the `fsx` `moveAcross` fixture make into `test_support.ScratchDir`, which removes a directory left by an earlier run of the same pid before it creates its own. +- Prepare `zig-common` `0.14.0` in `COMPAT.md` for callers of `fsx.absPath`, whose error set now includes `Error` as well as `Allocator.Error`. + + ## 0.13.0 (2026-11-24) ### Features diff --git a/COMPAT.md b/COMPAT.md index 6fdb56c..05aa452 100644 --- a/COMPAT.md +++ b/COMPAT.md @@ -2,6 +2,7 @@ | zig-common | Zig | tools built on it | |---|---|---| +| 0.14.0 | 0.17.1 | eb-local, eb-keep-logs and eessi-arch-guard on their next releases (`fsx.absPath` returns `Error` as well as `Allocator.Error`; a removed working directory is `error.NotFound`); eb-keep-logs builds against it in CI | | 0.13.0 | 0.17.1 | eb-local 3.5.0; eb-keep-logs and eessi-arch-guard on their next releases (`syslog` without the functions that take no `Identity`; `emitFor` and `send` are unchanged); eb-keep-logs builds against it in CI | | 0.12.0 | 0.17.1 | eb-keep-logs (`syslog.emitFor` with its own `Identity`) and eessi-arch-guard (`syslog.send`, the transport under its own formatting) on their next releases; eb-keep-logs builds against it in CI | | 0.11.0 | 0.17.1 | eb-keep-logs and eessi-arch-guard on their next releases (`syslog`: the RFC 5424 and journald emitter each carried a copy of); eb-keep-logs builds against it in CI | diff --git a/build.zig.zon b/build.zig.zon index 0e703fd..9a03afc 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .zig_common, - .version = "0.13.0", + .version = "0.14.0", .fingerprint = 0xa9bcabd6798f1690, .minimum_zig_version = "0.17.1", .dependencies = .{}, diff --git a/changelog.d/+appendline-close.bugfix.md b/changelog.d/+appendline-close.bugfix.md deleted file mode 100644 index 9b03ef9..0000000 --- a/changelog.d/+appendline-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`fsx.appendLine` closes the list after the line is written and returns that close. A failed close is returned as `sys.Error` with `sys.last_errno` set. The line is not removed, because the descriptor is already gone and the file is not shortened back to its old size. Before this change the close result was ignored, so a write that a network file system (NFS) reported lost at the close was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The close is replaceable through `fsx.publish_ops` in the same builds as `atomic.ops`. A cleanup close on an earlier error still ignores its result so the earlier error keeps its errno. diff --git a/changelog.d/+atomic-write-close.bugfix.md b/changelog.d/+atomic-write-close.bugfix.md deleted file mode 100644 index bc38fb9..0000000 --- a/changelog.d/+atomic-write-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`atomic.atomicWrite` and `atomic.atomicWriteAt` sync and close the temporary file before renaming it over the destination. A failed close is returned as `sys.Error`, the destination is left as it was, and the temporary file is removed. `atomicWrite` puts that errno in `why` with no path, as it does for a failed write or fsync. Before this change, `atomicWrite` ignored the close, and `atomicWriteAt` closed only after the rename and ignored the result. A write that the Network File System (NFS) reported lost at the close then replaced the destination and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The call is replaceable through `atomic.ops.close` in the same builds as the other `atomic.ops` calls. diff --git a/changelog.d/+copyto-file-close.bugfix.md b/changelog.d/+copyto-file-close.bugfix.md deleted file mode 100644 index ca3f91c..0000000 --- a/changelog.d/+copyto-file-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`fsx.copyTo` closes the temporary file before the rename that publishes it. A failed close is returned with `sys.last_errno` set, the destination keeps its old contents, and the temporary file is removed. A close that `EINTR` interrupts counts as success and is not retried. The caller still gets an open descriptor of the published file. diff --git a/changelog.d/+create-private-close.bugfix.md b/changelog.d/+create-private-close.bugfix.md deleted file mode 100644 index 419e86c..0000000 --- a/changelog.d/+create-private-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`state.createPrivateAt` returns a failed close of the file it creates as `sys.Error`, with that errno in `sys.last_errno`. The created name is left in place, including when the close fails. Before this change the close was ignored, so a write that a network file system (NFS) reported lost at the close was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. After an earlier error, the cleanup close ignores its result and keeps that error's errno. The close goes through `state.write_ops.close`, the same replaceable call `state.writePrivate` uses. diff --git a/changelog.d/+dir-close-after-sync.bugfix.md b/changelog.d/+dir-close-after-sync.bugfix.md deleted file mode 100644 index d50f0b7..0000000 --- a/changelog.d/+dir-close-after-sync.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`fsx.moveAcross` closes a copied directory after syncing it and before the rename that publishes the copy, including each directory of a copied tree. `fsx.copyTo` and `moveAcross` close the parent directory after the sync that makes the new name durable. `atomic.fsyncDir` and the parent directory sync in `atomic.atomicWrite` check that close as well, as does the directory sync at the end of `logs.gzipInPlace`. A failed close is returned as `sys.Error`. A close on the way out of an earlier error is ignored and that errno is kept. Before this change those closes were ignored, so a directory sync that a network file system (NFS) reported lost only at the close was returned as success. Before the rename, a failure leaves the destination name as it was and removes the temporary path. After the rename, the published name keeps what the rename put there. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The closes go through `fsx.publish_ops`, `atomic.ops.close` and `logs.gzip_ops` in the same builds as the other replaceable calls. diff --git a/changelog.d/+env-scrub-policy.feature.md b/changelog.d/+env-scrub-policy.feature.md deleted file mode 100644 index 66ae8fd..0000000 --- a/changelog.d/+env-scrub-policy.feature.md +++ /dev/null @@ -1,2 +0,0 @@ -`env_scrub.childClearNames` returns the install-location names in -`src/env-scrub.json`, in the order `eb-local env` prints them. diff --git a/changelog.d/+fsx-publish-close.bugfix.md b/changelog.d/+fsx-publish-close.bugfix.md deleted file mode 100644 index 2f49b82..0000000 --- a/changelog.d/+fsx-publish-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`fsx.replaceContents` closes the file before the rename that publishes it. So does the cross-device copy inside `fsx.moveAcross`, for a regular file and for each regular file of a copied tree. A failed close is returned as `sys.Error`, the destination is left as it was, and the temporary path is removed. Before this change, the close of `replaceContents` ran after the rename, and the copy ignored the result of its close. A write that the Network File System (NFS) reported lost at the close was then published and returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The close is replaceable through `fsx.publish_ops` in the same builds as `atomic.ops`. diff --git a/changelog.d/+gzip-step-comments.doc.md b/changelog.d/+gzip-step-comments.doc.md deleted file mode 100644 index c4e7bde..0000000 --- a/changelog.d/+gzip-step-comments.doc.md +++ /dev/null @@ -1 +0,0 @@ -`logs.GzipStep` says that an `archive` error from opening `name` changes nothing, so a `name` that was already absent stays absent and any `name.gz` already there is left alone, that after a later `archive` error the original is still there and `name.gz` is absent unless it existed before or both the removal of the original and the removal of the archive failed, and that `directory_sync` follows one rename and one unlink. diff --git a/changelog.d/+gzip-step-docs.doc.md b/changelog.d/+gzip-step-docs.doc.md deleted file mode 100644 index e8347d3..0000000 --- a/changelog.d/+gzip-step-docs.doc.md +++ /dev/null @@ -1 +0,0 @@ -The API reference and the compress-and-mark-logs how-to list `logs.GzipStep` and `logs.gzipInPlaceAtStep`, and the how-to shows how to read the step an error came from. diff --git a/changelog.d/+gzip-step-report.feature.md b/changelog.d/+gzip-step-report.feature.md deleted file mode 100644 index a98ef09..0000000 --- a/changelog.d/+gzip-step-report.feature.md +++ /dev/null @@ -1 +0,0 @@ -`logs.gzipInPlaceAtStep` compresses a log as `logs.gzipInPlace` does, and on an error sets a `logs.GzipStep` that says whether the error came before the archive was in place (`archive`) or from the sync of its directory afterwards (`directory_sync`). `gzipInPlace` keeps its signature and calls it. diff --git a/changelog.d/+keep-above-stdio-emfile-test.misc.md b/changelog.d/+keep-above-stdio-emfile-test.misc.md deleted file mode 100644 index 8b1af94..0000000 --- a/changelog.d/+keep-above-stdio-emfile-test.misc.md +++ /dev/null @@ -1 +0,0 @@ -Add a test that `sys.keepAboveStdio` returns `error.Unexpected` and leaves the original descriptor open when duplication fails with `EMFILE`. diff --git a/changelog.d/+lock-release-error.bugfix.md b/changelog.d/+lock-release-error.bugfix.md deleted file mode 100644 index 88986b2..0000000 --- a/changelog.d/+lock-release-error.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`state.RootLock.release` reports a failed release of the state-root lock. It closes both lock files and returns the first error as `sys.Error`. It used to drop that error, so callers that discarded the result have to handle it. diff --git a/changelog.d/+lock-release-unlock-test.misc.md b/changelog.d/+lock-release-unlock-test.misc.md deleted file mode 100644 index 380e7a9..0000000 --- a/changelog.d/+lock-release-unlock-test.misc.md +++ /dev/null @@ -1 +0,0 @@ -Add a test that `state.RootLock.release` returns the error when the `fcntl` or `flock` release fails through `state.lock_ops`, returns the record lock error when both fail, and closes both lock descriptors in each case. diff --git a/changelog.d/+logs-gzip-close.bugfix.md b/changelog.d/+logs-gzip-close.bugfix.md deleted file mode 100644 index cf87be6..0000000 --- a/changelog.d/+logs-gzip-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`logs.gzipInPlace` and `logs.gzipInPlaceAtStep` sync and close the temporary archive before renaming it over `name.gz`. A failed close is returned as `sys.Error`, the temporary file is removed, and the log and any existing archive are left as they were. Before this change the archive was closed after the rename and the close error was dropped, so a write that a network file system (NFS) reported lost at the close published `name.gz`, removed the log, and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The call is replaceable through `logs.gzip_ops` in the same builds as `atomic.ops`. diff --git a/changelog.d/+proc-keep-above-stdio-fd-count.misc.md b/changelog.d/+proc-keep-above-stdio-fd-count.misc.md deleted file mode 100644 index 7f14d57..0000000 --- a/changelog.d/+proc-keep-above-stdio-fd-count.misc.md +++ /dev/null @@ -1 +0,0 @@ -Add a descriptor count around the `proc` paths that call `sys.keepAboveStdio`, checking `/proc/self/fd` before and after so a leaked descriptor fails the test. diff --git a/changelog.d/+readme-argparse-compat-eb-local.doc.md b/changelog.d/+readme-argparse-compat-eb-local.doc.md deleted file mode 100644 index b289871..0000000 --- a/changelog.d/+readme-argparse-compat-eb-local.doc.md +++ /dev/null @@ -1 +0,0 @@ -The README module table lists `argparse`, and COMPAT.md names eb-local as a consumer of 0.13.0. diff --git a/changelog.d/+scratch-dir-test-helper.misc.md b/changelog.d/+scratch-dir-test-helper.misc.md deleted file mode 100644 index 71affa6..0000000 --- a/changelog.d/+scratch-dir-test-helper.misc.md +++ /dev/null @@ -1 +0,0 @@ -Move the scratch directory the `logs` tests and the `fsx` `moveAcross` fixture make into `test_support.ScratchDir`, which removes a directory left by an earlier run of the same pid before it creates its own. diff --git a/changelog.d/+shared-child-wait.misc.md b/changelog.d/+shared-child-wait.misc.md deleted file mode 100644 index b9dacde..0000000 --- a/changelog.d/+shared-child-wait.misc.md +++ /dev/null @@ -1 +0,0 @@ -Move the forked-child wait that retries an interrupted `wait4` into the shared test helper. diff --git a/changelog.d/+shared-fd-count.misc.md b/changelog.d/+shared-fd-count.misc.md deleted file mode 100644 index c464bf6..0000000 --- a/changelog.d/+shared-fd-count.misc.md +++ /dev/null @@ -1 +0,0 @@ -Move the open-descriptor count into a shared test helper and return an error when reading `/proc/self/fd` fails. diff --git a/changelog.d/+tempdir-probe-close.bugfix.md b/changelog.d/+tempdir-probe-close.bugfix.md deleted file mode 100644 index 45f377d..0000000 --- a/changelog.d/+tempdir-probe-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`fsx.TempDir.get` does not keep a directory whose probe file close fails, so a write that a network file system (NFS) reported lost at the close is not committed as the temporary directory. The probe file is removed. A close that `EINTR` interrupts counts as success and is not retried. The close goes through `fsx.temp_probe_ops`. diff --git a/changelog.d/+write-private-close-test.misc.md b/changelog.d/+write-private-close-test.misc.md deleted file mode 100644 index 11dbbf8..0000000 --- a/changelog.d/+write-private-close-test.misc.md +++ /dev/null @@ -1 +0,0 @@ -Add tests that `state.writePrivate` returns a failed `fsync` or `close` injected through `state.write_ops`, closes the descriptor once, leaves the name and no temporary file, retries an `fsync` that `EINTR` interrupts, and treats a `close` that `EINTR` interrupts as success without a retry. diff --git a/changelog.d/+write-private-close.bugfix.md b/changelog.d/+write-private-close.bugfix.md deleted file mode 100644 index 7bd2fa5..0000000 --- a/changelog.d/+write-private-close.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -`state.writePrivate` syncs and closes the temporary file before it renames it over the name. A failed fsync or close is returned as `sys.Error`, the name is left as it was, and the temporary file is removed. Before this change the file was closed after the rename and the close error was dropped, so a write that a network file system (NFS) reported lost at the close replaced the name and was returned as success. A close that `EINTR` interrupts is not retried and is not an error, as `sys.result` treats `EINTR`. The calls are replaceable through `state.write_ops` in the same builds as `state.lock_ops`. diff --git a/src/proc.zig b/src/proc.zig index 4be267b..cded4b1 100644 --- a/src/proc.zig +++ b/src/proc.zig @@ -285,7 +285,8 @@ pub fn resolveExecutable(gpa: Allocator, name: []const u8, path_env: ?[]const u8 else fsx.absPath(gpa, name) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, - // No absolute path exists when the working directory is gone. + // `else => null` also swallows `ERANGE` and any other `getcwd` + // failure, not only a removed working directory. else => return null, }; if (!isExecutableFile(abs)) {