Commit Graph

195 Commits

Author SHA1 Message Date
50cda50f01 Kernel, libc: Add F_GETFD, F_SETFD and FD_CLOEXEC 2022-10-27 17:17:24 +02:00
fcf53ef6a5 Kernel: Make waitpid() block by default unless WNOHANG is specified 2022-10-27 17:05:42 +02:00
1c35eabb2b open(): Add a third optional mode argument 2022-10-27 07:52:57 +02:00
7d20c507b1 Kernel, libc, userspace: Implement command-line arguments (argv)
The only thing missing now is for sh to pass them on.
2022-10-26 18:57:06 +02:00
af452e2b2a Kernel, libc: Add dup2() 2022-10-25 18:58:06 +02:00
af46b8d9ac Kernel: Cleanup file descriptor validation 2022-10-25 18:35:17 +02:00
ec2c314234 Kernel: Add /dev/null 2022-10-25 17:59:55 +02:00
0dec5f7bad libc: Add dummy getcwd() 2022-10-24 17:05:28 +02:00
58b01b74e2 Kernel, libc: Add stat() 2022-10-23 18:35:32 +02:00
8bf2904d74 libc: Implement a basic subset of dirent.h 2022-10-23 14:41:45 +02:00
14367f07b5 Kernel: Add support for getdents() to DeviceFS 2022-10-23 14:05:55 +02:00
78d72c2f0c Kernel, libc: Add a getdents() system call
This is meant to be a low-level interface to implement dirent.h on top of.
2022-10-23 14:03:46 +02:00
cf94ca2a4e Kernel: Update libk's string.h 2022-10-22 19:06:06 +02:00
bcdcfc4b45 Kernel: Add a pstat() system call
Not part of C or POSIX, but since there is no procfs right now, I thought it would be nice to have an interface to query process information.
It works like this: you pass the process ID and a pointer to a struct pstat (can be null).
If the process ID is -1, the kernel picks the process with the highest PID.
Then, if the pointer to a pstat struct is not null, the kernel fills it in with the process's information, and returns the process's PID.
2022-10-22 14:26:29 +02:00
0faabe02e5 Kernel, libc: Implement O_CLOEXEC 2022-10-22 10:28:02 +02:00
b2f5a0502f Kernel, libc: Implement O_NONBLOCK 2022-10-21 21:51:03 +02:00
da61e3648f Kernel: Implement blocking reads
This is a huge step forward!! bc actually runs now, without echo or backspace, but it runs!!
2022-10-21 21:26:19 +02:00
bef9158450 Kernel, libc: Add isatty() and F_ISTTY to fcntl() 2022-10-21 18:34:31 +02:00
93207820b3 libc: Add a few errors to errno.h
As well as ino_t, which I forgot in the fstat() commit :)
2022-10-21 18:34:01 +02:00
fcf191aa7a Kernel, libc: Add fstat() 2022-10-21 18:31:09 +02:00
f7cf395f71 Kernel, libc: Add access() 2022-10-20 19:03:24 +02:00
27448611b3 UserMemory: do not map refs into kernel memory
This is bad design. But it fails if mapped, since something overwrites KernelHeap.
2022-10-20 18:50:07 +02:00
712f4f5e51 KernelHeap: Add more debug logging 2022-10-20 18:49:33 +02:00
47bdfecedb Devices: Add /dev/uptime
This file contains how many milliseconds have passed since boot at the time of reading it :)
2022-10-19 21:11:12 +02:00
3c5c92c7c3 sh: Add a simple interactive shell 2022-10-19 19:42:05 +02:00
b035795eb3 Kernel: Move errno.h and (k)assert.h out of the main include directory
This is mostly so IDEs don't pick them up instead of the userspace headers :)
2022-10-19 17:41:23 +02:00
48d4a5910a Kernel: Add a few convenience functions to manipulate userland memory 2022-10-19 17:13:16 +02:00
671f2a2de3 Kernel, libc: Implement waitpid()
FIXME: exec() is now doing weird page table stuff. But at least it works, no panics :)
2022-10-18 21:30:52 +02:00
52d391507d Kernel: Rename the getpid() syscall to getprocid()
Now, we have one single system call to fetch all sorts of identifiers:
PID, PPID, UID, GID; EUID, EGID, and more...
2022-10-18 17:36:17 +02:00
a9d3bdba6f Kernel: Keep track of a task's PPID 2022-10-18 17:18:37 +02:00
4f41b9ed37 Scheduler: Implement a find_by_pid function 2022-10-17 20:40:38 +02:00
8b17065718 Kernel, libc: Rename gettid() to getpid() and move it to unistd.h 2022-10-17 20:08:44 +02:00
87ef210759 Kernel, libc: Remove spawn()
Now, fork() and exec() are both implemented. More POSIX-y, thus spawn can be removed.
2022-10-17 19:55:01 +02:00
ea8a42b8c0 Kernel: Add a name field to the Task structure 2022-10-17 19:12:47 +02:00
92634048fc UserHeap: some nice improvements 2022-10-17 18:49:19 +02:00
64f5078494 Kernel, libc: Implement fork()
This time for real.

Also, add a new per-user-task virtual address allocator (UserHeap), so that mmap'ed pages are in user range and can be copied.
2022-10-17 18:43:35 +02:00
682be58d97 AddressSpace: copy instead of linking 2022-10-17 17:24:33 +02:00
250db2c90f Scheduler: add an append_task() function 2022-10-17 17:14:22 +02:00
c2fa4f380d Kernel: Use the new Task member functions 2022-10-17 17:07:25 +02:00
891651f2d6 Task: Move functions operating on Task to member functions
Also, add an alloc_fd_greater_than_or_equal() function, for use in fcntl(F_DUPFD)
2022-10-17 17:00:07 +02:00
9b39d618de Kernel, libc: Implement spawn()
This function is a Luna alternative to fork() and exec().

Why? Simply because I can't figure out for the life of me how to implement a working fork().

So meanwhile, we have spawn() as a replacement. exec() still exists, though.
2022-10-16 18:48:35 +02:00
a1146a5ce2 Panic: show panic message on screen 2022-10-16 18:23:33 +02:00
d2e2883a79 Kernel: Make mkdir() accessible to userspace 2022-10-16 17:22:12 +02:00
18fbccafb7 VFS: add an exists() function 2022-10-16 16:58:18 +02:00
f8154ce230 Kernel: Implement mkdir() from a single path
This is done using dirname() and basename() :)
2022-10-16 14:45:25 +02:00
8c0a57f0c2 Kernel: Copy strrchr, dirname and basename over from libc 2022-10-16 14:36:25 +02:00
68403dc029 Kernel: Make AddressSpaces reference-counted 2022-10-15 17:40:33 +02:00
aca1367158 Kernel: Switch to strlcpy() as well
Surprisingly, most uses of strncpy() are in places where strncpy() is actually a better choice.
For example, copying to a fixed-length char array in a structure.
2022-10-15 17:30:34 +02:00
4bad782aad Kernel: Increment the maximum number of file descriptors a task can have
Doesn't use up more space in the Task structure, and now we are above the Minimum Acceptable Value as defined by POSIX (20), I think.
2022-10-15 14:20:29 +02:00
62a2bcf2ff Kernel: Add a clock() system call 2022-10-15 13:17:26 +02:00