Commit graph

19 commits

Author SHA1 Message Date
Andreas Kling 9fca94269e Kernel: Move TTY-related files into Kernel/TTY/. 2019-04-03 12:28:45 +02:00
Andreas Kling f9864940eb Kernel: Move FS-related files into Kernel/FileSystem/ 2019-04-03 12:25:24 +02:00
Andreas Kling 44e1e7423f Kernel: Put a bunch of debug spam behind #ifdefs. 2019-03-27 15:07:12 +01:00
Andreas Kling 60d25f0f4a Kernel: Introduce threads, and refactor everything in support of it.
The scheduler now operates on threads, rather than on processes.
Each process has a main thread, and can have any number of additional
threads. The process exits when the main thread exits.

This patch doesn't actually spawn any additional threads, it merely
does all the plumbing needed to make it possible. :^)
2019-03-23 22:03:17 +01:00
Andreas Kling beda478821 Kernel: Make syscalls that take a buffer size use ssize_t instead of size_t.
Dealing with the unsigned overflow propagation here just seems unreasonably
error prone. Let's limit ourselves to 2GB buffer sizes instead.
2019-02-25 21:21:12 +01:00
Andreas Kling b6bf26430d Kernel: Have devices automagically register themselves with the VFS. 2019-02-17 10:38:07 +01:00
Andreas Kling 994279d56c Kernel: Add Device base class for CharacterDevice.
..to prepare for adding a BlockDevice class.
2019-02-16 00:47:20 +01:00
Andreas Kling 0669ef8977 Kernel: Writing to a slave PTY should yield EIO if the master is closed. 2019-02-05 13:09:01 +01:00
Andreas Kling 378e20c535 Kernel: Reading from a slave PTY should give EOF if master PTY is closed. 2019-02-05 12:27:32 +01:00
Andreas Kling 34e745b0b4 Add uid and gid to CharacterDevices.
The vast majority of them will be owned by 0:0 (the default.)
However, PTY pairs will now be owned by the uid:gid of the opening process.
2019-01-31 05:55:30 +01:00
Andreas Kling 2b4374d08e Let the slave PTY keep the master PTY alive.
This ownership model is a bit confusing. There's a retain cycle between
MasterPTY and SlavePTY, but it's broken when the SlavePTY is closed, meaning
that there are no more FileDescriptors referring to it.
2019-01-30 19:05:59 +01:00
Andreas Kling b4e478aa50 Deallocate PTY's when they close.
This required a fair bit of plumbing. The CharacterDevice::close() virtual
will now be closed by ~FileDescriptor(), allowing device implementations to
do custom cleanup at that point.

One big problem remains: if the master PTY is closed before the slave PTY,
we go into crashy land.
2019-01-30 18:47:18 +01:00
Andreas Kling 027d26cd5d Add a String::format() and use that in place of ksprintf() in the Kernel.
You're never gonna be right 100% of the time when guessing how much buffer
space you need. This avoids having to make that type of decision in a bunch
of cases. :^)
2019-01-30 16:28:51 +01:00
Andreas Kling e9b948103d Add a /dev/pts filesystem and make PTY allocation dynamic.
You can now open as many PTY pairs as you like. Well, it's actually capped
at 8 for now, but it's just a constant and trivial to change.

Unregistering a PTY pair is untested because I didn't want to start
mucking with that in Terminal right now.
2019-01-30 00:49:20 +01:00
Andreas Kling b896d4b237 PTY: Disallow infinite writing to slaves.
This way we don't buffer ungodly amounts of output in the kernel when doing
e.g "cat /dev/random" on a PTY.
2019-01-25 00:13:54 +01:00
Andreas Kling 310a5f4199 Let each MasterPTY create its slave. 2019-01-16 02:11:50 +01:00
Andreas Kling e452303c66 Allow character devices to block write attempts until there is more space. 2019-01-15 09:17:22 +01:00
Andreas Kling 49b63281a0 Make it possible for a process to switch controlling terminals.
Via the TIOCSCTTY and TIOCNOTTY ioctls.
2019-01-15 08:49:24 +01:00
Andreas Kling 2f74c2f430 Add basic PTY support.
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
2019-01-15 06:30:19 +01:00