summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorValtteri Koskivuori <vkoskiv@gmail.com>2020-08-06 02:04:56 +0300
committerAndreas Kling <kling@serenityos.org>2020-08-06 17:45:06 +0200
commit471083ca3dd73bdcf176e9b9c8983c534cdeb154 (patch)
treefdb100548cf73c2aa1dc97ab6f9bd9468836b00a /Kernel
parent00a0e525e689e105fa6d1210198d3c947951bf6c (diff)
downloadserenity-471083ca3dd73bdcf176e9b9c8983c534cdeb154.zip
ProcFS: Expose the current kernel keymap as /proc/keymap
Programs can now ask the kernel which keymap is in use by reading from /proc/keymap
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/FileSystem/ProcFS.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 33fda8a8c8..3fea02b45c 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -33,6 +33,7 @@
#include <Kernel/CommandLine.h>
#include <Kernel/Console.h>
#include <Kernel/Devices/BlockDevice.h>
+#include <Kernel/Devices/KeyboardDevice.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileBackedFileSystem.h>
#include <Kernel/FileSystem/FileDescription.h>
@@ -85,6 +86,7 @@ enum ProcFileType {
FI_Root_inodes,
FI_Root_dmesg,
FI_Root_interrupts,
+ FI_Root_keymap,
FI_Root_pci,
FI_Root_devices,
FI_Root_uptime,
@@ -372,6 +374,15 @@ Optional<KBuffer> procfs$interrupts(InodeIdentifier)
return builder.build();
}
+Optional<KBuffer> procfs$keymap(InodeIdentifier)
+{
+ KBufferBuilder builder;
+ JsonObjectSerializer<KBufferBuilder> json { builder };
+ json.add("keymap", KeyboardDevice::the().keymap_name());
+ json.finish();
+ return builder.build();
+}
+
Optional<KBuffer> procfs$devices(InodeIdentifier)
{
KBufferBuilder builder;
@@ -1572,6 +1583,7 @@ ProcFS::ProcFS()
m_entries[FI_Root_self] = { "self", FI_Root_self, false, procfs$self };
m_entries[FI_Root_pci] = { "pci", FI_Root_pci, false, procfs$pci };
m_entries[FI_Root_interrupts] = { "interrupts", FI_Root_interrupts, false, procfs$interrupts };
+ m_entries[FI_Root_keymap] = { "keymap", FI_Root_keymap, false, procfs$keymap };
m_entries[FI_Root_devices] = { "devices", FI_Root_devices, false, procfs$devices };
m_entries[FI_Root_uptime] = { "uptime", FI_Root_uptime, false, procfs$uptime };
m_entries[FI_Root_cmdline] = { "cmdline", FI_Root_cmdline, true, procfs$cmdline };