From 93ff911473a8a6f1c2e8fb70359f8e8acbb77f20 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sun, 12 Jan 2020 19:22:24 +0300 Subject: [PATCH] Kernel: Properly propagate bind mount flags Previously, when performing a bind mount flags other than MS_BIND were ignored. Now, they're properly propagated the same way a for any other mount. --- Kernel/FileSystem/VirtualFileSystem.cpp | 8 ++++---- Kernel/FileSystem/VirtualFileSystem.h | 4 ++-- Kernel/Process.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 3b7c52f11db..af91c3d21e9 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -49,11 +49,11 @@ KResult VFS::mount(FS& file_system, Custody& mount_point, int flags) return KSuccess; } -KResult VFS::bind_mount(Custody& source, Custody& mount_point) +KResult VFS::bind_mount(Custody& source, Custody& mount_point, int flags) { dbg() << "VFS: Bind-mounting " << source.absolute_path() << " at " << mount_point.absolute_path(); // FIXME: check that this is not already a mount point - Mount mount { source.inode(), mount_point }; + Mount mount { source.inode(), mount_point, flags }; m_mounts.append(move(mount)); mount_point.did_mount_on({}); return KSuccess; @@ -631,11 +631,11 @@ VFS::Mount::Mount(FS& guest_fs, Custody* host_custody, int flags) { } -VFS::Mount::Mount(Inode& source, Custody& host_custody) +VFS::Mount::Mount(Inode& source, Custody& host_custody, int flags) : m_guest(source.identifier()) , m_guest_fs(source.fs()) , m_host_custody(host_custody) - , m_flags(MS_BIND) + , m_flags(flags) { } diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index c062d7bba17..2fa748487d4 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -48,7 +48,7 @@ public: class Mount { public: Mount(FS&, Custody* host_custody, int flags); - Mount(Inode& source, Custody& host_custody); + Mount(Inode& source, Custody& host_custody, int flags); InodeIdentifier host() const; InodeIdentifier guest() const { return m_guest; } @@ -74,7 +74,7 @@ public: bool mount_root(FS&); KResult mount(FS&, Custody& mount_point, int flags); - KResult bind_mount(Custody& source, Custody& mount_point); + KResult bind_mount(Custody& source, Custody& mount_point, int flags); KResult unmount(InodeIdentifier guest_inode_id); KResultOr> open(StringView path, int options, mode_t mode, Custody& base, Optional = {}); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 87f52dda081..6e1d34dce81 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -3753,7 +3753,7 @@ int Process::sys$mount(const Syscall::SC_mount_params* user_params) if (source_or_error.is_error()) return source_or_error.error(); auto& source_custody = source_or_error.value(); - return VFS::the().bind_mount(source_custody, target_custody); + return VFS::the().bind_mount(source_custody, target_custody, params.flags); } if (fs_type == "ext2" || fs_type == "Ext2FS") {