Serenity Operating System
at master 57 lines 1.2 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <AK/HashMap.h> 8#include <AK/Singleton.h> 9#include <AK/StringView.h> 10#include <Kernel/FileSystem/FileSystem.h> 11#include <Kernel/FileSystem/Inode.h> 12#include <Kernel/FileSystem/VirtualFileSystem.h> 13#include <Kernel/InterruptDisabler.h> 14#include <Kernel/Memory/MemoryManager.h> 15#include <Kernel/Net/LocalSocket.h> 16 17namespace Kernel { 18 19static u32 s_lastFileSystemID; 20 21FileSystem::FileSystem() 22 : m_fsid(++s_lastFileSystemID) 23{ 24} 25 26FileSystem::~FileSystem() 27{ 28} 29 30ErrorOr<void> FileSystem::prepare_to_unmount() 31{ 32 return m_attach_count.with([&](auto& attach_count) -> ErrorOr<void> { 33 if (attach_count == 1) 34 return prepare_to_clear_last_mount(); 35 return {}; 36 }); 37} 38 39FileSystem::DirectoryEntryView::DirectoryEntryView(StringView n, InodeIdentifier i, u8 ft) 40 : name(n) 41 , inode(i) 42 , file_type(ft) 43{ 44} 45 46void FileSystem::sync() 47{ 48 Inode::sync_all(); 49 VirtualFileSystem::the().sync_filesystems(); 50} 51 52void FileSystem::lock_all() 53{ 54 VirtualFileSystem::the().lock_all_filesystems(); 55} 56 57}