From e821b349b283150234472b4b773fe3bd81125825 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 30 Jun 2021 00:25:03 -0600 Subject: [PATCH] Kernel: Give Devices without a custody a less fake absoulte_path This hack allows self-test mode run-tests-and-shutdown.sh to give TestProcFs a stat(2)-able /proc/self/fd/0. For some reason, when stdin is a SerialDevice, /proc/self/fd/0 will be a symlink to the device as expected, but, calling realpath or stat on /proc/self/fd/0 will error out. realpath will give the string from Device::absolute_path() which would be something like "device:4,64 (SerialDevice)". When VFS is trying to resolve_path so that we can stat the file, it would bail out on this fake-y path. Change the fake path (that doesn't show up when you ls a device, nor when checking the devices tab in SystemMonitor) from the major/minor device number and class_name() to /dev/device_name(). There's probably a very hairy yak standing behind this issue that was only discovered due to the ProcFS rework. --- Kernel/Devices/Device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index d4349414bb..1a64215005 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -52,7 +52,8 @@ Device::~Device() String Device::absolute_path() const { - return String::formatted("device:{},{} ({})", m_major, m_minor, class_name()); + // FIXME: Don't assume mount point for DevFs + return String::formatted("/dev/{}", device_name()); } String Device::absolute_path(const FileDescription&) const