Commit Graph

44 Commits

Author SHA1 Message Date
Andreas Kling
920e8e58ed Kernel+Userland: Implement setuid() and setgid() and add /bin/su
Also show setuid and setgid bits in "ls -l" output. :^)
2019-02-21 23:38:10 +01:00
Andreas Kling
4ea28bf0a5 Kernel: Add a simple shared memory API for two processes only.
And use this to implement shared bitmaps between WindowServer and clients.
2019-02-16 12:13:43 +01:00
Andreas Kling
736e852525 LibC: Implement enough missing stuff to get bash-5.0 running. :^) 2019-02-08 02:38:21 +01:00
Andreas Kling
dddd0e7b03 Get nyancat nyanning in Serenity.
I found a cute program that renders an animated nyancat in the terminal.
This patch adds enough hackery to get it working correctly. :^)
2019-02-03 16:11:28 +01:00
Andreas Kling
c2adfd0e2d LibC: Implement various things to get GNU bc building and running.
Looks like that's all we needed, and bc now runs. :^)
2019-02-03 04:32:31 +01:00
Andreas Kling
c95228b128 Add support for removing directories.
It's really only supported in Ext2FS since SynthFS doesn't really want you
mucking around with its files. This is pretty neat though :^)

I ran into some trouble with HashMap while working on this but opted to work
around it and leave that for a separate investigation.
2019-01-28 04:16:01 +01:00
Andreas Kling
267a903dd0 Terminal: Redraw entire line if any of its characters are dirty.
This means we only have to do one fill_rect() per line and the whole process
ends up being ~10% faster than before.

Also added a read_tsc() syscall to give userspace access to the TSC.
2019-01-25 02:09:29 +01:00
Andreas Kling
8d36c8f0d8 LibC: Tweak execvp() and execve() prototypes. 2019-01-23 17:09:00 +01:00
Andreas Kling
69a3aecf6b LibC: Add vsnprintf(), snprintf(), execvp() and abs(). 2019-01-23 06:35:34 +01:00
Andreas Kling
ed7ae6c02c Add sync() syscall and a /bin/sync.
It walks all the live Inode objects and flushes pending metadata changes
wherever needed.

This could be optimized by keeping a separate list of dirty Inodes,
but let's not get ahead of ourselves.
2018-12-20 00:39:29 +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
9d05f6b7a7 Make bash-2.05b build with minimal changes.
This is really neat. :^)
2018-11-17 00:14:07 +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
e48182d91b Add setvbuf(), setlinebuf(), setbuf(). 2018-11-11 10:11:09 +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
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
e5e0bffd76 Add getwd(). 2018-11-06 15:59:57 +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
9f2b9c82bf More work towards getting bash to build.
Implemented some syscalls: dup(), dup2(), getdtablesize().
FileHandle is now a retainable, since that's needed for dup()'ed fd's.
I didn't really test any of this beyond a basic smoke check.
2018-11-05 19:01:59 +01:00
Andreas Kling
e76312ab63 Lots of minor compat stuff while seeing if bash would build.
We're quite far from bash building, but we'll get there eventually!
2018-11-05 16:40:48 +01:00
Andreas Kling
e4611248c4 Add geteuid() and getegid().
There's no support for set-uid or set-gid executables yet so these don't
actually do anything. It's just nice to get the boilerplate stuff in.
2018-11-05 15:05:27 +01:00
Andreas Kling
8039a20611 Tiny LibC things. 2018-11-05 14:54:11 +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
a685809e75 Waiters should be notified when a waitee is killed.
Ran into a horrendous bug where VirtualConsole would overrun its buffer
and scribble right into some other object if we were interrupted while
processing a character. Slapped an InterruptDisabler onto onChar for now.

This provokes an interesting question though.. if a process is killed
while its in kernel space, how the heck do we release any locks it held?
I'm sure there are many different solutions to this problem, but I'll
have to think about it.
2018-11-01 01:05:59 +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
819ce91395 Enough compatibility work to make figlet build and run!
I ran out of steam writing library routines and imported two
BSD-licensed libc routines: sscanf() and getopt().

I will most likely rewrite them sooner or later. For now
I just wanted to see figlet running.
2018-10-31 17:52:59 +01:00
Andreas Kling
9160fd0d47 More LibC portability work while trying to get figlet building. 2018-10-31 10:14:56 +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
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
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
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
ec07761d0f Implement waitpid() support for getting the waitee's exit code. 2018-10-27 01:24:22 +02:00
Andreas Kling
2749e7f1c2 Implement sys$chdir() and teach sh+ls to cd around and browse different dirs. 2018-10-26 14:24:11 +02:00
Andreas Kling
53abfa7ea1 Add sys$gethostname and /bin/hostname 2018-10-26 09:54:29 +02:00
Andreas Kling
5978185242 Add a "sleep" syscall that sleeps for N seconds. 2018-10-25 13:56:03 +02:00
Andreas Kling
ec1d16b307 Add a "pwd" utility to userland.
It's implemented as a separate process. How cute is that.
Tasks now have a current working directory. Spawned tasks inherit their
parent task's working directory.
Currently everyone just uses "/" as there's no way to chdir().
2018-10-24 14:28:22 +02:00
Andreas Kling
5f36a5f22e Add an lstat() syscall and use it to make "ls" nicer. 2018-10-24 13:19:36 +02:00
Andreas Kling
3253a23b91 Add a simplified waitpid() so that sh can wait on spawned commands. 2018-10-24 00:20:34 +02:00
Andreas Kling
fe237ee215 Lots of hacking:
- Turn Keyboard into a CharacterDevice (85,1) at /dev/keyboard.
- Implement MM::unmapRegionsForTask() and MM::unmapRegion()
- Save SS correctly on interrupt.
- Add a simple Spawn syscall for launching another process.
- Move a bunch of IO syscall debug output behind DEBUG_IO.
- Have ASSERT do a "cli" immediately when failing.
  This makes the output look proper every time.
- Implement a bunch of syscalls in LibC.
- Add a simple shell ("sh"). All it can do now is read a line
  of text from /dev/keyboard and then try launching the specified
  executable by calling spawn().

There are definitely bugs in here, but we're moving on forward.
2018-10-23 10:12:50 +02:00
Andreas Kling
4cbf079a17 Start work on a standard C library. I'm calling it... LibC. 2018-10-22 13:57:25 +02:00