mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03: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
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/8940552d1d Pull-request: https://github.com/SerenityOS/serenity/pull/19668 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/linusg
@ -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…
Reference in New Issue
Block a user