From 4a9b6ea81ba653caa05022fbbf73ba5087a499d4 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 30 Oct 2025 02:06:16 +0000 Subject: [PATCH] Improve error message for missing paths in mount operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When mount() fails with ENOENT (No such file or directory), provide a descriptive error message that includes: - Source and destination paths in the error message - System error description (strerror) and errno - Helpful hint about checking source path existence All other mount failures continue to use the generic check() assertion as before, preserving the original error handling behavior for non-ENOENT errors. This makes debugging missing path issues much easier while maintaining the existing error handling for other failure cases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- deps/userns_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deps/userns_common.c b/deps/userns_common.c index c7797e7..83fdbdd 100644 --- a/deps/userns_common.c +++ b/deps/userns_common.c @@ -299,7 +299,15 @@ void bind_mount(const char *src, const char *dest, char read_only) { // We don't expect workspaces to have any submounts in normal operation. // However, for runshell(), workspace could be an arbitrary directory, // including one with sub-mounts, so allow that situation with MS_REC. - check(0 == mount(resolved_src, dest, "", MS_BIND|MS_REC, NULL)); + int mount_result = mount(resolved_src, dest, "", MS_BIND|MS_REC, NULL); + if (mount_result != 0 && errno == ENOENT) { + // Provide a more descriptive error for missing paths + fprintf(stderr, "ERROR: Failed to mount '%s' to '%s': %s (errno %d)\n", + resolved_src, dest, strerror(errno), errno); + fprintf(stderr, " Please ensure that '%s' exists and is accessible.\n", resolved_src); + _exit(1); + } + check(mount_result == 0); // remount to read-only. this requires a separate remount: // https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=9ac77b8a78452eab0612523d27fee52159f5016a