1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

Kernel: Have TTY subclasses cache their tty_name/pts_name.

This commit is contained in:
Andreas Kling 2019-04-16 00:35:02 +02:00
parent d384c7815f
commit 88f03f86ff
6 changed files with 9 additions and 3 deletions

View file

@ -13,6 +13,7 @@ MasterPTY::MasterPTY(unsigned index)
, m_slave(adopt(*new SlavePTY(*this, index))) , m_slave(adopt(*new SlavePTY(*this, index)))
, m_index(index) , m_index(index)
{ {
m_pts_name = String::format("/dev/pts/%u", m_index);
set_uid(current->process().uid()); set_uid(current->process().uid());
set_gid(current->process().gid()); set_gid(current->process().gid());
} }
@ -27,7 +28,7 @@ MasterPTY::~MasterPTY()
String MasterPTY::pts_name() const 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) ssize_t MasterPTY::read(Process&, byte* buffer, ssize_t size)

View file

@ -33,4 +33,5 @@ private:
unsigned m_index; unsigned m_index;
bool m_closed { false }; bool m_closed { false };
DoubleBuffer m_buffer; DoubleBuffer m_buffer;
String m_pts_name;
}; };

View file

@ -10,6 +10,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index)
, m_master(master) , m_master(master)
, m_index(index) , m_index(index)
{ {
m_tty_name = String::format("/dev/pts/%u", m_index);
set_uid(current->process().uid()); set_uid(current->process().uid());
set_gid(current->process().gid()); set_gid(current->process().gid());
DevPtsFS::the().register_slave_pty(*this); DevPtsFS::the().register_slave_pty(*this);
@ -26,7 +27,7 @@ SlavePTY::~SlavePTY()
String SlavePTY::tty_name() const 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) void SlavePTY::on_master_write(const byte* buffer, ssize_t size)

View file

@ -32,5 +32,6 @@ private:
RetainPtr<MasterPTY> m_master; RetainPtr<MasterPTY> m_master;
unsigned m_index; unsigned m_index;
InodeIdentifier m_devpts_inode_id; InodeIdentifier m_devpts_inode_id;
String m_tty_name;
}; };

View file

@ -40,6 +40,7 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents)
: TTY(4, index) : TTY(4, index)
, m_index(index) , m_index(index)
{ {
m_tty_name = String::format("/dev/tty%u", m_index);
set_size(80, 25); set_size(80, 25);
m_horizontal_tabs = static_cast<byte*>(kmalloc(columns())); m_horizontal_tabs = static_cast<byte*>(kmalloc(columns()));
for (unsigned i = 0; i < columns(); ++i) 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 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) void VirtualConsole::set_vga_start_row(word row)

View file

@ -78,4 +78,5 @@ private:
Vector<byte> m_parameters; Vector<byte> m_parameters;
Vector<byte> m_intermediates; Vector<byte> m_intermediates;
byte* m_horizontal_tabs { nullptr }; byte* m_horizontal_tabs { nullptr };
String m_tty_name;
}; };