forked from Bananymous/banan-os
Kernel: Fix ATADevice naming
ATADevice now stores its name instead of using static buffer. Old static buffer was changing on every name query. I just hadn't noticed since virtual machine disks were always sda.
This commit is contained in:
parent
6f8fce94a0
commit
b767317a7a
|
@ -28,7 +28,7 @@ namespace Kernel
|
||||||
uint64_t sector_count() const { return m_lba_count; }
|
uint64_t sector_count() const { return m_lba_count; }
|
||||||
|
|
||||||
BAN::StringView model() const { return m_model; }
|
BAN::StringView model() const { return m_model; }
|
||||||
BAN::StringView name() const;
|
BAN::StringView name() const { return m_name; }
|
||||||
|
|
||||||
virtual dev_t rdev() const override { return m_rdev; }
|
virtual dev_t rdev() const override { return m_rdev; }
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ namespace Kernel
|
||||||
uint32_t m_sector_words;
|
uint32_t m_sector_words;
|
||||||
uint64_t m_lba_count;
|
uint64_t m_lba_count;
|
||||||
char m_model[41];
|
char m_model[41];
|
||||||
|
char m_name[4] {};
|
||||||
|
|
||||||
const dev_t m_rdev;
|
const dev_t m_rdev;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,10 @@ namespace Kernel
|
||||||
|
|
||||||
detail::ATABaseDevice::ATABaseDevice()
|
detail::ATABaseDevice::ATABaseDevice()
|
||||||
: m_rdev(makedev(get_ata_dev_major(), get_ata_dev_minor()))
|
: m_rdev(makedev(get_ata_dev_major(), get_ata_dev_minor()))
|
||||||
{ }
|
{
|
||||||
|
strcpy(m_name, "sda");
|
||||||
|
m_name[2] += minor(m_rdev);
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> detail::ATABaseDevice::initialize(BAN::Span<const uint16_t> identify_data)
|
BAN::ErrorOr<void> detail::ATABaseDevice::initialize(BAN::Span<const uint16_t> identify_data)
|
||||||
{
|
{
|
||||||
|
@ -99,13 +102,6 @@ namespace Kernel
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::StringView detail::ATABaseDevice::name() const
|
|
||||||
{
|
|
||||||
static char device_name[] = "sda";
|
|
||||||
device_name[2] += minor(m_rdev);
|
|
||||||
return device_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::RefPtr<ATADevice>> ATADevice::create(BAN::RefPtr<ATABus> bus, ATABus::DeviceType type, bool is_secondary, BAN::Span<const uint16_t> identify_data)
|
BAN::ErrorOr<BAN::RefPtr<ATADevice>> ATADevice::create(BAN::RefPtr<ATABus> bus, ATABus::DeviceType type, bool is_secondary, BAN::Span<const uint16_t> identify_data)
|
||||||
{
|
{
|
||||||
auto* device_ptr = new ATADevice(bus, type, is_secondary);
|
auto* device_ptr = new ATADevice(bus, type, is_secondary);
|
||||||
|
|
Loading…
Reference in New Issue