1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

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
This commit is contained in:
Valtteri Koskivuori 2020-08-06 02:04:56 +03:00 committed by Andreas Kling
parent 00a0e525e6
commit 471083ca3d

View file

@ -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 };