Commit Graph

226 Commits

Author SHA1 Message Date
da7ad8da5b Kernel: Show the file location when a check fails 2022-11-09 15:23:59 +01:00
033c41cbd7 Kernel: Rework the uid/gid system to make it compliant 2022-11-09 09:54:07 +01:00
98da473fdc Run clang-format 2022-11-08 19:07:43 +01:00
6f72f92493 Kernel: Start preparing for recursive paging 2022-11-08 17:12:59 +01:00
5d94525c7a Kernel: Figure out why a program is misbehaving 2022-11-06 18:12:25 +01:00
44815b08c7 Kernel: Use copy_from_user() and copy_to_user() in read/write
This is huge. Finally, we can do proper reads/writes with invalid addresses, or big buffers.
2022-11-06 15:19:23 +01:00
b63a9f5ba9 Kernel: Improve strdup_from_user and add copy to and from user
Still a bit funky, that's why we're not using it in read() and write() yet.
2022-11-05 11:54:55 +01:00
67f536cf91 Kernel: Split number-parsing code into a separate file 2022-11-05 10:50:58 +01:00
ffcaac0ca3 Kernel: Add validate_user_write() and validate_user_read()
Not at copy_from_user and copy_to_user yet, but an improvement over blindly using physical memory.
2022-11-04 22:46:48 +01:00
0fd31698b2 Kernel: Accept not opened file descriptors in dup2()
This involves renaming the descriptor_from_fd function to the more appropriately named
open_descriptor_from_fd (since we check if the descriptor was opened and error out otherwise),
and creating a new function that does not verify that the file descriptor was opened.
2022-11-03 16:52:21 +01:00
249c79f8a3 Kernel, libc: Add ioctl()
Right now, only the framebuffer supports this system call, to query its dimensions.
2022-11-02 20:59:42 +01:00
feab66c0d3 Kernel: Remove the paint() system call
That was a very old one from back in the old days. Now that the framebuffer is finally a device file,
and it can be memory-mapped by user programs for more performance,
this syscall is MORE than obsolete.
2022-11-02 20:35:06 +01:00
8f2308c80d Kernel: Implement mmap-able device files (regular files are not mmap-able yet) 2022-11-02 20:24:07 +01:00
42a805fd60 Kernel: Move the translated keyboard to /dev/console and make /dev/kbd provide raw scancodes 2022-11-02 19:51:54 +01:00
c604c074a1 Kernel: Rename ASSERT() to ensure()
Doesn't get stripped on release builds, so it shouldn't be named assert.
2022-11-02 19:38:15 +01:00
e5cf32c7b3 Kernel: Introduce page ownership
Some pages, such as framebuffer pages, are not physical memory frames reserved for the current process.
Some, such as the framebuffer, may be shared between all processes.
Yet, on exit() or on exec(), a process frees all frames mapped into its address spaces.
And on fork(), it copies all data between frames. So how could we map framebuffers.

Simple: we use one of the bits in page table entries which are available to the OS, and mark whether that page is owned by the current process.

If it is owned, it will be:
- Freed on address space destruction
- Its data will be copied to a new page owned by the child process on fork()

If it is not owned, it will be:
- Left alone on address space destruction
- On fork(), the child's virtual page will be mapped to the same physical frame as the parent

This still needs a bit more work, such as keeping a reference of how many processes use a page to free it when all processes using it exit/exec.
This should be done for MAP_SHARED mappings, for example, since they are not permanent forever,
unlike the framebuffer for example.
2022-11-02 19:32:28 +01:00
22740e69bf Kernel: Add support for the NX bit
Not support, actually. We now REQUIRE it.
2022-11-02 18:34:57 +01:00
c2a08060cf VFS: Add support for an implementation-defined value 2022-10-30 20:53:45 +01:00
52d4f34f05 Kernel, libc: Implement umask() 2022-10-30 19:55:38 +01:00
29c59abf7d Kernel: Rename blocking_wait_info's wait_pid to pid 2022-10-30 19:28:43 +01:00
e244c150c2 Kernel, libc: Add ECHILD 2022-10-30 19:24:26 +01:00
af0f4d2037 Kernel: Remove /dev/uptime
This information can now be fetched with clock_gettime.
2022-10-30 10:16:53 +01:00
e640c6e245 Kernel, libc, userspace: Add file timestamps (atime,ctime,mtime) 2022-10-30 09:57:17 +01:00
688a640a16 Kernel: Add the clock_gettime syscall, which replaces clock as it can be used for more stuff 2022-10-30 09:07:59 +01:00
baf97840e9 Kernel: Keep track of boot time 2022-10-30 09:07:03 +01:00
e05f3f5325 Kernel: Read file modes from the initrd, filtering out write permissions 2022-10-28 20:52:10 +02:00
1c4f1ab867 Kernel, libc: Add setuid() and setgid() system calls 2022-10-28 17:19:26 +02:00
26b20938de Kernel, libc: Use mode in mkdir() 2022-10-28 17:11:35 +02:00
0115cce750 Kernel/VFS: Add file owners and file modes, and check those in system calls 2022-10-28 17:10:28 +02:00
16dc227a05 Kernel: Add UID and GID fields to Task 2022-10-28 17:06:13 +02:00
3effe8b004 Kernel: Add EACCES to std/errno.h 2022-10-28 17:02:27 +02:00
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