Commit graph

354 commits

Author SHA1 Message Date
Idan Horowitz 9547a8e8a2 Kernel: Remove big lock from sys$close
This syscall doesn't access any unprotected shared data.
2022-04-09 23:46:02 +02:00
Idan Horowitz 0297349922 Kernel: Remove big lock from sys$chown
This syscall doesn't access any unprotected shared data.
2022-04-09 23:46:02 +02:00
Idan Horowitz 8458313e8a Kernel: Remove big lock from sys$fchown
This syscall doesn't access any unprotected shared data.
2022-04-09 23:46:02 +02:00
Idan Horowitz f986a3b886 Kernel: Remove big lock from sys$bind
This syscall doesn't access any unprotected shared data.
2022-04-09 23:46:02 +02:00
Luke Wilde 1682b0b6d8 Kernel: Remove big lock from sys$set_coredump_metadata
The only requirement for this syscall is to make
Process::m_coredump_properties SpinlockProtected.
2022-04-09 21:51:16 +02:00
Jelle Raaijmakers cc411b328c Kernel: Remove big lock from sys$accept4
The only thing we needed to check is whether `socket.accept()` returns
a socket, and if not, we go back to blocking again.
2022-04-09 17:53:18 +02:00
Andreas Kling 12b612ab14 Kernel: Mark sys$adjtime() as not needing the big lock
This syscall works on global kernel state and so doesn't need protection
from threads in the same process.
2022-04-04 00:42:18 +02:00
Andreas Kling 4306422f29 Kernel: Mark sys$clock_settime() as not needing the big log
This syscall ends up disabling interrupts while changing the time,
and the clock is a global resource anyway, so preventing threads in the
same process from running wouldn't solve anything.
2022-04-04 00:42:18 +02:00
Andreas Kling 55814f6e0e Kernel: Mark sys$sched_{set,get}param() as not needing the big lock
Both of these syscalls take the scheduler lock while accessing the
thread priority, so there's no reliance on the process big lock.
2022-04-04 00:42:18 +02:00
Andreas Kling 36d829b97c Kernel: Mark sys$listen() as not needing the big lock
This syscall already performs the necessary locking and so doesn't
need to rely on the process big lock.
2022-04-03 22:22:22 +02:00
Andreas Kling bc4282c773 Kernel: Mark sys$sendfd() and sys$recvfd() as not needing the big lock
These syscalls already perform the necessary locking and don't rely on
the process big lock.
2022-04-03 22:06:03 +02:00
Tim Schumacher 4ba39c8d63 Kernel: Implement f_basetype in statvfs 2022-04-03 19:15:14 +02:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Liav A b5ef900ccd Kernel: Don't assume paths of TTYs and pseudo terminals anymore
The obsolete ttyname and ptsname syscalls are removed.
LibC doesn't rely on these anymore, and it helps simplifying the Kernel
in many places, so it's an overall an improvement.

In addition to that, /proc/PID/tty node is removed too as it is not
needed anymore by userspace to get the attached TTY of a process, as
/dev/tty (which is already a character device) represents that as well.
2022-03-22 20:26:05 +01:00
int16 4307c4480e Kernel: Define MS_WXALLOWED mount option 2022-03-22 12:20:19 +01:00
Brian Gianforcaro f47c92bd2e Kernel: Mark serenity_dev_ functions as static
This avoids multiple definition errors when linking software which
may utilize these functions from different compilation units.
2022-03-18 11:59:35 +00:00
Linus Groh 9882848e0b Kernel: Define IF_NAMESIZE in net/if.h
This makes the _socket module from the Python port build. :^)
2022-03-16 18:03:25 +00:00
Andreas Kling 7b3642d08c Kernel: Mark sys$lseek() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 09e644f0ba Kernel: Mark sys$emuctl() as not needing the big lock
This syscall doesn't do anything at all, and definitely doesn't need the
big lock. :^)
2022-03-09 16:43:00 +01:00
Andreas Kling b4fefedd1d Kernel: Mark sys$chmod() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling aa381c4a67 Kernel: Mark sys$fchmod() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling d074aae422 Kernel: Mark sys$dup2() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 8aad9e7448 Kernel: Mark sys$ftruncate() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 69a6a4d927 Kernel: Mark sys$fstatvfs() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Sahan Fernando 0e57f80460 LibC: Add ioctls for VirGL 2022-03-09 14:58:48 +03:30
Tim Schumacher 5200cdac43 Kernel: Remove an unused fd_set.h import
The project appears to build just fine without it, and the explicit use
of `LibC` causes it to conflict with the system-wide `fd_set.h` when
building inside of Serenity.
2022-03-08 16:18:48 -08:00
Andreas Kling 6354a9a030 Kernel: Mark sys$fsync() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling ef45ff4703 Kernel: Mark sys$readlink() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 2688ee28ff Kernel: Mark sys$stat() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling be7ec52ed0 Kernel: Mark sys$fstat() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 23822febd2 Kernel: Mark sys$fchdir() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 156ab0c47d Kernel: Mark sys$chdir() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 7597bef771 Kernel: Mark sys$getcwd() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling f630d0f095 Kernel: Mark sys$realpath() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 7543c34d07 Kernel: Mark sys$anon_create() as not needing the big lock
This syscall is already safe for no-big-lock since it doesn't access any
unprotected data.
2022-03-08 00:19:49 +01:00
Andreas Kling baa6ff5649 Kernel: Wrap HIDManagement keymap data in SpinlockProtected
This serializes access to the current keymap data everywhere in the
kernel, allowing to mark sys$setkeymap() as not needing the big lock.
2022-03-07 16:35:23 +01:00
Ali Mohammad Pur e14e919b78 Kernel: Fill some siginfo and ucontext fields on SA_SIGINFO
There's no reason to fill in any of these fields if SA_SIGINFO is not
given, as the signal handler won't be reading from them at all.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 4bd01b7fe9 Kernel: Add support for SA_SIGINFO
We currently don't really populate most of the fields, but that can
wait :^)
2022-03-04 20:07:05 +01:00
Lucas CHOLLET 839d3d9f74 Kernel: Add getrusage() syscall
Only the two timeval fields are maintained, as required by the POSIX
standard.
2022-02-28 20:09:37 +01:00
Jakub Berkop 4916c892b2 Kernel/Profiling: Add profiling to read syscall
Syscalls to read can now be profiled, allowing us to monitor
filesystem usage by different applications.
2022-02-14 11:38:13 +01:00
Andrew Kaster b4a7d148b1 Kernel: Expose maximum argument limit in sysconf
Move the definitions for maximum argument and environment size to
Process.h from execve.cpp. This allows sysconf(_SC_ARG_MAX) to return
the actual argument maximum of 128 KiB to userspace.
2022-02-13 22:06:54 +02:00
Tom 03c45b1865 Kernel: Add ioctl to get the EDID from a framebuffer 2022-01-23 22:45:21 +00:00
Liav A b1ca39411b Kernel/Devices: Introduce the Device Control Device
This device will assist userspace to manage hotplug events.
A userspace application reads a DeviceEvent entry until the return value
is zero which indicates no events that are queued and waiting for
processing.
Trying to read with a buffer smaller than sizeof(DeviceEvent) results in
EOVERFLOW.
For now, there's no ioctl mechanism for this device but in the future an
acknowledgement mechanism can be implemented via ioctl(2) interface.
2022-01-23 00:38:02 +00:00
Dmitry Petrov d61cc47055 Kernel: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Daniel Bertalan 182016d7c0 Kernel+LibC+LibCore+UE: Implement fchmodat(2)
This function is an extended version of `chmod(2)` that lets one control
whether to dereference symlinks, and specify a file descriptor to a
directory that will be used as the base for relative paths.
2022-01-12 14:54:12 +01:00
Michel Hermier 69cabb3ead Everywhere: Add serenity_dev_{makedev,major,minor}
Add them in `<Kernel/API/Device.h>` and use these to provides
`{makedev,major,minor}` in `<sys/sysmacros.h>`. It aims to be more in
line with other Unix implementations and avoid code duplication in user
land.
2022-01-09 00:58:44 +01:00
Andreas Kling 95df924e0e Kernel: Remove EWHYTHO error code :^)
This error code was a hack for catching error handling mistakes in the
kernel. It's no longer used anywhere.
2022-01-08 20:10:58 +01:00
Aatos Majava d17dca5c91 Kernel: Update key_code_count
This was not updated when the Menu button was added.
2022-01-04 17:57:54 +00:00
Corey Williamson f51834d610 Kernel: Allow backspace '\b' to be remapped
Previously, one could put '\b' in a keymap, but in non-Terminal
applications, it would just insert a literal '\b' character instead of
behaving like backspace. This patch modifes
`visible_code_point_to_key_code` to include backspace, as well as
renaming it to `code_point_to_key_code` since '\b' is not a visible
character. Additionally, `KeyboardDevice::key_state_changed` has been
rearranged to apply the user's keymap before checking for things like
caps lock.
2022-01-03 15:54:32 +01:00
circl 63760603f3 Kernel+LibC+LibCore: Add lchown and fchownat functions
This modifies sys$chown to allow specifying whether or not to follow
symlinks and in which directory.

This was then used to implement lchown and fchownat in LibC and LibCore.
2022-01-01 15:08:49 +01:00
Brian Gianforcaro c444a3fc9e Kernel: Add EPROMISEVIOLATION as a kernel ErrnoCode 2021-12-29 18:08:15 +01:00
Daniel Bertalan e37dbee017 Kernel+LibC: Add ECANCELED errno value
This is needed for clangd to compile.
2021-12-29 03:42:45 -08:00
Owen Smith e6df1c9988 Kernel: Implement and use the syscall/sysret instruction pair on x86_64 2021-12-28 23:15:38 +01:00
Brian Gianforcaro 904ea56956 Kernel: Add _SC_MAPPED_FILES sysconf API
This is mandated by POSIX, it's fine that we don't actually implement
it, just as long as it's present during compilation. :^)
2021-12-28 11:00:51 +01:00
Brian Gianforcaro 4fdff1ba63 LibC: Add in6addr_loopback and IN6ADDR_LOOPBACK_INIT constant
Much like the existing in6addr_any global and the IN6ADDR_ANY_INIT
macro, our LibC is also expected to export the in6addr_loopback global
and the IN6ADDR_LOOPBACK_INIT constant.

These were found by the stress-ng port.
2021-12-28 11:00:51 +01:00
Daniel Bertalan 8e3d1a42e3 Kernel+UE+LibC: Store address as void* in SC_m{re,}map_params
Most other syscalls pass address arguments as `void*` instead of
`uintptr_t`, so let's do that here too. Besides improving consistency,
this commit makes `strace` correctly pretty-print these arguments in
hex.
2021-12-23 23:08:10 +01:00
Daniel Bertalan 77f9272aaf Kernel+UE: Add MAP_FIXED_NOREPLACE mmap() flag
This feature was introduced in version 4.17 of the Linux kernel, and
while it's not specified by POSIX, I think it will be a nice addition to
our system.

MAP_FIXED_NOREPLACE provides a less error-prone alternative to
MAP_FIXED: while regular fixed mappings would cause any intersecting
ranges to be unmapped, MAP_FIXED_NOREPLACE returns EEXIST instead. This
ensures that we don't corrupt our process's address space if something
is already at the requested address.

Note that the more portable way to do this is to use regular
MAP_ANONYMOUS, and check afterwards whether the returned address matches
what we wanted. This, however, has a large performance impact on
programs like Wine which try to reserve large portions of the address
space at once, as the non-matching addresses have to be unmapped
separately.
2021-12-23 23:08:10 +01:00
Brian Gianforcaro c724955d54 LibC: Add support for posix_madvise(..)
Add the `posix_madvise(..)` LibC implementation that just forwards
to the normal `madvise(..)` implementation.

Also define a few POSIX_MADV_DONTNEED and POSIX_MADV_NORMAL as they
are part of the POSIX API for `posix_madvise(..)`.

This is needed by the `fio` port.
2021-12-22 13:28:13 -08:00
Idan Horowitz 7a662c2638 Kernel: Add the si_errno and si_band siginfo_t members
These 2 members are required by POSIX and are also used by some ports.
Zero is a valid value for both of these, so no further work to support
them is required.
2021-12-22 22:53:56 +02:00
Idan Horowitz 5f4a67434c Kernel: Move userspace virtual address range base to 0x10000
Now that the shared bottom 2 MiB virtual address mappings are gone
userspace can use lower virtual addresses.
2021-12-22 00:02:36 -08:00
Idan Horowitz 7b24fc6fb8 Kernel+LibC: Stub out getifaddrs() and freeifaddrs()
These are required for some ports.
2021-12-22 00:02:36 -08:00
Idan Horowitz 468ae105d8 Kernel+LibC: Stub out if_nameindex() and if_freenameindex()
These should allow users to receive the names of network interfaces in
the system, but for now these are only stubs required to compile some
ports.
2021-12-22 00:02:36 -08:00
Idan Horowitz 3a1ff175e8 Kernel: Define and return the ARPHRD_* device type in SIOCGIFHWADDR
The sa_family field in SIOCGIFHWADDR specifies the underlying network
interface's device type, this is hardcoded to generic "Ethernet" right
now, as we don't have a nice way to query it.
2021-12-22 00:02:36 -08:00
Martin Bříza 86b249f02f Kernel: Implement sysconf(_SC_SYMLOOP_MAX)
Not much to say here, this is an implementation of this call that
accesses the actual limit constant that's used by the VirtualFileSystem
class.

As a side note, this is required for my eventual Qt port.
2021-12-21 12:54:11 -08:00
sin-ack 69ef211925 Kernel+LibC: Move errno definitions to Kernel/API/POSIX
This fixes at least half of our LibC includes in the kernel. The source
of truth for errno codes and their description strings now lives in
Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-16 22:21:35 +03:30
Jean-Baptiste Boric 23257cac52 Kernel: Remove sys$select() syscall
Now that the userland has a compatiblity wrapper for select(), the
kernel doesn't need to implement this syscall natively. The poll()
interface been around since 1987, any code still using select()
should be slapped silly.

Note: the SerenityOS source tree mostly uses select() and not poll()
despite SerenityOS having support for poll() since early 2019...
2021-12-12 21:48:50 +01:00
Idan Horowitz 762e047ec9 Kernel+LibC: Implement sigtimedwait()
This includes a new Thread::Blocker called SignalBlocker which blocks
until a signal of a matching type is pending. The current Blocker
implementation in the Kernel is very complicated, but cleaning it up is
a different yak for a different day.
2021-12-12 08:34:19 +02:00
Ben Wiederhake 0f8483f09c Kernel: Implement new ptrace function PT_PEEKBUF
This enables the tracer to copy large amounts of data in a much saner
way.
2021-12-05 22:59:09 +01:00
Ben Wiederhake 3e223185b3 Kernel+strace: Remove unnecessary indirection for PEEK
Also, remove incomplete, superfluous check.
Incomplete, because only the byte at the provided address was checked;
this misses the last bytes of the "jerk page".
Superfluous, because it is already correctly checked by peek_user_data
(which calls copy_from_user).

The caller/tracer should not typically attempt to read non-userspace
addresses, we don't need to "hot-path" it either.
2021-12-05 22:59:09 +01:00
Idan Horowitz b2464cf4c0 Kernel: Define PT_WRITE_I and PT_WRITE_D
These are aliases for PT_POKE that are used in some *BSDs.
2021-12-05 12:53:29 +01:00
Idan Horowitz 265764ff2f Kernel: Add support for the POLLWRBAND poll event 2021-12-05 12:53:29 +01:00
Idan Horowitz f2fef049e1 Kernel: Define the POLLRDNORM alias for POLLIN
This flag is equivalent to POLLIN.
2021-12-05 12:53:29 +01:00
Idan Horowitz 05aa764402 Kernel: Define the POLLWRNORM alias for POLLOUT
This is defined by posix to be equivalent to POLLOUT
2021-12-05 12:53:29 +01:00
Idan Horowitz 8074157c10 Kernel: Add the IPPROTO_{IGMP, IPIP, RAW} protocol macros
These are not implemented currently, but are required for some ports to
compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz 2860637ff3 Kernel: Add the IP_{BLOCK_SOURCE, UNBLOCK_SOURCE, OPTIONS} macros
These are not implemented currently, but are required for some ports to
compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz d18b3eb53d Kernel: Add the SO_OOBINLINE SOL_SOCKET-level option macro
This is not actually implemented, as we don't have any support for
out-of-band right now, but this is required for some ports to compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz 613ade9dec Kernel: Implement the SO_DONTROUTE SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz 641498954f Kernel: Implement the SO_ACCEPTCONN SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz a0e2fedc20 Kernel: Stub out the SO_DEBUG SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz e521ffd156 Kernel: Add support for the MSG_WAITALL sys$recvmsg flag 2021-12-05 12:53:29 +01:00
Idan Horowitz 5514d60d8d Kernel: Add support for the MSG_DONTROUTE sys$sendmsg flag 2021-12-05 12:53:29 +01:00
Daniel Bertalan 294cb3cef4 Kernel: Wrap x86 assembly behind ARCH(...) in Syscall.h
Unlike GCC, Clang parses assembly eagerly, and immediately rejects
inline assembly that's not for the right architecture.
2021-12-04 11:59:59 -08:00
Idan Horowitz f415218afe Kernel+LibC: Implement sigaltstack()
This is required for compiling wine for serenity
2021-12-01 21:44:11 +02:00
Idan Horowitz 5f95a1a7b7 LibC: Define the MADV_DONTNEED madvise advice macro
This isn't actually implemented at the moment, but it is required for
wine to compile
2021-12-01 21:44:11 +02:00
Idan Horowitz fc13d0782f LibC: Make the madvise advice field a value instead of a bitfield
The advices are almost always exclusive of one another, and while POSIX
does not define madvise, most other unix-like and *BSD systems also only
accept a singular value per call.
2021-12-01 21:44:11 +02:00
Idan Horowitz 48f92f6482 LibC: Add the SIGFPE si_code macros 2021-12-01 21:44:11 +02:00
macarc bffdc056a2 Kernel: Ensure KeyEvent::key sent to Userspace respects keyboard layout
Before, only KeyEvent::code_point took the user's keyboard layout
into consideration, while KeyEvent::key was hardcoded QWERTY. This
affected, among other things, Vim Emulation.

Now, KeyEvent::key respects the user's keyboard layout, so will be the
same as KeyEvent::code_point for visible (alphanumeric + symbol) keys.

Co-Authored-By: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
2021-11-26 11:19:36 -08:00
Ben Wiederhake 33079c8ab9 Kernel+UE+LibC: Remove unused dbgputch syscall
Everything uses the dbgputstr syscall anyway, so there is no need to
keep supporting it.
2021-11-24 22:56:39 +01:00
Andreas Kling daef7e2c71 Kernel+LibC: Fix misspelled "VERTICAL" in framebuffer ioctls 2021-11-21 20:22:48 +01:00
Itamar 38ddf301f6 Kernel+LibC: Fix ptrace for 64-bit
This makes the types used in the PT_PEEK and PT_POKE actions
suitable for 64-bit platforms as well.
2021-11-20 21:22:24 +00:00
Andreas Kling 32aa37d5dc Kernel+LibC: Add msync() system call
This allows userspace to trigger a full (FIXME) flush of a shared file
mapping to disk. We iterate over all the mapped pages in the VMObject
and write them out to the underlying inode, one by one. This is rather
naive, and there's lots of room for improvement.

Note that shared file mappings are currently not possible since mmap()
returns ENOTSUP for PROT_WRITE+MAP_SHARED. That restriction will be
removed in a subsequent commit. :^)
2021-11-17 19:34:15 +01:00
Andreas Kling 79fa9765ca Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace!
This was a slightly tedious refactoring that took a long time, so it's
not unlikely that some bugs crept in.

Nevertheless, it does pass basic functionality testing, and it's just
real nice to finally see the same pattern in all contexts. :^)
2021-11-08 01:10:53 +01:00
Idan Horowitz a8bd78e634 LibC: Include sys/uio.h in sys/socket.h for struct iovec 2021-10-28 11:24:36 +02:00
Idan Horowitz 2882a90dec Kernel: Add the IFF_* SIOCGIFFLAGS flag macros 2021-10-28 11:24:36 +02:00
Idan Horowitz adc9939a7b Kernel+LibC: Add support for the IPv4 TOS field via the IP_TOS sockopt 2021-10-28 11:24:36 +02:00
Idan Horowitz c45b1e1983 LibC: Add IPPROTO_ICMPV6 macro 2021-10-28 11:24:36 +02:00
Filiph Sandström c6247fe414 Everywhere: Rename back-click to backward-click
This matches the current forward-click terminology.
2021-10-27 22:05:58 +03:00
Liav A 8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Rodrigo Tobar e1093c3403 Kernel: Implement pread syscall
The OpenFileDescription class already offers the necessary functionlity,
so implementing this was only a matter of following the structure for
`read` while handling the additional `offset` argument.
2021-10-13 16:10:50 +02:00
Nico Weber 5a951d6258 Kernel: Fix a few typos 2021-10-01 00:51:49 +01:00
Jelle Raaijmakers 9a6283c524 Kernel: Define PT_READ_I and PT_READ_D
Looking at how these two constants are commonly used in other systems,
we should be able to mimic their behavior using our PT_PEEK constant.

For example, see:
https://man.netbsd.org/NetBSD-6.0.1/i386/ptrace.2
2021-09-23 18:51:21 +02:00
Brian Gianforcaro 07b314e843 Kernel+LibC: Pack SC_stat_params struct tighter
Flagged by pvs-studio, ordering the members from largest to smallest
allows us to save a few bytes in the size of the struct.
2021-09-16 17:17:13 +02:00
Brian Gianforcaro be15bd3c86 Kernel+LibC: Pack SC_mount_params struct tighter
Flagged by pvs-studio, ordering the members from largest to smallest
allows us to save a few bytes in the size of the struct.
2021-09-16 17:17:13 +02:00
Brian Gianforcaro dcb327a83b Kernel+LibC: Pack SC_setsockopt_params struct tighter
Flagged by pvs-studio, ordering the members from largest to smallest
allows us to save a few bytes in the size of the struct.
2021-09-16 17:17:13 +02:00
Brian Gianforcaro 9956607283 Kernel+LibC: Pack SC_accept4_params struct tighter
Flagged by pvs-studio, ordering the members from largest to smallest
allows us to save a few bytes in the size of the struct.
2021-09-16 17:17:13 +02:00
Brian Gianforcaro b45ca5d56e Kernel+LibC: Pack SC_inode_watcher_add_watch_params struct better
Flagged by pvs-studio, ordering the members from largest to smallest
allows us to save a few bytes in the size of the struct.
2021-09-16 17:17:13 +02:00
Liav A 8d0dbdeaac Kernel+Userland: Introduce a new way to reboot and poweroff the machine
This change removes the halt and reboot syscalls, and create a new
mechanism to change the power state of the machine.
Instead of how power state was changed until now, put a SysFS node as
writable only for the superuser, that with a defined value, can result
in either reboot or poweroff.
In the future, a power group can be assigned to this node (which will be
the GroupID responsible for power management).

This opens an opportunity to permit to shutdown/reboot without superuser
permissions, so in the future, a userspace daemon can take control of
this node to perform power management operations without superuser
permissions, if we enforce different UserID/GroupID on that node.
2021-09-12 11:52:16 +02:00
TheFightingCatfish a81b21c1a7 Kernel+LibC: Implement fsync 2021-09-12 11:24:02 +02:00
Liav A 04ba31b8c5 Kernel+Userland: Remove loadable kernel moduless
These interfaces are broken for about 9 months, maybe longer than that.
At this point, this is just a dead code nobody tests or tries to use, so
let's remove it instead of keeping a stale code just for the sake of
keeping it and hoping someone will fix it.

To better justify this, I read that OpenBSD removed loadable kernel
modules in 5.7 release (2014), mainly for the same reason we do -
nobody used it so they had no good reason to maintain it.
Still, OpenBSD had LKMs being effectively working, which is not the
current state in our project for a long time.
An arguably better approach to minimize the Kernel image size is to
allow dropping drivers and features while compiling a new image.
2021-09-11 19:05:00 +02:00
Linus Groh f646d49ac1 Kernel: Add _SC_HOST_NAME_MAX 2021-09-11 00:28:39 +02:00
Rodrigo Tobar a0ac5c5fc2 Kernel: Define INADDR_BROADCAST constant
This is required by some programs, notably python's socket module, which
fails to compile without this definition.
2021-09-09 11:33:45 +02:00
Andreas Kling 4b4e1d1c90 Kernel: Remove redundant [[nodiscard]] on KResult return values
Both KResult and KResultOr are [[nodiscard]] at the class level,
so there's no need to have functions return `[[nodiscard]] KResult`.
2021-09-07 01:18:02 +02:00
Andreas Kling e1af24eac8 Kernel: Make KResult usable with TRY() as well
This patch adds release_error() and release_value() to KResult, making
it usable with TRY().

Note that release_value() returns void, since there is no value inside
a KResult.
2021-09-05 14:50:52 +02:00
Andreas Kling e1da3b1841 Kernel: Make KResult pull in the TRY macro 2021-09-05 14:08:12 +02:00
Andreas Kling fd44336ef8 Kernel: Add KResultOr::release_error()
This is just for symmetry with AK::Result, so that we can use them
interchangeably in generic code.
2021-09-05 13:29:06 +02:00
sin-ack 566c5d1e99 AK+Kernel: Move KResult.h to Kernel/API for userspace access
This commit moves the KResult and KResultOr objects to Kernel/API to
signify that they may now be freely used by userspace code at points
where a syscall-related error result is to be expected. It also exposes
KResult and KResultOr to the global namespace to make it nicer to use
for userspace code.
2021-09-05 12:54:48 +02:00
Andreas Kling 4226b662cd Kernel+Userland: Remove global futexes
We only ever use private futexes, so it doesn't make sense to carry
around all the complexity required for global (cross-process) futexes.
2021-08-17 01:21:47 +02:00
Itamar f3aa87c436 Kernel: Make makedev()/minor()/major() static
This was originally done in 7274037 and for some reason reverted in
740140a.

This avoids "multiple definitions" link errors and fixes the libuv port.
2021-08-16 23:26:52 +02:00
Andreas Kling 1b739a72c2 Kernel+Userland: Remove chroot functionality
We are not using this for anything and it's just been sitting there
gathering dust for well over a year, so let's stop carrying all this
complexity around for no good reason.
2021-08-15 12:44:35 +02:00
Kenneth Myhra cb10c62327 LibC: Add SOCK_RDM and SOCK_SEQPACKET to socket.h 2021-08-14 22:32:00 +01:00
Kenneth Myhra 3875e8bd4b LibC: Add IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP to netin/in.h 2021-08-14 22:32:00 +01:00
Andreas Kling e1273a8ff7 Kernel+LibC: Share definitions for sys/statvfs.h 2021-08-14 19:58:11 +02:00
Andreas Kling dfd78b75d8 Kernel+LibC: Share definitions for sched.h 2021-08-14 19:58:11 +02:00
Andreas Kling c9a5d83ccc Kernel+LibC: Share definitions for sys/uio.h 2021-08-14 19:58:11 +02:00
Andreas Kling 37e98a55b7 Kernel+LibC: Share definitions for sys/ptrace.h 2021-08-14 19:58:11 +02:00
Andreas Kling 6b6eca0631 Kernel+LibC: Share definitions for sys/time.h 2021-08-14 19:58:11 +02:00
Andreas Kling 35b52338bb Kernel+LibC: Share definitions for sys/times.h 2021-08-14 19:58:11 +02:00
Andreas Kling 808ce594db Kernel+LibC: Share definitions for stdio.h 2021-08-14 19:58:11 +02:00
Andreas Kling 9c2212a60a Kernel+LibC: Share definitions for unistd.h 2021-08-14 19:58:11 +02:00
Andreas Kling d33b43276c Kernel+LibC: Share definitions for poll.h 2021-08-14 19:58:11 +02:00
Andreas Kling d794ed1de7 Kernel+LibC: Share definitions for utsname.h 2021-08-14 19:58:11 +02:00
Andreas Kling c65a735d71 Kernel+LibC: Share definitions for dirent.h 2021-08-14 19:58:11 +02:00
Andreas Kling 77c2c0f620 Kernel+LibC: Share definitions for serenity.h 2021-08-14 19:58:11 +02:00
Andreas Kling 6f78377864 Kernel+LibC: Share definitions for sys/wait.h 2021-08-14 19:58:11 +02:00
Andreas Kling 661bd992b0 Kernel+LibC: Share definitions for net/{if,if_arp,route}.h 2021-08-14 19:58:11 +02:00
Andreas Kling ff50122dc5 Kernel+LibC: Share definitions for futex.h 2021-08-14 19:58:11 +02:00
Andreas Kling 6fd7212476 Kernel+LibC: Share definitions for signal.h 2021-08-14 19:58:11 +02:00
Andreas Kling 9dc1350177 Kernel+LibC: Share definitions for netinet/in.h 2021-08-14 19:58:11 +02:00
Andreas Kling b92e6b02e5 Kernel+LibC: Share definitions for sys/socket.h and sys/un.h 2021-08-14 19:58:11 +02:00
Andreas Kling d277cdfd4c Kernel+LibC: Share definitions for termios.h 2021-08-14 19:58:11 +02:00
Andreas Kling a8d1c2dde9 Kernel+LibC: Share definitions for sys/mman.h 2021-08-14 19:58:11 +02:00
Andreas Kling 0a78056453 Kernel+LibC: Share definitions for time.h and sys/stat.h 2021-08-14 19:58:11 +02:00
Andreas Kling 740140a661 Kernel+LibC: Share definitions in fcntl.h and sys/types.h
This patch begins the work of sharing types and macros between Kernel
and LibC instead of duplicating them via the kludge in UnixTypes.h.

The basic idea is that the Kernel vends various POSIX headers via
Kernel/API/POSIX/ and LibC simply #include's them to get the macros.
2021-08-14 19:58:11 +02:00
Andreas Kling 4657c79143 Kernel+LibC: Add sys$perf_register_string()
This syscall allows userspace to register a keyed string that appears in
a new "strings" JSON object in profile output.

This will be used to add custom strings to profile signposts. :^)
2021-08-12 00:03:39 +02:00
Andreas Kling b7dae4f90e Kernel: Add CLOCK_MONOTONIC_COARSE to the kernel time page
This allows clock_gettime(CLOCK_MONOTONIC_COARSE) without syscalls.
Core::EventLoop takes advantage of this automatically. :^)
2021-08-10 21:51:05 +02:00
Andreas Kling aaead6f332 Kernel: Only expose CLOCK_REALTIME_COARSE via the kernel time page
Non-COARSE clock sources may probably still require a syscall.
2021-08-10 21:51:05 +02:00
Andreas Kling fdfc66db61 Kernel+LibC: Allow clock_gettime() to run without syscalls
This patch adds a vDSO-like mechanism for exposing the current time as
an array of per-clock-source timestamps.

LibC's clock_gettime() calls sys$map_time_page() to map the kernel's
"time page" into the process address space (at a random address, ofc.)
This is only done on first call, and from then on the timestamps are
fetched from the time page.

This first patch only adds support for CLOCK_REALTIME, but eventually
we should be able to support all clock sources this way and get rid of
sys$clock_gettime() in the kernel entirely. :^)

Accesses are synchronized using two atomic integers that are incremented
at the start and finish of the kernel's time page update cycle.
2021-08-10 19:21:16 +02:00
Andreas Kling 595ed59eb7 Kernel: Alphabetize the syscall list 2021-08-10 13:01:39 +02:00
Andreas Kling fa64ab26a4 Kernel+UserspaceEmulator: Remove unused sys$gettimeofday()
Now that LibC uses clock_gettime() to implement gettimeofday(), we can
get rid of this entire syscall. :^)
2021-08-10 13:01:39 +02:00
Idan Horowitz 9d21c79671 Kernel: Disable big process lock for sys$sync
This syscall doesn't touch any intra-process shared resources and only
calls VirtualFileSystem::sync, which is self-locking.
2021-08-07 15:30:26 +02:00