summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-04-01 11:18:38 +0300
committerAndreas Kling <kling@serenityos.org>2022-04-01 11:27:19 +0200
commitae2ec45e789cb02db1b4e227c9c16c495a50f170 (patch)
tree9971eea7dedb0d5a4ff37b5b4078989889986adc
parent66ff60db07c67384b870d6d1aadf1d1b6729b405 (diff)
downloadserenity-ae2ec45e789cb02db1b4e227c9c16c495a50f170.zip
Kernel: Allow SysFS components to have non-zero size
This is important for dmidecode because it does an fstat on the DMI blobs, trying to figure out their size. Because we already know the size of the blobs when creating the SysFS components, there's no performance penalty whatsoever, and this allows dmidecode to not use the /dev/mem device as a fallback.
-rw-r--r--Kernel/FileSystem/SysFS.cpp2
-rw-r--r--Kernel/FileSystem/SysFSComponent.h1
-rw-r--r--Kernel/Firmware/BIOS.h5
3 files changed, 7 insertions, 1 deletions
diff --git a/Kernel/FileSystem/SysFS.cpp b/Kernel/FileSystem/SysFS.cpp
index d3ac479ffb..fe790cae68 100644
--- a/Kernel/FileSystem/SysFS.cpp
+++ b/Kernel/FileSystem/SysFS.cpp
@@ -137,7 +137,7 @@ InodeMetadata SysFSInode::metadata() const
metadata.mode = S_IFREG | m_associated_component->permissions();
metadata.uid = 0;
metadata.gid = 0;
- metadata.size = 0;
+ metadata.size = m_associated_component->size();
metadata.mtime = mepoch;
return metadata;
}
diff --git a/Kernel/FileSystem/SysFSComponent.h b/Kernel/FileSystem/SysFSComponent.h
index 179f704ea4..b7d1032e8c 100644
--- a/Kernel/FileSystem/SysFSComponent.h
+++ b/Kernel/FileSystem/SysFSComponent.h
@@ -31,6 +31,7 @@ public:
virtual RefPtr<SysFSComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
virtual mode_t permissions() const;
virtual ErrorOr<void> truncate(u64) { return EPERM; }
+ virtual size_t size() const { return 0; }
virtual ErrorOr<void> set_mtime(time_t) { return ENOTIMPL; }
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; }
virtual ErrorOr<void> refresh_data(OpenFileDescription&) const { return {}; }
diff --git a/Kernel/Firmware/BIOS.h b/Kernel/Firmware/BIOS.h
index a881b80344..0be5ad40aa 100644
--- a/Kernel/Firmware/BIOS.h
+++ b/Kernel/Firmware/BIOS.h
@@ -77,6 +77,9 @@ public:
private:
DMIEntryPointExposedBlob(PhysicalAddress dmi_entry_point, size_t blob_size);
virtual ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const override;
+
+ virtual size_t size() const override { return m_dmi_entry_point_length; }
+
PhysicalAddress m_dmi_entry_point;
size_t const m_dmi_entry_point_length { 0 };
};
@@ -90,6 +93,8 @@ private:
SMBIOSExposedTable(PhysicalAddress dmi_entry_point, size_t blob_size);
virtual ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const override;
+ virtual size_t size() const override { return m_smbios_structure_table_length; }
+
PhysicalAddress m_smbios_structure_table;
size_t const m_smbios_structure_table_length { 0 };
};