diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-16 00:35:02 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-16 00:35:02 +0200 |
commit | 88f03f86ff4659c9cabd484b1ee37bd044681a26 (patch) | |
tree | 13414d68a155089ea048eab9dc10ce5b1cc0254a | |
parent | d384c7815f92d9bd411033f0bc1d92250568b1c4 (diff) | |
download | serenity-88f03f86ff4659c9cabd484b1ee37bd044681a26.zip |
Kernel: Have TTY subclasses cache their tty_name/pts_name.
-rw-r--r-- | Kernel/TTY/MasterPTY.cpp | 3 | ||||
-rw-r--r-- | Kernel/TTY/MasterPTY.h | 1 | ||||
-rw-r--r-- | Kernel/TTY/SlavePTY.cpp | 3 | ||||
-rw-r--r-- | Kernel/TTY/SlavePTY.h | 1 | ||||
-rw-r--r-- | Kernel/TTY/VirtualConsole.cpp | 3 | ||||
-rw-r--r-- | Kernel/TTY/VirtualConsole.h | 1 |
6 files changed, 9 insertions, 3 deletions
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index 9c643183fb..6c9fd6a6ef 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -13,6 +13,7 @@ MasterPTY::MasterPTY(unsigned index) , m_slave(adopt(*new SlavePTY(*this, index))) , m_index(index) { + m_pts_name = String::format("/dev/pts/%u", m_index); set_uid(current->process().uid()); set_gid(current->process().gid()); } @@ -27,7 +28,7 @@ MasterPTY::~MasterPTY() String MasterPTY::pts_name() const { - return String::format("/dev/pts/%u", m_index); + return m_pts_name; } ssize_t MasterPTY::read(Process&, byte* buffer, ssize_t size) diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h index fa65522dea..c98dd625f9 100644 --- a/Kernel/TTY/MasterPTY.h +++ b/Kernel/TTY/MasterPTY.h @@ -33,4 +33,5 @@ private: unsigned m_index; bool m_closed { false }; DoubleBuffer m_buffer; + String m_pts_name; }; diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index 96f07e151f..4725f815a3 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -10,6 +10,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index) , m_master(master) , m_index(index) { + m_tty_name = String::format("/dev/pts/%u", m_index); set_uid(current->process().uid()); set_gid(current->process().gid()); DevPtsFS::the().register_slave_pty(*this); @@ -26,7 +27,7 @@ SlavePTY::~SlavePTY() String SlavePTY::tty_name() const { - return String::format("/dev/pts/%u", m_index); + return m_tty_name; } void SlavePTY::on_master_write(const byte* buffer, ssize_t size) diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index 95c17b62a1..36ec094ce6 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -32,5 +32,6 @@ private: RetainPtr<MasterPTY> m_master; unsigned m_index; InodeIdentifier m_devpts_inode_id; + String m_tty_name; }; diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index 96d8eee7ce..995f9b2720 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -40,6 +40,7 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents) : TTY(4, index) , m_index(index) { + m_tty_name = String::format("/dev/tty%u", m_index); set_size(80, 25); m_horizontal_tabs = static_cast<byte*>(kmalloc(columns())); for (unsigned i = 0; i < columns(); ++i) @@ -508,7 +509,7 @@ ssize_t VirtualConsole::on_tty_write(const byte* data, ssize_t size) String VirtualConsole::tty_name() const { - return String::format("/dev/tty%u", m_index); + return m_tty_name; } void VirtualConsole::set_vga_start_row(word row) diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index cafd7fbc3c..eb0c11b3fe 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -78,4 +78,5 @@ private: Vector<byte> m_parameters; Vector<byte> m_intermediates; byte* m_horizontal_tabs { nullptr }; + String m_tty_name; }; |