From d9b5e4ae8dd2c392805a5437942efcbb19906ab7 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Fri, 2 Sep 2022 13:57:26 +0200 Subject: [PATCH] libc: warn on missing std*="" or file The libc kernel used to silently go on if one of the files given through stdin/stdout/stderr or was missing (with possibly vital functionality for the component not working). A pointer to the presumably simple configuration issue of the underlying scenario was not given to the user. With this commit, the libc kernel prints a descriptive warning before proceeding with the invalid file descriptor Fixes #4218 --- repos/libports/src/lib/libc/kernel.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repos/libports/src/lib/libc/kernel.cc b/repos/libports/src/lib/libc/kernel.cc index 9c76ef8768..2324951b0f 100644 --- a/repos/libports/src/lib/libc/kernel.cc +++ b/repos/libports/src/lib/libc/kernel.cc @@ -181,8 +181,10 @@ void Libc::Kernel::_init_file_descriptors() Absolute_path const path { resolve_absolute_path(attr_value) }; struct stat out_stat { }; - if (_vfs.stat_from_kernel(path.string(), &out_stat) != 0) + if (_vfs.stat_from_kernel(path.string(), &out_stat) != 0) { + warning("failed to call 'stat' on ", path); return; + } File_descriptor *fd = _vfs.open_from_kernel(path.string(), flags, libc_fd); @@ -218,7 +220,7 @@ void Libc::Kernel::_init_file_descriptors() _vfs.lseek_from_kernel(fd, seek); } catch (Symlink_resolve_error) { - warning("failed to resolve ", attr_value); + warning("failed to resolve path for ", attr_value); return; } };