Commit Graph

80 Commits

Author SHA1 Message Date
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
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
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
36b3dc6c32 Add /proc/PID/cwd, a symlink to the process's current directory. 2018-11-10 18:16:21 +01:00
Andreas Kling
8605711f4b Make /bin/clear work again.
After I made stdio buffered, we were dropping anything unflushed on exit.
Since /bin/clear just prints out some escape sequences without a newline,
the entire buffer was being discarded.

Also add VirtualConsole::clear() that handles clearing of background VC's.
2018-11-10 00:56:10 +01:00
Andreas Kling
4914f3b837 Build LibC and Userland with clang as well. 2018-11-09 14:29:00 +01:00
Andreas Kling
7b3b5f745f Move <utsname.h> to <sys/utsname.h> for correctness. 2018-11-09 10:24:41 +01:00
Andreas Kling
8249c086c3 Get rid of redundant sys$spawn now that we have fork+exec. 2018-11-09 10:22:27 +01:00
Andreas Kling
3e0a0dd7ed Fix all current build warnings in the userland. 2018-11-09 10:19:33 +01:00
Andreas Kling
3b2dcd5929 Add a VMO pointer to VNode.
This way, if anyone tries to map an already mapped file, we share the VMO.
2018-11-08 15:39:26 +01:00
Andreas Kling
3c8064a787 Support basic mmap'ing of a file!
All right, we can now mmap() a file and it gets magically paged in from fs
in response to an NP page fault. This is really cool :^)

I need to refactor this to support sharing of read-only file-backed pages,
but it's cool to just have something working.
2018-11-08 12:59:16 +01:00
Andreas Kling
41a751c90c Minor tweak to /bin/kill. 2018-11-08 02:07:08 +01:00
Andreas Kling
da3857b0c2 Add some simple write buffering to LibC's stdio.
Plumb it all the way to the VirtualConsole. Also fix /bin/cat to write()
the whole chunks we get from read() directly to stdout.
2018-11-08 01:23:47 +01:00
Andreas Kling
1dbc340da8 Get rid of the undertaker and have waitpid() be the reaper.
For dead orphans, the scheduler calls reap().
2018-11-07 23:59:49 +01:00
Andreas Kling
03a8357e84 Implement sending signals to blocked-in-kernel processes.
This is dirty but pretty cool! If we have a pending, unmasked signal for
a process that's blocked inside the kernel, we set up alternate stacks
for that process and unblock it to execute the signal handler.

A slightly different return trampoline is used here: since we need to
get back into the kernel, a dedicated syscall is used (sys$sigreturn.)

This restores the TSS contents of the process to the state it was in
while we were originally blocking in the kernel.

NOTE: There's currently only one "kernel resume TSS" so signal nesting
definitely won't work.
2018-11-07 21:19:47 +01:00
Andreas Kling
c8b308910e Signals to processes in userspace now work again.
Ugh, how am I going to dispatch signals to processes in the kernel?
2018-11-07 19:03:44 +01:00
Andreas Kling
678882e020 Rework process states to make a bit more sense.
Processes are either alive (with many substates), dead or forgiven.
A dead process is forgiven when the parent waitpid()s on it.
Dead orphans are also forgiven.

There's a lot of work to be done around this.
2018-11-07 18:34:37 +01:00
Andreas Kling
a7f1d892a9 Add some basic setgroups(), getgroups() and initgroups().
Also teach /bin/id to print the user's supplemental groups.
2018-11-07 01:38:51 +01:00
Andreas Kling
90bab5ea71 Add getgrent() family of functions. 2018-11-06 22:27:51 +01:00
Andreas Kling
7c3746592b Add strsignal() and improve sharing signal numbers between LibC and kernel. 2018-11-06 15:45:16 +01:00
Andreas Kling
153ea704af Add some basic signal support.
It only works for sending a signal to a process that's in userspace code.

We implement reception by synthesizing a PUSHA+PUSHF in the receiving process
(operating on values in the TSS.)
The TSS CS:EIP is then rerouted to the signal handler and a tiny return
trampoline is constructed in a dedicated region in the receiving process.

Also hacked up /bin/kill to be able to send arbitrary signals (kill -N PID)
2018-11-06 10:56:41 +01:00
Andreas Kling
72cdc62155 Replace zones with individually tracked physical pages.
It's just a simple struct { ref_count, paddr }.
This will allow me to implement lazy zeroing and COW pages.
2018-11-05 10:23:00 +01:00
Andreas Kling
da13c9a264 Map pages in read-only ELF sections as non-writable.
This is so cool! :^) Now you'll crash if you try to write into your
.text or .rodata segments.
2018-11-03 11:36:45 +01:00
Andreas Kling
20fb1fc377 Fix some bugs in execve() and make sh use it for process launching.
Interrupting children of sh now always works with ^C :^)
2018-11-03 02:08:06 +01:00
Andreas Kling
202bdb553c Implemented sys$execve().
It's really crufty, but it basically works!
2018-11-03 01:51:42 +01:00
Andreas Kling
8accc92c3c Implement fork()!
This is quite cool! The syscall entry point plumbs the register dump
down to sys$fork(), which uses it to set up the child process's TSS
in order to resume execution right after the int 0x80 fork() call. :^)

This works pretty well, although there is some problem with the kernel
alias mappings used to clone the parent process's regions. If I disable
the MM::release_page_directory() code, there's no problem. Probably there's
a premature freeing of a physical page somehow.
2018-11-02 20:41:58 +01:00
Andreas Kling
10b666f69a Basic ^C interrupt implementation.
For testing, I made cat put itself into a new process group.
This should eventually be done by sh between fork() and exec().
2018-11-02 14:06:48 +01:00
Andreas Kling
621217ffeb Add tcsetpgrp()+tcgetpgrp().
One more step on the path to being able to ^C a runaway process. :^)
2018-11-02 13:14:25 +01:00
Andreas Kling
d8f0dd6f3b Start working on sessions and process groups. 2018-11-02 12:56:51 +01:00
Andreas Kling
90ddbca127 Free physical pages allocated for a process's page directory on exit.
Also use a ProcessPagingScope instead of region aliasing to implement
create-process ELF loading.
2018-11-01 23:08:10 +01:00
Andreas Kling
cddd2f37e9 Have sh print out which signal terminated a child process. 2018-11-01 01:11:00 +01:00
Andreas Kling
c7d5ce6b5a Add a /bin/tty command that prints the current tty.
Also fix ttyname() syscall to include "/dev/" in the name.
2018-10-31 21:46:05 +01:00
Andreas Kling
8f6998c902 Add SpinLock to IDE disk access.
This forces serialization of accesses. This driver needs to be redesigned.
2018-10-31 21:33:27 +01:00
Andreas Kling
9886b27d9c Add getpwent() family of functions to LibC.
Also add a little /etc/passwd database. There's just me in there.
2018-10-31 19:54:25 +01:00
Andreas Kling
71c9b09e8c Fix ls build. 2018-10-31 15:52:24 +01:00
Andreas Kling
bb90c8ecab A bunch of LibC boilerplate stuff added while trying to get figlet to build. 2018-10-31 02:09:11 +01:00
Andreas Kling
511ed4c4de Snazz up the sh prompt a bit. Add the current tty to it. 2018-10-31 01:21:56 +01:00
Andreas Kling
3218f00099 Implement basic sys$kill() and add a /bin/kill
All it can do right now is send SIGKILL which just murders the target task.
2018-10-31 01:06:57 +01:00
Andreas Kling
00c21d1590 Add sys$ttyname_r and ttyname_r() + ttyname().
And print a greeting when sh starts up so we know which TTY we're on.
2018-10-30 22:03:02 +01:00
Andreas Kling
7a85384e47 sh should read from fd 0 (stdin) instead of /dev/keyboard. 2018-10-30 16:17:34 +01:00
Andreas Kling
7a7956a595 Virtual consoles kinda work!
We now make three VirtualConsoles at boot: tty0, tty1, and tty2.
We launch an instance of /bin/sh in each one.
You switch between them with Alt+1/2/3

How very very cool :^)
2018-10-30 15:33:37 +01:00
Andreas Kling
0f20be05a6 Implement sys$getcwd properly.
Also fixed broken strcpy that didn't copy the null terminator.
2018-10-30 00:06:31 +01:00
Andreas Kling
e6284a8774 Fix broken SpinLock.
The SpinLock was all backwards and didn't actually work. Fixing it exposed
how wrong most of the locking here is.

I need to come up with a better granularity here.
2018-10-29 22:04:26 +01:00
Andreas Kling
97726862dd Add basic symlink support.
- sys$readlink + readlink()
- Add a /proc/PID/exe symlink to the process's executable.
- Print symlink contents in ls output.
- Some work on plumbing options into VFS::open().
2018-10-28 14:11:51 +01:00
Andreas Kling
c76dc9a047 Add /proc/mm and a /bin/mm utility that just dumps it.
This shows some info about the MM. Right now it's just the zone count
and the number of free physical pages. Lots more can be added.

Also added "exit" to sh so we can nest shells and exit from them.

I also noticed that we were leaking all the physical pages, so fixed that.
2018-10-28 10:28:21 +01:00
Andreas Kling
e904f193c1 Canonicalize the path used by sh.
With a bunch of LibC work to support the feature. LibC now initializes
AK::StringImpl by default. It's now fine to use AK in LibC/Userland! :^)
2018-10-28 09:36:21 +01:00
Andreas Kling
43475f248b Add save/unsave cursor escape sequences.
Also added a little terminal test program called /bin/tst.
2018-10-28 01:44:53 +02:00