Commit graph

440 commits

Author SHA1 Message Date
Andreas Kling 85b886c2e0 Make it possible to build the Kernel on a macOS host.
It still requires an ELF compiler and linker, but at least it builds.
I need to get rid of the "Unix" namespace. This does a lot of that.
2018-12-02 23:34:50 +01:00
Andreas Kling 44036f32bc Move ELFLoader code into Kernel/. 2018-12-02 20:27:08 +01:00
Andreas Kling ac7a60225e Add TIOCGWINSZ ioctl so userland can determine terminal geometry.
(Don't) use this to implement short-form output in ls.
I'm too tired to make a nice column formatting algorithm.
I just wanted something concise when I type "ls".
2018-11-29 03:45:23 +01:00
Andreas Kling f5a83c4d8a Fix bug where a signal-interrupted waitpid() wouldn't return EINTR. 2018-11-28 23:30:49 +01:00
Andreas Kling 464a16afa2 Implement signal() via sigaction() and get rid of sys$signal(). 2018-11-28 22:27:32 +01:00
Andreas Kling d90104f9e0 Let reap() communicate the dead process's exit status to the caller.
This way the scheduler doesn't need to plumb the exit status into the waiter.
We still plumb the waitee pid though, I don't love it but it can be fixed.
2018-11-28 22:01:24 +01:00
Andreas Kling 938d1b8bfb Drop any old signal stacks on exec(). 2018-11-28 20:59:10 +01:00
Andreas Kling 629c5be10b Add basic zero faults.
mmap() will now map uncommitted pages that get allocated and zeroed upon the
first access. I also made /proc/PID/vm show number of "committed" bytes in
each region. This is so cool! :^)
2018-11-19 02:17:20 +01:00
Andreas Kling e88f306d07 Make /proc/PID/vm more readable.
And move the unreadable detail-heavy mess to /proc/PID/vmo.
2018-11-19 01:49:19 +01:00
Andreas Kling 526dcafd57 Some improvements to LibC malloc(). 2018-11-19 01:40:19 +01:00
Andreas Kling 85649077cd Adapt kmalloc() for userspace.
A slightly more useful malloc() for userspace. The max allocation limit
is still 128 kB, but at least now free() is able to recycle memory.
2018-11-19 00:53:02 +01:00
Andreas Kling f5a0b6961c Fix mkdir with relative paths. 2018-11-18 23:28:43 +01:00
Andreas Kling de4604ac95 Finally hook up the mkdir code to a syscall.
Added a /bin/mkdir that makes directories. How very neat :^)
There are various limitations because of missing functionality.
2018-11-18 15:02:16 +01:00
Andreas Kling 303577df16 Various stubs while trying to get an old coreutils to build. 2018-11-17 15:56:09 +01:00
Andreas Kling e440c3fa87 Support "ls <path>" rather than just "ls" :^) 2018-11-17 01:04:00 +01:00
Andreas Kling 95e0f6ad82 Fix race condition in exec().
...also hook up sys$fstat in the syscall dispatcher.
2018-11-17 00:52:29 +01:00
Andreas Kling bb9766ee17 Tweak default hostname. 2018-11-17 00:23:39 +01:00
Andreas Kling 9d05f6b7a7 Make bash-2.05b build with minimal changes.
This is really neat. :^)
2018-11-17 00:14:07 +01:00
Andreas Kling 2cf477a151 Add fcntl() F_DUPFD which is slightly different from dup2(). 2018-11-16 22:14:40 +01:00
Andreas Kling 6cedb88153 Don't unblock a blocked process when it ignores a signal. 2018-11-16 21:14:25 +01:00
Andreas Kling a788e85c09 Refactor TTY signal generation a bit.
We now respect the VINTR and VQUIT control characters in the termios.
2018-11-16 20:18:58 +01:00
Andreas Kling 4e2c2b9748 Minor TTY tweak. 2018-11-16 18:12:22 +01:00
Andreas Kling d2046e79cf Add a DoubleBuffer thingy to allow TTY read/write to be interleaved.
I feel like this concept might be useful in more places. It's very naive
right now and uses dynamically growing buffers. It should really use static
size buffers and never kmalloc().
2018-11-16 17:57:00 +01:00
Andreas Kling 52d1822c3c Add templated helpers for read/write validation, and one for strings, too. 2018-11-16 16:26:20 +01:00
Andreas Kling 8a286b9244 Improve syscall address validation a bit. 2018-11-16 16:10:59 +01:00
Andreas Kling 084287ca45 Reimplement tcsetattr/tcgetattr as ioctls. 2018-11-16 15:41:48 +01:00
Andreas Kling c99f8af66d Add ioctl() and reimplement tcsetpgrp/tcsetpgrp as ioctls. 2018-11-16 13:13:50 +01:00
Andreas Kling 2529925fe9 Some more renaming:
FileSystem -> FS
SyntheticFileSystem -> SynthFS
ProcFileSystem -> ProcFS
Ext2FileSystem -> Ext2FS
Ext2Inode -> Ext2FSInode
2018-11-15 17:13:10 +01:00
Andreas Kling eced5f11e3 Add CoreInode::reverse_lookup().
Getting the absolute path of an ext2fs inode now uses the lookup cache
which makes it a lot faster.
2018-11-15 17:04:55 +01:00
Andreas Kling 5f434bc00b Add CoreInode::lookup() for directory lookups.
Also add a name-to-inode lookup cache to Ext2Inode. This seems like a great
speedup for filesystem traversal.
2018-11-15 16:38:43 +01:00
Andreas Kling 8fa2d7104a More VFS cleanup. 2018-11-15 16:04:25 +01:00
Andreas Kling 396a32835b A pass of style/naming cleanup in VFS. 2018-11-15 15:10:30 +01:00
Andreas Kling 457a5df7d5 Rename:
VirtualFileSystem -> VFS
VirtualFileSystem::Node -> Vnode
2018-11-15 14:43:10 +01:00
Andreas Kling c735c56e4c More work on CoreInode. 2018-11-13 23:44:54 +01:00
Andreas Kling 26852a8363 Add metadata to CoreInode. 2018-11-13 13:32:16 +01:00
Andreas Kling 10c470e95f Make page_in_from_vnode 2x faster.
...by adding a new class called Ext2Inode that inherits CoreInode.
The idea is that a vnode will wrap a CoreInode rather than InodeIdentifier.
Each CoreInode subclass can keep whatever caches they like.

Right now, Ext2Inode caches the list of block indices since it can be very
expensive to retrieve.
2018-11-13 13:02:39 +01:00
Andreas Kling 97c799576a Add close-on-exec flag for file descriptors.
I was surprised to find that dup()'ed fds don't share the close-on-exec flag.
That means it has to be stored separately from the FileDescriptor object.
2018-11-13 01:36:31 +01:00
Andreas Kling 19b9401487 Reduce kmalloc() traffic in directory iteration.
Pass the file name in a stack-allocated buffer instead of using an AK::String
when iterating directories. This dramatically reduces the amount of cycles
spent traversing the filesystem.
2018-11-13 00:17:30 +01:00
Andreas Kling 5e8e554f94 Add a braindead 10x speedup to kmalloc().
Skip over entirely full buckets when scanning for a big-enough memory slot.
This means I can postpone writing a better kmalloc() for a while longer! :^)
2018-11-12 15:29:46 +01:00
Andreas Kling dea474dfd5 Make loading /bin/bash ~250x faster.
The ELF loader was doing huge amounts of unnecessary work.
Got rid of the "export symbols" and relocation passes since we don't need them.
They were useful things when bringing up the ELF loading code.

Also added a simple TSC-based Stopwatch RAII thingy to help debug performance issues.
2018-11-12 13:45:15 +01:00
Andreas Kling 1cf20a2fe2 Some minor termios debugging output. 2018-11-12 12:27:28 +01:00
Andreas Kling f1404aa948 Add primitive FIFO and hook it up to sys$pipe().
It's now possible to do this in bash:

cat kernel.map | fgrep List

This is very cool! :^)
2018-11-12 01:28:46 +01:00
Andreas Kling 18e3ddf605 Add a naive /bin/fgrep for testing pipes. 2018-11-11 20:42:41 +01:00
Andreas Kling d5d45d1088 Rage hacking to get bash to run. It finally runs. So cool! :^) 2018-11-11 15:38:07 +01:00
Andreas Kling 9b70808ab5 Add really cheap atol() since sizeof(int) == sizeof(long) here anyway. 2018-11-11 10:40:50 +01:00
Andreas Kling f394e3486a Stub out a bunch more functions to get closer to that sweet bash build. 2018-11-11 10:38:33 +01:00
Andreas Kling e48182d91b Add setvbuf(), setlinebuf(), setbuf(). 2018-11-11 10:11:09 +01:00
Andreas Kling 7cc4caee4f Add ispunct() to LibC + some minor cleanups. 2018-11-11 00:44:04 +01:00
Andreas Kling 3b2f172d48 A bunch of compat work (mostly stubs but some real implementations, too.)
Another pass at getting bash-1.14.7 to build. Not that many symbols remain.
2018-11-11 00:20:53 +01:00
Andreas Kling 6a0a2c9ab4 Some improvements to signals.
- Add sigprocmask() and sigpending().
- Forked children inherit signal dispositions and masks.
- Exec clears signal dispositions and masks.
2018-11-10 23:30:41 +01:00