diff options
author | Liav A <liavalb@gmail.com> | 2022-02-15 21:31:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-22 20:26:05 +0100 |
commit | 5ffe2f117c668ce011ff08635b4eba52ccacb083 (patch) | |
tree | 2cad9ad5a7ba538c26a6e722fdfaf2d892137b69 /Kernel/TTY | |
parent | e508073168ef8cf1dc0e0763ee92adfe64b9cb8d (diff) | |
download | serenity-5ffe2f117c668ce011ff08635b4eba52ccacb083.zip |
Kernel/TTY: Implement TIOCGPTN ioctl for MasterPTY
This ioctl operation will allow userspace to determine the index number
of a MasterPTY after opening /dev/ptmx and actually getting an internal
file descriptor of MasterPTY.
Diffstat (limited to 'Kernel/TTY')
-rw-r--r-- | Kernel/TTY/MasterPTY.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index cebb91529d..ce3f27f05e 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -125,9 +125,17 @@ ErrorOr<void> MasterPTY::ioctl(OpenFileDescription& description, unsigned reques TRY(Process::current().require_promise(Pledge::tty)); if (!m_slave) return EIO; - if (request == TIOCSWINSZ || request == TIOCGPGRP) + switch (request) { + case TIOCGPTN: { + int master_pty_index = index(); + return copy_to_user(static_ptr_cast<int*>(arg), &master_pty_index); + } + case TIOCSWINSZ: + case TIOCGPGRP: return m_slave->ioctl(description, request, arg); - return EINVAL; + default: + return EINVAL; + } } ErrorOr<NonnullOwnPtr<KString>> MasterPTY::pseudo_path(const OpenFileDescription&) const |