mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:18:12 +00:00

This change is another minor step towards removing `AK::String` from the Kernel. Instead of dynamically allocating the storage_name we can instead allocate it via a KString in the factory for each device, and then push the device name down into the StorageDevice base class. We don't have a way of doing `AK::String::formatted(..)` with a KString at the moment, so cleaning that up will be left for a later day.
38 lines
960 B
C++
38 lines
960 B
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/Locking/Mutex.h>
|
|
#include <Kernel/Storage/StorageDevice.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class RamdiskController;
|
|
|
|
class RamdiskDevice final : public StorageDevice {
|
|
friend class RamdiskController;
|
|
friend class DeviceManagement;
|
|
AK_MAKE_ETERNAL
|
|
public:
|
|
static NonnullRefPtr<RamdiskDevice> create(const RamdiskController&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor);
|
|
virtual ~RamdiskDevice() override;
|
|
|
|
// ^DiskDevice
|
|
virtual StringView class_name() const override;
|
|
|
|
private:
|
|
RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Memory::Region>&&, int major, int minor, NonnullOwnPtr<KString> device_name);
|
|
|
|
// ^BlockDevice
|
|
virtual void start_request(AsyncBlockDeviceRequest&) override;
|
|
|
|
Mutex m_lock { "RamdiskDevice" };
|
|
|
|
NonnullOwnPtr<Memory::Region> m_region;
|
|
};
|
|
|
|
}
|