mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
Kernel: Implement bind mounts
You can now bind-mount files and directories. This essentially exposes an
existing part of the file system in another place, and can be used as an
alternative to symlinks or hardlinks.
Here's an example of doing this:
# mkdir /tmp/foo
# mount /home/anon/myfile.txt /tmp/foo -o bind
# cat /tmp/foo
This is anon's file.
This commit is contained in:
committed by
Andreas Kling
parent
71f1d3f819
commit
0cb0f54783
@@ -49,6 +49,16 @@ KResult VFS::mount(FS& file_system, Custody& mount_point, int flags)
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult VFS::bind_mount(Custody& source, Custody& mount_point)
|
||||
{
|
||||
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 };
|
||||
m_mounts.append(move(mount));
|
||||
mount_point.did_mount_on({});
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult VFS::unmount(InodeIdentifier guest_inode_id)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
@@ -617,6 +627,14 @@ VFS::Mount::Mount(FS& guest_fs, Custody* host_custody, int flags)
|
||||
{
|
||||
}
|
||||
|
||||
VFS::Mount::Mount(Inode& source, Custody& host_custody)
|
||||
: m_guest(source.identifier())
|
||||
, m_guest_fs(source.fs())
|
||||
, m_host_custody(host_custody)
|
||||
, m_flags(MS_BIND)
|
||||
{
|
||||
}
|
||||
|
||||
String VFS::Mount::absolute_path() const
|
||||
{
|
||||
if (!m_host_custody)
|
||||
|
||||
Reference in New Issue
Block a user