mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription
This patch switches away from {Nonnull,}LockRefPtr to the non-locking smart pointers throughout the kernel. I've looked at the handful of places where these were being persisted and I don't see any race situations. Note that the process file descriptor table (Process::m_fds) was already guarded via MutexProtected.
This commit is contained in:
parent
36b0ecfe9e
commit
d1371d66f7
34 changed files with 82 additions and 80 deletions
|
@ -59,7 +59,7 @@ ErrorOr<NonnullOwnPtr<KString>> Device::pseudo_path(OpenFileDescription const&)
|
|||
return KString::formatted("device:{},{}", major(), minor());
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> Device::open(int options)
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> Device::open(int options)
|
||||
{
|
||||
TRY(Process::current().jail().with([&](auto const& my_jail) -> ErrorOr<void> {
|
||||
if (my_jail && !is_openable_by_jailed_processes())
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
MinorNumber minor() const { return m_minor; }
|
||||
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
UserID uid() const { return m_uid; }
|
||||
GroupID gid() const { return m_gid; }
|
||||
|
|
|
@ -65,7 +65,7 @@ void KCOVDevice::free_process()
|
|||
delete kcov_instance;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> KCOVDevice::open(int options)
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> KCOVDevice::open(int options)
|
||||
{
|
||||
auto pid = Process::current().pid();
|
||||
if (proc_instance->get(pid).has_value())
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
// ^File
|
||||
ErrorOr<NonnullLockRefPtr<Memory::VMObject>> vmobject_for_mmap(Process&, Memory::VirtualRange const&, u64& offset, bool shared) override;
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
protected:
|
||||
KCOVDevice();
|
||||
|
|
|
@ -19,7 +19,7 @@ UNMAP_AFTER_INIT NonnullLockRefPtr<SelfTTYDevice> SelfTTYDevice::must_create()
|
|||
return self_tty_device_or_error.release_value();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> SelfTTYDevice::open(int options)
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> SelfTTYDevice::open(int options)
|
||||
{
|
||||
// Note: If for some odd reason we try to open this device (early on boot?)
|
||||
// while there's no current Process assigned, don't fail and return an error.
|
||||
|
|
|
@ -24,7 +24,7 @@ private:
|
|||
virtual bool is_openable_by_jailed_processes() const override { return true; }
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue