Commit Graph

458 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen b63e5af467 Add secure_getenv(3). 2024-06-23 23:31:37 +02:00
Jonas 'Sortie' Termansen 85bad22f34 fixup! Recognize and advertise POSIX 2024 support. 2024-06-23 23:19:16 +02:00
Jonas 'Sortie' Termansen 3474d7f674 Add PTHREAD_NULL. 2024-06-23 23:04:04 +02:00
Jonas 'Sortie' Termansen 020c263d5d Add nl_langinfo(3) ALTMON_* and ABALTMON_*. 2024-06-23 22:32:13 +02:00
Jonas 'Sortie' Termansen 5c896e027a Add ESOCKTNOSUPPORT. 2024-06-23 19:56:50 +02:00
Jonas 'Sortie' Termansen 23bce072c0 Reject the obsolescent inet_addr and inet_ntoa. 2024-06-23 19:48:50 +02:00
Jonas 'Sortie' Termansen 16abe619e6 fixup! Implement dladdr(3). 2024-06-23 19:45:58 +02:00
Jonas 'Sortie' Termansen 535ee9649f Add sig2str(3) and str2sig(3). 2024-06-23 19:38:24 +02:00
Jonas 'Sortie' Termansen 64fc6b5f6d Add thread wait functions with clock support.
- pthread_cond_clockwait(2)
- pthread_mutex_clocklock(2)
- pthread_mutex_timedlock(2)
- pthread_rwlock_clockrdlock(2)
- pthread_rwlock_clockwrlock(2)
- pthread_rwlock_timedrdlock(2)
- pthread_rwlock_timedwrlock(2)
- sem_clockwait(2)
2024-06-23 19:05:04 +02:00
Jonas 'Sortie' Termansen 0f5aaed789 Add memmem(3). 2024-06-23 17:28:53 +02:00
Jonas 'Sortie' Termansen 8f68ea49ce Add getlocalename_l(3). 2024-06-23 17:28:08 +02:00
Jonas 'Sortie' Termansen 240d227be8 Implement dladdr(3). 2024-06-23 13:48:48 +02:00
Jonas 'Sortie' Termansen c4a44531bf Add _Fork(2). 2024-06-23 13:40:39 +02:00
Jonas 'Sortie' Termansen 82fd2d4c92 Recognize and advertise POSIX 2024 support.
Update feature macros for interfaces added to POSIX 2024.

This commit begins the work of implementing POSIX 2024, which was
largely already implemented as extensions.
2024-06-23 13:33:55 +02:00
Jonas 'Sortie' Termansen 50792cb986 Remove unused alternative const safe sortix string functions. 2024-06-23 12:10:18 +02:00
Jonas 'Sortie' Termansen 6e51c1ae51 Add init groups.
Every process now has an init process like it has a session, and each
session belong to an init. Orphaned processes are reparented to its init
process. All descendent processes are SIGKILL'd when an init process exits
and creating additional processes/threads fails.

Add setinit(2) for becoming the init process for your child processes and
add getinit(2) for locating your init process.

Add TIOCSCTTY force flag that releases a terminal from its current session
and makes it the controlling terminal for the current session. This ioctl
is essential to transferring the controlling terminal to a nested init,
which has its own session.

Add TIOCUCTTY that releases the terminal as the controlling terminal for
its current session.

Remove INIT_PID as it is replaced by getinit(2).
2024-06-22 18:25:49 +02:00
Jonas 'Sortie' Termansen eb1f28c738 Add kernel heap allocation tracing debug facility. 2024-06-22 18:25:48 +02:00
Jonas 'Sortie' Termansen 04b605477e Add IFF_UP to getifaddrs(3). 2024-03-25 23:11:36 +01:00
Jonas 'Sortie' Termansen 9033153c47 Add sub_leap_seconds(3) and add_leap_seconds(3).
Advertise leap seconds being counted via CLOCK_REALTIME_HAS_LEAP_SECONDS.
2023-03-27 00:06:33 +02:00
Jonas 'Sortie' Termansen c57ff050e9 Add include and comment support to passwd(5) and group(5). 2023-03-19 21:53:21 +01:00
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 b9a72bbfbc Add ssh port. 2023-02-26 15:13:19 +01:00
Jonas 'Sortie' Termansen 580b71ae89 Add getifaddrs(3) and freeifaddrs(3). 2023-01-10 22:31:48 +01:00
Jonas 'Sortie' Termansen cbf0c1dc97 Fix endian swapping classes reading volatile values twice. 2023-01-09 23:44:40 +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 006145d335 Add EHOSTDOWN. 2022-12-04 23:18:17 +01:00
Juhani Krekelä e4c8d42b7c Update to dbus-1.14.0. 2022-07-11 00:25:00 +02:00
Jonas 'Sortie' Termansen 611dc22e73 Standardize header include guards.
This change makes all the standard library and kernel headers use header
guards with a consistent scheme within the reserved namespace to avoid
conflicts with non-standard-library-implementation code.
2022-07-09 20:51:13 +02:00
Jonas 'Sortie' Termansen fe729d6032 Fix typo in <malloc.h>. 2022-04-26 01:08:31 +02:00
Jonas 'Sortie' Termansen ac9c24219b Implement RFC5424 syslog version 1. 2022-01-05 22:00:53 +01:00
Jonas 'Sortie' Termansen 3c43f71084 Implement file descriptor passing.
This change refactors the Unix socket / pipe backend to have a ring buffer
containing segments, where each segment has an optional leading ancillary
buffer containing control messages followed by a normal data buffer.

The SCM_RIGHTS control message has been implemented which transfers file
descriptors to the receiving process. File descriptors are reference counted
and cycles are prevented using the following restrictions:

1) Unix sockets cannot be sent on themselves (on either end).
2) Unix sockets themselves being sent cannot be sent on.
3) Unix sockets cannot send a Unix socket being sent on.

This is a compatible ABI change.
2021-12-31 22:24:11 +01:00
Jonas 'Sortie' Termansen db4ab331c7 Fix <psctl.h> using the same include guard as <sys/ioctl.h>. 2021-12-12 22:13:05 +01:00
Juhani Krekelä c6e989909f Add header for working with the PS/2 mouse protocol. 2021-12-12 20:34:07 +02: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 4daedc31f7 Fix handling of overflow and non-canonical values in timespec APIs.
Support zero relative and absolute times in the timer API.
2021-06-22 21:48:27 +02:00
Jonas 'Sortie' Termansen 3b036b6c5d Add getdnsconfig(2) and setdnsconfig(2). 2021-06-13 23:27:52 +02:00
Jonas 'Sortie' Termansen 9d87d76957 Abort on overlapping memcpy. 2021-05-30 23:48:19 +02:00
Jonas 'Sortie' Termansen 1c9233e0c9 Add ENOMEDIUM. 2021-05-29 00:52:33 +02:00
Jonas 'Sortie' Termansen 11be0007b8 Remove ENOUSER and ENOGROUP.
The <pwd.h> and <grp.h> family of functions are supposed to return
nothing with no error set if there is no matching entry.
2021-05-10 23:26:31 +02:00
Jonas 'Sortie' Termansen b2235844da Add TCP_MAXSEG and TCP_NOPUSH definitions. 2021-01-23 00:35:38 +01: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 d3a2eb8a79 Unify EWOULDBLOCK and EAGAIN. 2020-03-15 23:13:17 +01: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 29555d72bb Fix <fcntl.h> including <sys/stat.h> namespace pollution.
POSIX allows <fcntl.h> to include <sys/stat.h>, but doesn't require it.
There's little reason to do that, since they are separate headers, and
<fcntl.h> just needs the mode_t constants. Fix the code accidentally
relying on <fcntl.h> including <sys/stat.h>. The mode_t constants are now
provided in their own kernel header <sortix/mode.h>.

Additionally fix <sys/stat.h> pulling in all of <sys/types.h>, which is not
allowed by POSIX, which only requires a few types to be declared. Fix the
code accidentally relying on <sys/stat.h> including <sys/types.h>.

Finally fix <dirent.h> pulling in <stdint.h> through <sortix/dirent.h>.

The <sortix/__/dt.h> and <sortix/__/stat.h> headers are no longer required
and their contents have been merged into <sortix/__/dirent.h>.
2018-08-06 23:59:34 +02:00
Jonas 'Sortie' Termansen 9c3af039ca Fix <stdio.h> pulling in <pthread.h> through <FILE.h> when __is_sortix_libc. 2018-07-17 12:25:52 +02:00
Jonas 'Sortie' Termansen 7c91ea1b19 Add restartable system calls compatibility macro. 2017-12-04 23:56:47 +01:00
Jonas 'Sortie' Termansen c8ba4b0973 Add float formating and parsing compatibility macros. 2017-12-04 23:56:47 +01:00