From 5b3980b04067ccc2b795ec407822757a82396157 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 21 Oct 2022 19:30:06 +0300 Subject: [PATCH] Userland: Utilize MS_NOREGULAR mount flag For SystemServer, we simply ensure that the /dev mount is now mounted with MS_NOREGULAR flag to ensure only non-regular files are created, thus, achieving what DevTmpFS provided in its implementation, but in a much more sane and clean way than how DevTmpFS did that. For other userland applications, we simply make them being aware of this flag so they can show an indication about this flag being used to the user. --- Userland/Applications/SystemMonitor/main.cpp | 1 + Userland/Services/SystemServer/main.cpp | 2 +- Userland/Utilities/mount.cpp | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 6876027a68..2d4c38a3a4 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -191,6 +191,7 @@ public: check(MS_RDONLY, "ro"sv); check(MS_WXALLOWED, "wxallowed"sv); check(MS_AXALLOWED, "axallowed"sv); + check(MS_NOREGULAR, "noregular"sv); if (builder.string_view().is_empty()) return String("defaults"); return builder.to_string(); diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index 473b23f196..4bf612aa51 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -380,7 +380,7 @@ static ErrorOr prepare_synthetic_filesystems() // FIXME: Find a better way to all of this stuff, without hardcoding all of this! TRY(Core::System::mount(-1, "/proc"sv, "proc"sv, MS_NOSUID)); TRY(Core::System::mount(-1, "/sys"sv, "sys"sv, 0)); - TRY(Core::System::mount(-1, "/dev"sv, "tmp"sv, MS_NOSUID | MS_NOEXEC)); + TRY(Core::System::mount(-1, "/dev"sv, "tmp"sv, MS_NOSUID | MS_NOEXEC | MS_NOREGULAR)); TRY(Core::System::mkdir("/dev/audio"sv, 0755)); TRY(Core::System::mkdir("/dev/input"sv, 0755)); diff --git a/Userland/Utilities/mount.cpp b/Userland/Utilities/mount.cpp index f220579670..c2a192b57c 100644 --- a/Userland/Utilities/mount.cpp +++ b/Userland/Utilities/mount.cpp @@ -40,6 +40,8 @@ static int parse_options(StringView options) flags |= MS_WXALLOWED; else if (part == "axallowed") flags |= MS_AXALLOWED; + else if (part == "noregular") + flags |= MS_NOREGULAR; else warnln("Ignoring invalid option: {}", part); } @@ -173,6 +175,8 @@ static ErrorOr print_mounts() if (mount_flags & MS_NODEV) out(",nodev"); + if (mount_flags & MS_NOREGULAR) + out(",noregular"); if (mount_flags & MS_NOEXEC) out(",noexec"); if (mount_flags & MS_NOSUID)