mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Kernel/VirtualFileSystem: Allow unmounting via inode and mount path
This pair of information uniquely identifies any mount point, and it can be used in situations where mount point custodies are not available.
This commit is contained in:
parent
abc1eaff36
commit
8940552d1d
2 changed files with 6 additions and 2 deletions
|
@ -267,15 +267,18 @@ ErrorOr<void> VirtualFileSystem::unmount(Custody& mountpoint_custody)
|
|||
{
|
||||
auto& guest_inode = mountpoint_custody.inode();
|
||||
auto custody_path = TRY(mountpoint_custody.try_serialize_absolute_path());
|
||||
dbgln("VirtualFileSystem: unmount called with inode {} on mountpoint {}", guest_inode.identifier(), custody_path->view());
|
||||
return unmount(guest_inode, custody_path->view());
|
||||
}
|
||||
|
||||
ErrorOr<void> VirtualFileSystem::unmount(Inode& guest_inode, StringView custody_path)
|
||||
{
|
||||
return m_file_backed_file_systems_list.with_exclusive([&](auto& file_backed_fs_list) -> ErrorOr<void> {
|
||||
TRY(m_mounts.with([&](auto& mounts) -> ErrorOr<void> {
|
||||
for (auto& mount : mounts) {
|
||||
if (&mount.guest() != &guest_inode)
|
||||
continue;
|
||||
auto mountpoint_path = TRY(mount.absolute_path());
|
||||
if (custody_path->view() != mountpoint_path->view())
|
||||
if (custody_path != mountpoint_path->view())
|
||||
continue;
|
||||
NonnullRefPtr<FileSystem> fs = mount.guest_fs();
|
||||
TRY(fs->prepare_to_unmount(mount.guest()));
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
ErrorOr<void> bind_mount(Custody& source, Custody& mount_point, int flags);
|
||||
ErrorOr<void> remount(Custody& mount_point, int new_flags);
|
||||
ErrorOr<void> unmount(Custody& mount_point);
|
||||
ErrorOr<void> unmount(Inode& guest_inode, StringView custody_path);
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open(Credentials const&, StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {});
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open(Process const&, Credentials const&, StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {});
|
||||
|
|
Loading…
Add table
Reference in a new issue