Commit Graph

1081 Commits

Author SHA1 Message Date
c79e412215 resolver: Fix UB and resolve localhost 2026-05-25 03:19:20 +03:00
43d03eb4a9 LibC: Add shm_open/shm_unlink
These can just open files in /tmp/shm. no need for anything fancier
2026-05-25 02:14:04 +03:00
2a6792b44a LibC: Make mlock, munlock and madvice no-ops
These don't have to do anything as I don't swap processes to disk
2026-05-25 02:14:04 +03:00
c72f2f9b31 LibC: Fix posix_spawn
signal was checking for NULL instead of SIG_ERR

there is no need to do post fork waiting in posix_spawn, we just have to
exit with 127 on error
2026-05-25 02:14:04 +03:00
62e2f4896a LibC: reorder LOCK_SH and LOCK_EX
Some software im porting has static asserts for these :)
2026-05-25 02:14:04 +03:00
9ccdebcd96 LibC: Implement/fix mk{,o}stemp{,s} 2026-05-25 02:14:04 +03:00
fe533c2e62 LibC: Fix freopen to preserve file state :) 2026-05-25 02:14:04 +03:00
ee5c225954 LibC: Add __fseterr
This is used by some ports to not require internal FILE structure
2026-05-25 02:14:04 +03:00
d5ee98708b TaskBar: Show CPU load in task bar! 2026-05-20 19:14:21 +03:00
7ce68b0488 LibGUI: Allow timeout with Window::wait_events 2026-05-20 19:03:11 +03:00
77796dd317 driver-install: implemented a simple installer 2026-05-20 17:52:19 +03:00
f1a72cc9da Kernel: Implemented banos - a WIP C driver API
Banos is a stable WIP C driver API that is supposed to provide a simple
interface to interact with the kernel and load the modules dynamically.
It is WIP and atm this just implements module loading with a custom
banos_install syscall. Banos will not try to substitute parts of the
kernel instead it will just expose kernel functionality via a stable
BINARY API. Meaning binaries (should) remain forward and backward
compatible on a binary level.

Banos modules work similarly to those in linux, you expose symbols via
BANOS_EXPORT which allows you to export a name + addr paired symbol.
It puts it in the .banos-export section. Drivers provide metadata about
themselves in the REQUIRED .banos-driver section. Symbols are resolved
at runtime. The kernel exposes the driver functionality via the same
.banos-export export mechanism.

Banos modules are elf RELOCATABLE files (object files) which have
partial linking (only banos symbols should remain). Modules will
eventually define dependencies, will export symbols and will allow you
to build a complex object hierarchy.

This patch adds the banos_install syscall which takes in the driver
image to install and may only be executed by super users. The API
doesn't validate already loaded modules, as thats something the
userspace MAY choose to keep track of. Multi-instance functionality
shall be implemented via driver specific behaviuor (exposed in the dev
filesystem or some other means).

Modules are supposed to allow you to alter kernel behavior and extend
it, allowing you to create filesystems, drivers, networking
modifications, schedulers, probers, and more (hopefully) whilst
remaining binary compatible with any version of the kernel (again,
hopefully).
2026-05-20 17:52:19 +03:00
45e55d8907 LibC: Don't compare equal elements in qsort
This seemed to break supertuxkart which returned `less` in this case
2026-05-20 05:54:45 +03:00
e9d6431728 DynamicLoader: Fix dynamic TLS init order 2026-05-20 05:03:20 +03:00
aa8be130f9 DynamicLoader: Cleanup lazy PLT relocations 2026-05-20 05:02:48 +03:00
d52ad29afa Kernel: Add missing tr cmake file 2026-05-19 13:57:56 +03:00
1922d78661 Kernel: Add support for mkfifo{,at} mkdir at
Opening FIFOs still dont work as expected but at least you can create
them now :D
2026-05-18 23:53:09 +03:00
9c79971bdc LibC/Kernel: Add support for detached pthreads 2026-05-17 00:40:56 +03:00
ff75c15ba3 LibC: Move pthread keys to TCB
This removes all TLS relocations from libc which may become handy ;)
2026-05-17 00:29:20 +03:00
9c3eb8d270 userspace: Implement tr utility 2026-05-17 00:29:20 +03:00
68479bf07e userspace: Fix getopt_long usage
- Add missing null entry after the last long option
- Don't duplicate illegal option message, getopt already prints
  the message as I do not suppress it. Also handle missing arguments.
2026-05-17 00:29:20 +03:00
40dd29b876 LibC: Cleanup syscall macros 2026-05-17 00:29:20 +03:00
dc1d7e3fae ls: Print total field with -l 2026-05-15 22:46:50 +03:00
8f8ba2751c ls: Add support for -A and -h 2026-05-15 22:35:58 +03:00
928d3e3fe7 dirname: Fix help message 2026-05-15 22:34:48 +03:00
bf2121e166 LibC: Implement tc{get,set}winsize
These were added in POSIX issue 8 :^)
2026-05-15 17:08:02 +03:00
05c9f0640c Kernel/LibC: Replace terminal syscalls with ioctls
isatty, tc{get,set}attr, tc{get,set}pgrp are now implemented as ioctls
instead of separate syscalls
2026-05-15 17:03:33 +03:00
fe2c9f7d2d LibC: Rewrite malloc
The old linked list allocator with power of two pool sizes was kinda
weird. Now we use 1MiB bitmap allocators for allocations <64KiB and
directly call mmap for larger allocations. This allows userspace to
actually free unused memory on `free` :)
2026-05-15 17:03:33 +03:00
d7cdf3818c LibC: Make aio.h incudable in C++
aio stuff is not supported but now the header is at least includable in
C++ which was not possible before as __restrict was not allowed in array
size
2026-05-15 17:03:33 +03:00
6a2f041858 LibC: Handle negative size in fgets 2026-05-15 17:03:33 +03:00
f0c5fb3a87 LibC: Don't use ScopeGuard in exec
These ended up pulling `operator delete` which is not available when
linking with gcc :^)
2026-05-15 17:03:33 +03:00
212ab010a5 BAN: Expose radix sort with user provided buffer
This can be nice if user has memory for a the temporary buffer and
doesnt want the sorting to allocate or be able to fail.

Also counts are now stack allocated, there isn't really any reason to
allocate them on the heap as 256x 64 bit values only adds up to 2 KiB
2026-05-13 05:05:11 +03:00
d345f96387 LibC: Optimize qsort
Apply same optimizations as to BAN quick sort!
2026-05-13 04:37:25 +03:00
912647ce68 Shell: Fix type builtin PATH resolution
We were not adding a '/' between PATH dir and the command
2026-05-06 17:30:43 +03:00
47650980f2 LibC: Reorder stack trace dump printing
If we fault while getting start of stack frame at least we now print
that we were trying to get the stack trace :^)
2026-05-05 13:54:51 +03:00
4b12770485 LibC: Don't leak FILEs on failed shebang exec 2026-05-05 13:52:52 +03:00
ba106f6bf5 LibC: Update argv[0] for shebang scripts to full path
This is needed so `dirname -- "$0"` works with shebang scripts found in
PATH
2026-05-05 12:48:04 +03:00
3a05a29294 dirname: Support options and multiple strings
This is not needed by POSIX but sdl2-config uses `dirname -- "$0"`
2026-05-05 01:42:28 +03:00
28499b890c LibC: Mark exit as noreturn 2026-05-04 20:26:02 +03:00
fde085e04b Kernel: Pass current cpu index as a GDT limit
I had no idea LSL was an instruction. This cleans up code to get the
current cpu by a lot and does not require extra segment usage :D
2026-05-04 20:26:02 +03:00
bef53c726b Userspace: Install libdl, libm, libpthread as symlinks to libc
Having dummy libraries was just unnecessary
2026-04-21 21:46:00 +03:00
eea0154f18 LibC: Cleanup RNG and properly initialize to srand(1) at startup 2026-04-21 00:26:41 +03:00
ea4c34fc0b LibC: Fix printf thread safety
I don't know why I was using a static buffer for value conversions :D
2026-04-21 00:25:56 +03:00
558ed8fd44 LibC: Define pthread_{equal,self} as macros
These really should get inlined :D
2026-04-21 00:25:16 +03:00
40f3546aca BAN: Rewrite HashMap as a wrapper around HashSet
There is really no need to have two implementation of the same thing.
Only difference now is that HashMap's value type has to be movable but
this wasn't an issue
2026-04-21 00:18:18 +03:00
a24ec0da2b LibC: Don't complain about stack size until 8192 bytes
It was unnecessary as userspace stack is way bigger than that...
2026-04-19 17:52:21 +03:00
e6284c3cf3 LibC/Kernel: Bump PATH_MAX to 4096 2026-04-19 17:52:21 +03:00
f527aca9d0 LibC: add strcasestr to string.h 2026-04-19 17:52:21 +03:00
5fce3b64cc LibC: implemented strptime (partially) 2026-04-17 21:05:58 +03:00
c04ad65f7f LibC: Add mbsinit and wcsrtombs stubs 2026-04-17 18:40:18 +03:00