mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:25:07 +00:00
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:
parent
b46ae2bf09
commit
9dd29f9aa9
13 changed files with 75 additions and 37 deletions
|
@ -59,23 +59,13 @@ static int max(int a, int b)
|
|||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
static int open_ptm()
|
||||
{
|
||||
char buf[32];
|
||||
for (unsigned i = 0; i < 4; ++i) {
|
||||
sprintf(buf, "/dev/ptm%u", i);
|
||||
int fd = open(buf, O_RDWR);
|
||||
if (fd)
|
||||
return fd;
|
||||
}
|
||||
dbgprintf("No master PTY available :(\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
int ptm_fd = open_ptm();
|
||||
int ptm_fd = open("/dev/ptmx", O_RDWR);
|
||||
if (ptm_fd < 0) {
|
||||
perror("open(ptmx)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
make_shell(ptm_fd);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue