1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

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.
This commit is contained in:
Sergey Bugaev 2020-01-12 19:22:24 +03:00 committed by Andreas Kling
parent b620ed25ab
commit 93ff911473
3 changed files with 7 additions and 7 deletions

View file

@ -49,11 +49,11 @@ KResult VFS::mount(FS& file_system, Custody& mount_point, int flags)
return KSuccess; 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(); dbg() << "VFS: Bind-mounting " << source.absolute_path() << " at " << mount_point.absolute_path();
// FIXME: check that this is not already a mount point // 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)); m_mounts.append(move(mount));
mount_point.did_mount_on({}); mount_point.did_mount_on({});
return KSuccess; 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(source.identifier())
, m_guest_fs(source.fs()) , m_guest_fs(source.fs())
, m_host_custody(host_custody) , m_host_custody(host_custody)
, m_flags(MS_BIND) , m_flags(flags)
{ {
} }

View file

@ -48,7 +48,7 @@ public:
class Mount { class Mount {
public: public:
Mount(FS&, Custody* host_custody, int flags); 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 host() const;
InodeIdentifier guest() const { return m_guest; } InodeIdentifier guest() const { return m_guest; }
@ -74,7 +74,7 @@ public:
bool mount_root(FS&); bool mount_root(FS&);
KResult mount(FS&, Custody& mount_point, int flags); 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); KResult unmount(InodeIdentifier guest_inode_id);
KResultOr<NonnullRefPtr<FileDescription>> open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {}); KResultOr<NonnullRefPtr<FileDescription>> open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {});

View file

@ -3753,7 +3753,7 @@ int Process::sys$mount(const Syscall::SC_mount_params* user_params)
if (source_or_error.is_error()) if (source_or_error.is_error())
return source_or_error.error(); return source_or_error.error();
auto& source_custody = source_or_error.value(); 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") { if (fs_type == "ext2" || fs_type == "Ext2FS") {