mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
Kernel+LibCore+LibC: Split the mount syscall into multiple syscalls
This is a preparation before we can create a usable mechanism to use filesystem-specific mount flags. To keep some compatibility with userland code, LibC and LibCore mount functions are kept being usable, but now instead of doing an "atomic" syscall, they do multiple syscalls to perform the complete procedure of mounting a filesystem. The FileBackedFileSystem IntrusiveList in the VFS code is now changed to be protected by a Mutex, because when we mount a new filesystem, we need to check if a filesystem is already created for a given source_fd so we do a scan for that OpenFileDescription in that list. If we fail to find an already-created filesystem we create a new one and register it in the list if we successfully mounted it. We use a Mutex because we might need to initiate disk access during the filesystem creation, which will take other mutexes in other parts of the kernel, therefore making it not possible to take a spinlock while doing this.
This commit is contained in:
parent
63fc36d00d
commit
23a7ccf607
39 changed files with 651 additions and 214 deletions
|
@ -70,6 +70,7 @@ UnixDateTime kgettimeofday();
|
|||
__ENUMERATE_PLEDGE_PROMISE(map_fixed) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(getkeymap) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(jail) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(mount) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(no_error)
|
||||
|
||||
enum class Pledge : u32 {
|
||||
|
@ -395,7 +396,8 @@ public:
|
|||
ErrorOr<FlatPtr> sys$unlink(int dirfd, Userspace<char const*> pathname, size_t path_length, int flags);
|
||||
ErrorOr<FlatPtr> sys$symlink(Userspace<Syscall::SC_symlink_params const*>);
|
||||
ErrorOr<FlatPtr> sys$rmdir(Userspace<char const*> pathname, size_t path_length);
|
||||
ErrorOr<FlatPtr> sys$mount(Userspace<Syscall::SC_mount_params const*>);
|
||||
ErrorOr<FlatPtr> sys$fsmount(Userspace<Syscall::SC_fsmount_params const*>);
|
||||
ErrorOr<FlatPtr> sys$fsopen(Userspace<Syscall::SC_fsopen_params const*>);
|
||||
ErrorOr<FlatPtr> sys$umount(Userspace<char const*> mountpoint, size_t mountpoint_length);
|
||||
ErrorOr<FlatPtr> sys$chmod(Userspace<Syscall::SC_chmod_params const*>);
|
||||
ErrorOr<FlatPtr> sys$fchmod(int fd, mode_t);
|
||||
|
@ -826,11 +828,25 @@ public:
|
|||
return m_fds.with_shared([fd](auto& fds) { return fds.open_file_description(fd); });
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<OpenFileDescription>> open_file_description_ignoring_negative(int fd)
|
||||
{
|
||||
if (fd < 0)
|
||||
return nullptr;
|
||||
return open_file_description(fd);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_file_description(int fd) const
|
||||
{
|
||||
return m_fds.with_shared([fd](auto& fds) { return fds.open_file_description(fd); });
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<OpenFileDescription>> open_file_description_ignoring_negative(int fd) const
|
||||
{
|
||||
if (fd < 0)
|
||||
return nullptr;
|
||||
return open_file_description(fd);
|
||||
}
|
||||
|
||||
ErrorOr<ScopedDescriptionAllocation> allocate_fd()
|
||||
{
|
||||
return m_fds.with_exclusive([](auto& fds) { return fds.allocate(); });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue