1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +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:
Liav A 2022-12-15 11:42:40 +02:00 committed by Jelle Raaijmakers
parent 63fc36d00d
commit 23a7ccf607
39 changed files with 651 additions and 214 deletions

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2022-2023, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#define MOUNT_SPECIFIC_FLAG_KEY_STRING_MAX_LENGTH 64
#define MOUNT_SPECIFIC_FLAG_NON_ASCII_STRING_TYPE_MAX_LENGTH 64
#define MOUNT_SPECIFIC_FLAG_ASCII_STRING_TYPE_MAX_LENGTH 1024
struct MountSpecificFlag {
u32 key_string_length;
u32 value_length;
enum class ValueType : u32 {
Boolean = 0,
UnsignedInteger,
SignedInteger,
ASCIIString,
};
ValueType value_type;
unsigned char const* key_string_addr;
void const* value_addr;
};

View file

@ -108,6 +108,7 @@ enum IOCtlNumber {
KEYBOARD_IOCTL_SET_NUM_LOCK,
KEYBOARD_IOCTL_GET_CAPS_LOCK,
KEYBOARD_IOCTL_SET_CAPS_LOCK,
MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG,
SIOCATMARK,
SIOCSIFADDR,
SIOCGIFADDR,
@ -190,6 +191,7 @@ enum IOCtlNumber {
#define FIBMAP FIBMAP
#define FIONBIO FIONBIO
#define FIONREAD FIONREAD
#define MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG MOUNT_IOCTL_SET_MOUNT_SPECIFIC_FLAG
#define SOUNDCARD_IOCTL_SET_SAMPLE_RATE SOUNDCARD_IOCTL_SET_SAMPLE_RATE
#define SOUNDCARD_IOCTL_GET_SAMPLE_RATE SOUNDCARD_IOCTL_GET_SAMPLE_RATE
#define STORAGE_DEVICE_GET_SIZE STORAGE_DEVICE_GET_SIZE

View file

@ -82,6 +82,8 @@ enum class NeedsBigProcessLock {
S(fork, NeedsBigProcessLock::No) \
S(fstat, NeedsBigProcessLock::No) \
S(fstatvfs, NeedsBigProcessLock::No) \
S(fsopen, NeedsBigProcessLock::No) \
S(fsmount, NeedsBigProcessLock::No) \
S(fsync, NeedsBigProcessLock::No) \
S(ftruncate, NeedsBigProcessLock::No) \
S(futex, NeedsBigProcessLock::Yes) \
@ -128,7 +130,6 @@ enum class NeedsBigProcessLock {
S(mkdir, NeedsBigProcessLock::No) \
S(mknod, NeedsBigProcessLock::No) \
S(mmap, NeedsBigProcessLock::No) \
S(mount, NeedsBigProcessLock::Yes) \
S(mprotect, NeedsBigProcessLock::No) \
S(mremap, NeedsBigProcessLock::No) \
S(msync, NeedsBigProcessLock::No) \
@ -432,9 +433,19 @@ struct SC_rename_params {
StringArgument new_path;
};
struct SC_mount_params {
StringArgument target;
struct SC_fsopen_params {
StringArgument fs_type;
int flags;
};
struct SC_fsmount_params {
int mount_fd;
StringArgument target;
int source_fd;
};
struct SC_bindmount_params {
StringArgument target;
int source_fd;
int flags;
};
@ -444,12 +455,6 @@ struct SC_remount_params {
int flags;
};
struct SC_bindmount_params {
StringArgument target;
int source_fd;
int flags;
};
struct SC_pledge_params {
StringArgument promises;
StringArgument execpromises;