libc: warn on missing std*="" or <fd path=""> file

The libc kernel used to silently go on if one of the files given through
stdin/stdout/stderr or <fd path=""> 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
This commit is contained in:
Martin Stein 2022-09-02 13:57:26 +02:00 committed by Norman Feske
parent 5e9e003bb0
commit d9b5e4ae8d

View File

@ -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;
}
};