Commit Graph

333 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 47e1cc439a Add glob(3).
Switch sh(1) to use glob(3).

Remove compatibility for no glob(3) from the ports.
2023-03-16 00:20:43 +01:00
Jonas 'Sortie' Termansen 2cd7361294 Add memusage(2).
Switch xz to memusage(2) and fix native self-cross issue.

This is a compatible ABI change.
2023-03-09 20:27:17 +01:00
Jonas 'Sortie' Termansen 580b71ae89 Add getifaddrs(3) and freeifaddrs(3). 2023-01-10 22:31:48 +01:00
Jonas 'Sortie' Termansen 3997116656 Add if_nameindex(3). 2022-12-16 23:44:50 +01:00
Jonas 'Sortie' Termansen 2ef6804ead Add networking stack.
This change adds all the kernel parts of a network stack. The network stack
is partial but implements many of the important parts.

Add if(4) network interface abstraction. Network interfaces are registered
in a global list that can be iterated and each assigned an unique integer
identifier.

Add reference counted packets with a cache that recycles recent packets.

Add support for lo(4) loopback and ether(4) ethernet network interfaces.
The /dev/lo0 loopback device is created automatically on boot.

Add arp(4) address resolution protocol driver for translation of inet(4)
network layer addresses into ether(4) link layer addresses. arp(4) entries
are cached and evicted from the cache when needed or when the entry has not
been used for a while. The cache is limited to 256 entries for now.

Add ip(4) internet protocol version 4 support. IP fragmentation and options
are not implemented yet.

Add tcp(4) transmission control protocol sockets for a reliable transport
layer protocol that provides a reliable byte stream connection between two
hosts. The implementation is incomplete and does not yet implement out of
band data, options, and high performance extensions.

Add udp(4) user datagram protocol sockets for a connectionless transport
layer that provides best-effort delivery of datagrams.

Add ping(4) sockets for a best-effort delivery of echo datagrams.

Change type of sa_family_t from unsigned short to uint16_t.

Add --disable-network-drivers to the kernel(7) options and expose it with a
bootloader menu. tix-iso-bootconfig can set this option by default.

Import CRC32 code from libz for the Ethernet checksum.

This is a compatible ABI change that adds features to socket(2) (AF_INET,
IPPROTO_TCP, IPPROTO_UDP, IPPROTO_PING), the ioctls for if(4), socket
options, and the lo0 loopback interface.

This commit is based on work by Meisaka Yukara contributed as the commit
bbf7f1e8a5238a2bd1fe8eb1d2cc5c9c2421e2c4. Almost no lines of this work
remains in this final commit as it has been rewritten or refactored away
over the years, see the individual file headers for which files contain
remnants of this work.

Co-authored-by: Meisaka Yukara <Meisaka.Yukara@gmail.com>
2022-12-11 13:40:34 +01:00
Jonas 'Sortie' Termansen 322c8317d6 Fix non-throwing operator new failure checks being optimized away. 2022-04-26 01:08:19 +02:00
Juhani Krekelä e9c4946ff7 Document getdnsconfig(2) and setdnsconfig(2). 2022-03-06 16:18:12 +02:00
Jonas 'Sortie' Termansen ac9c24219b Implement RFC5424 syslog version 1. 2022-01-05 22:00:53 +01:00
Jonas 'Sortie' Termansen 5e7605fad2 Implement threading primitives that truly sleep.
The idle thread is now actually run when the system is idle because it
truly goes idle. The idle thread is made power efficient by using the hlt
instruction rather than a busy loop.

The new futex(2) system call is used to implement fast user-space mutexes,
condition variables, and semaphores. The same backend and design is used as
kutexes for truly sleeping kernel mutexes and condition variables.

The new exit_thread(2) flag EXIT_THREAD_FUTEX_WAKE wakes a futex.

Sleeping on clocks in the kernel now uses timers for true sleep.

The interrupt worker thread now truly sleeps when idle.

Kernel threads are now named.

This is a compatible ABI change.
2021-06-23 22:10:47 +02:00
Jonas 'Sortie' Termansen 3b036b6c5d Add getdnsconfig(2) and setdnsconfig(2). 2021-06-13 23:27:52 +02:00
Jonas 'Sortie' Termansen a969564af4 Delete inet_addr(3) and inet_ntoa(3). 2020-07-29 21:38:41 +02:00
Jonas 'Sortie' Termansen 8d4b932f0f Add <sha2.h>. 2020-04-13 22:15:04 +02:00
Jonas 'Sortie' Termansen 221fa7d954 Rewrite scanf(3) to be standards compliant.
This change adds missing features:

* %[ for pattern matching with a scanset.
* %m for allocation of strings.
* %p for pointers.
* Field width for integers.

The following features remain unimplemented, like with printf(3):

* Floating point support.
* Wide character support.
* %n$ positional parameters.

The code has been completely refactored to be much more maintainable.

The implemented features should now be standards compliant. A large number
of edge cases have been fixed.

The vscanf_callback(3) function has been renamed to vcbscanf(3) and a new
cbscanf(3) function has been added.
2020-03-07 23:31:05 +01:00
Jonas 'Sortie' Termansen 5de36cf449 Add inet_pton(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen ba3b6d386e Add inet_ntop(3). 2017-02-14 20:43:30 +01:00
Jonas 'Sortie' Termansen 0b6e58a7ef Document scram(2). 2017-02-12 13:59:07 +01:00
Jonas 'Sortie' Termansen 52ea22d793 Add ptsname_r(3). 2016-11-23 22:31:41 +01:00
Jonas 'Sortie' Termansen 1f742d521c Add ptsname(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 88de69487b Add unlockpt(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 46ebbf82d4 Add grantpt(3). 2016-11-23 22:31:40 +01:00
Jonas 'Sortie' Termansen 2563b926ad Add posix_openpt(3). 2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen 365815401b Add openpty(3). 2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen b38c84852c Add pseudo terminals.
This is a compatible ABI change riding on the previous commit's bump.
2016-11-23 22:31:05 +01:00
Jonas 'Sortie' Termansen db7182ddc3 Add support for sessions.
This change refactors the process group implementation and adds support
for sessions. The setsid(2) and getsid(2) system calls were added.

psctl(2) now has PSCTL_TTYNAME, which lets you get the name of a process's
terminal, and ps(1) now uses it.

The initial terminal is now called /dev/tty1.

/dev/tty is now a factory for the current terminal.

A global lock now protects the process hierarchy which makes it safe to
access other processes. This refactor removes potential vulnerabilities
and increases system robustness.

A number of terminal ioctls have been added.

This is a compatible ABI change.
2016-11-23 22:30:47 +01:00
Nicholas De Nova a942b15f91 Add errc(3) family. 2016-11-06 15:31:52 -06:00
Jonas 'Sortie' Termansen 67471b55e7 Add nl_langinfo(3). 2016-10-03 20:02:12 +02:00
Jonas 'Sortie' Termansen 01a9779fc6 Compile libc with -ffreestanding.
This properly avoids problems where the compiler is unaware that this is the
implementation and assumes it can rely on the implementation. For instance,
it might implement calloc using a call to calloc.

Restructure the code that wrongly assumed __STDC_HOSTED__ meant userspace.
2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 2a6a246ff4 Remove getdomainname(2). 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 443b4797bb Add dirname and basename to libk. 2016-03-07 17:46:14 +01:00
Jonas 'Sortie' Termansen 8e988c1bf1 Convert libpthread to C and merge into libc. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen 01b59c1947 Convert libc to C. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen b5f9876089 Remove unnecessary libg.a. 2016-01-26 21:17:08 +01:00
Jonas 'Sortie' Termansen 9e6876ff14 Split fdio into multiple files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 3320e29c95 Remove unused libc signal assembly files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 4d2901b90e Split stdin, stdout and stderr into their own files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 2e4b15daed Simplify directory reading. 2016-01-26 18:42:54 +01:00
Jonas 'Sortie' Termansen bb73362d23 Create stdio buffers at FILE creation time.
This removes support for user-supplied buffers with setvbuf.
2016-01-26 18:39:48 +01:00
Jonas 'Sortie' Termansen 63d42cd686 Add fstab(3). 2016-01-25 17:42:25 +01:00
Jonas 'Sortie' Termansen bff1265d62 Add termios(2). 2016-01-25 15:47:40 +01:00
Jonas 'Sortie' Termansen fbfe159046 Add crypt_checkpass(3) and crypt_newhash(3). 2016-01-09 02:54:51 +01:00
Jonas 'Sortie' Termansen 53711549af Add bcrypt_checkhash(3) and bcrypt_newhash(3). 2016-01-09 02:54:51 +01:00
Jonas 'Sortie' Termansen 02f95d6c1c Add in6addr_any and in6addr_loopback. 2015-12-18 01:34:37 +01:00
Jonas 'Sortie' Termansen 75808c637d Add regex(3). 2015-12-17 23:32:43 +01:00
Jonas 'Sortie' Termansen 5a3e181975 Add stack smash protection support. 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen 9b6d60d9d2 Add undefined behavior sanitizer support. 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen 4b6b06bbc8 Add scram(2). 2015-12-12 22:53:07 +01:00
Jonas 'Sortie' Termansen cee24359d8 Add psctl(2). 2015-12-12 19:28:07 +01:00
Jonas 'Sortie' Termansen 213b3636bb Add open_memstream(3). 2015-08-26 18:10:24 +02:00
Jonas 'Sortie' Termansen f1571ebaf4 Add err(3). 2015-08-26 18:10:24 +02:00
Jonas 'Sortie' Termansen 59e7dd00c5 Add mkdtemps(3). 2015-08-26 16:49:18 +02:00