Commit Graph

61 Commits

Author SHA1 Message Date
Andreas Kling
31871557e4 LibC: Add ftruncate() stub. 2019-03-24 00:53:39 +01:00
Andreas Kling
e561ab1b0b Kernel+LibC: Add a simple create_thread() syscall.
It takes two parameters, a function pointer for the entry function,
and a void* argument to be passed to that function on the new thread.
2019-03-23 22:59:08 +01:00
Andreas Kling
2c3cf22bc9 LibC: A whole bunch of compat work towards porting Lynx. 2019-03-14 15:18:15 +01:00
Andreas Kling
8175d75432 LibC: Implement getlogin(). 2019-03-10 03:15:36 +01:00
Andreas Kling
eda0866992 Add a C++ helper class for working with shared buffers.
This is a bit more comfortable than passing the shared buffer ID manually
everywhere and keeping track of size etc.
2019-03-08 12:24:05 +01:00
Andreas Kling
2c5a378ccc Kernel+Userland: Add symlink() syscall and add "-s" flag to /bin/ln.
It's now possible to create symbolic links! :^)

This exposed an issue in Ext2FS where we'd write uninitialized data past
the end of an inode's content. Fix this by zeroing out the tail end of
the last block in a file.
2019-03-02 01:52:24 +01:00
Andreas Kling
1d2529b4a1 Add chown() syscall and a simple /bin/chown program. 2019-02-27 12:32:53 +01:00
Andreas Kling
cccc8d8aeb More compat work.
Move syscall to int 0x82 since using int 0x80 was kinda prone to fork bombs
when building things on Linux. :^)
2019-02-26 12:57:02 +01:00
Andreas Kling
901b7d5d91 Fix a bunch of compiler warnings. Not all, but a lot. 2019-02-25 19:05:51 +01:00
Andreas Kling
a7a456002e LibC: Enough compat work to make binutils-2.32 build and run. 2019-02-23 17:24:50 +01:00
Andreas Kling
7d288aafb2 Kernel: Add link() syscall to create hard links.
This accidentally grew into a little bit of VFS cleanup as well.

Also add a simple /bin/ln implementation to exercise it.
2019-02-21 13:26:40 +01:00
Andreas Kling
640360e958 Move WindowServer to userspace.
This is a monster patch that required changing a whole bunch of things.
There are performance and stability issues all over the place, but it works.
Pretty cool, I have to admit :^)
2019-02-17 00:13:47 +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
2ac697ca09 LibC: execl() forgot to add the null sentinel to argv. 2019-02-08 00:12:35 +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
c30e2c8d44 Implement basic chmod() syscall and /bin/chmod helper.
Only raw octal modes are supported right now.
This patch also changes mode_t from 32-bit to 16-bit to match the on-disk
type used by Ext2FS.

I also ran into EPERM being errno=0 which was confusing, so I inserted an
ESUCCESS in its place.
2019-01-29 04:55:08 +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
bda0c935c2 Add unlink() syscall and /bin/rm.
This patch adds most of the plumbing for working file deletion in Ext2FS.
Directory entries are removed and inode link counts updated.
We don't yet update the inode or block bitmaps, I will do that separately.
2019-01-22 07:03:44 +01:00
Andreas Kling
f70136a324 Kernel: Support open() with O_CREAT.
It's now possible to create zero-length files! :^)
Also hook up the new functionality in /bin/touch.
2019-01-22 00:58:56 +01:00
Andreas Kling
3a0a8848fb Make syscall invocations look pleasant.
Old: Syscall::invoke(Syscall::SC_foo, (dword)arg1, (dword)arg2)
New: syscall(SC_foo, arg1, arg2)
2018-12-21 03:02:06 +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
c99f8af66d Add ioctl() and reimplement tcsetpgrp/tcsetpgrp as ioctls. 2018-11-16 13:13:50 +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
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
0b3e927597 Oops, waitpid() was not passing the options parameter to the kernel. 2018-11-07 10:46:48 +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
77fe8e8363 Add getppid(). 2018-11-06 13:33:57 +01:00
Andreas Kling
3024167cbd Change syscall naming scheme. 2018-11-06 13:33:54 +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
82f84bab11 More random compat hacking towards getting bash to build.
I'm now at the build stage where it complains about a bajillion missing
symbols. This is a good place to be!
2018-11-05 18:21:42 +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
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
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
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
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