Add a PTY multiplexer (/dev/ptmx) device.

When you open /dev/ptmx, you get a file descriptor pointing to one of the
available MasterPTY's. If none are available, you get an EBUSY.

This makes it possible to open multiple (up to 4) Terminals. :^)

To support this, I also added a CharacterDevice::open() that gets control
when VFS is opening a CharacterDevice. This is useful when we want to return
a custom FileDescriptor like we do here.
This commit is contained in:
Andreas Kling 2019-01-16 13:36:10 +01:00
commit 9dd29f9aa9
Notes: sideshowbarker 2024-07-19 16:01:34 +09:00
13 changed files with 75 additions and 37 deletions

View file

@ -617,9 +617,10 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
} else {
m_fds.resize(m_max_open_file_descriptors);
if (tty) {
m_fds[0].set(tty->open(O_RDONLY));
m_fds[1].set(tty->open(O_WRONLY));
m_fds[2].set(tty->open(O_WRONLY));
int error;
m_fds[0].set(tty->open(error, O_RDONLY));
m_fds[1].set(tty->open(error, O_WRONLY));
m_fds[2].set(tty->open(error, O_WRONLY));
}
}