Commit graph

31829 commits

Author SHA1 Message Date
Idan Horowitz
6e2a82df13 Kernel: Port File to RefCounted
Since RefCounted automatically calls a method named `will_be_destoyed`
on classes that have one, so there's no need to have a custom
implementation of unref in File.
2021-12-29 12:04:15 +01:00
Idan Horowitz
4a3a947df3 Kernel: Rename File::{before_removing => will_be_destroyed}
This will allow File and it's descendants to use RefCounted instead of
having a custom implementation of unref. (Since RefCounted calls
will_be_destroyed automatically)

This commit also removes an erroneous call to `before_removing` in
AHCIPort, this is a duplicate call, as the only reference to the device
is immediately dropped following the call, which in turns calls
`before_removing` via File::unref.
2021-12-29 12:04:15 +01:00
Idan Horowitz
d7ec5d042f Kernel: Port Process to ListedRefCounted 2021-12-29 12:04:15 +01:00
Idan Horowitz
3d0b5efcfc Kernel: Remove Process::all_processes()
This was only used in ProcFS, which can use the `processes()` list just
as well, so let's remove it.
2021-12-29 12:04:15 +01:00
Idan Horowitz
81e23617d6 Kernel: Port Custody to ListedRefCounted
Custody's unref is one of many implementions of ListedRefCounted's
behaviour in the Kernel, which results in avoidable bugs caused by
the fragmentation of the implementations. This commit starts the work
of replacing all custom implementations with ListedRefCounted by
porting Custody to it.
2021-12-29 12:04:15 +01:00
Idan Horowitz
be91b4fe3e Kernel: Support Mutex Protected lists in ListedRefCounted
This will allow us to support Mutex Protected lists like the custodies
list as well.
2021-12-29 12:04:15 +01:00
Linus Groh
7204b292c5 LibJS: Implement and use the MakeMethod AO
Two direct uses of the set_home_object() setter remain, we should fix
those up and remove it eventually.
2021-12-29 10:34:34 +01:00
Linus Groh
df931e6a83 LibJS: Implement and use the InitializeBoundName AO 2021-12-29 10:34:28 +01:00
Linus Groh
ca48151147 LibJS: Add spec comments to VM::binding_initialization() 2021-12-29 10:34:23 +01:00
Linus Groh
3626a7fd6d LibJS: Remove unused FunctionEnvironment this value getter/setter
The this value is only supposed to be set via the BindThisValue and
accessed via the GetThisBinding AOs, so exposing a direct getter/setter
would only lead to potentially non-spec-compliant behavior down the
line.
2021-12-29 00:16:51 +01:00
Linus Groh
451149df0b LibJS: Ensure get_new_target() never returns an empty value
Also add spec comments and remove a redundant exception check while
we're here :^)
2021-12-29 00:16:51 +01:00
Linus Groh
8d70a50aed LibJS: Remove unused MemberExpression::computed_property_name() 2021-12-29 00:16:51 +01:00
Peter Elliott
23e09eb7f4 less: Handle tabs in line wrapping
Before tabs were treated as a width of 1, which would cause issues with
man page headers.
2021-12-29 00:00:02 +01:00
Peter Elliott
20a0572de8 Userland: Port less(1) to LibMain 2021-12-29 00:00:02 +01:00
Peter Elliott
6312742257 less: Remove all formatting before printing status line 2021-12-29 00:00:02 +01:00
Peter Elliott
3677e88fb1 less: Dynamically re-wrap lines on resize
This change moves from wrapping lines at the start to operating on whole
lines and wrapping them as needed.

This has a few added benefits:
- line numbers are now always accurate.
- going to a line actually works
2021-12-29 00:00:02 +01:00
TheGrizzlyDev
2905642550 Magnifier: Add colorblind preview options
Add the same preview options as the theme editor so you can test the
accessibility of anything on your desktop. Both tools share the same
shortcuts.
2021-12-28 23:59:56 +01:00
Lady Gegga
7f61d430e6 Base: Add Tifinagh characters to font Katica Regular 10
2D30-2D7F https://www.unicode.org/charts/PDF/U2D30.pdf
2021-12-28 23:40:35 +01:00
Kenneth Myhra
7772309169 LibCore+chown: Return ErrorOr<Optional<...>> for getgrnam and getpwnam
This patch returns an empty Optional<...> instead of an Error for
Core::System::getgrname and Core::System::getpwnam if we can't find a
matching group or user entry.

It also updates the 'chown' utility to support this new behavior.
2021-12-28 23:23:54 +01:00
Maciej
ab324c1dae ImageViewer: Change how scaling works
- Store scale as a (float) factor (not as %)
- Make scaling exponential so that matches PixelPaint and another
image viewers/editors/etc
2021-12-28 23:23:09 +01:00
Stephan Unverwerth
1c3a82d59e Profiler: Extract percentage gradient calculation into its own file 2021-12-28 23:17:24 +01:00
Stephan Unverwerth
ddccf451a9 Profiler: Make everything east-const :^) 2021-12-28 23:17:24 +01:00
Stephan Unverwerth
cf8427b7b4 Profiler: Add source code view
This adds a new view mode to profiler which displays source lines and
samples that occured at those lines. This view can be opened via the
menu or by pressing CTRL-S.

It does this by mapping file names from DWARF to "/usr/src/serenity/..."
i.e. source code should be copied to /usr/src/serenity/Userland and
/usr/src/serenity/Kernel to be visible in this mode.

Currently *all* files contributing to the selected function are loaded
completely which could be a lot of data when dealing with lots of
inlined code.
2021-12-28 23:17:24 +01:00
Owen Smith
e6df1c9988 Kernel: Implement and use the syscall/sysret instruction pair on x86_64 2021-12-28 23:15:38 +01:00
Owen Smith
d36c84c331 Kernel: Reorder the 64-bit GDT a bit
Add a kernel data segment and make the user code segment come after
the data segment. We need the GDT to be in a certain order to support
the syscall and sysret instruction pair.
2021-12-28 23:15:38 +01:00
Guilherme Goncalves
33b78915d3 Kernel: Propagate overflow errors from Memory::page_round_up
Fixes #11402.
2021-12-28 23:08:50 +01:00
Idan Horowitz
11599a3342 pls: Stop on first non option when parsing arguments
This allows using pls on a program with arguments more ergonomically,
e.g. `pls -- echo "hello friends"` can now simply be done as:
`pls echo "hello friends"`.
2021-12-28 22:03:33 +02:00
Andreas Kling
987b5adf2a Kernel: Remove old comment about kmalloc() being Q&D :^)
We've finally gotten kmalloc to a point where it feels decent enough
to drop this comment.

There's still a lot of room for improvement, and we'll continue working
on it.
2021-12-28 21:02:38 +01:00
Andreas Kling
9dffcc9752 Kernel: VERIFY that addresses passed to kfree_sized() look valid
Let's do some simple pointer arithmetic to verify that the address being
freed is at least within one of the two valid kmalloc VM ranges.
2021-12-28 21:02:38 +01:00
Andreas Kling
9111376d70 Kernel: Rename kmalloc_pool_heap => initial_kmalloc_memory 2021-12-28 21:02:38 +01:00
Andreas Kling
ac7ce12123 Kernel: Remove the kmalloc_eternal heap :^)
This was a premature optimization from the early days of SerenityOS.
The eternal heap was a simple bump pointer allocator over a static
byte array. My original idea was to avoid heap fragmentation and improve
data locality, but both ideas were rooted in cargo culting, not data.

We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting
the rest.

This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-28 21:02:38 +01:00
Andreas Kling
a1be135891 Kernel: Lock socket mutex across {get,set}sockopt() and SO_ERROR updates
Since a socket can be accessed by multiple threads concurrently, we need
to protect shared data behind the socket mutex.

There's very likely more places where we need to fix this, the purpose
of this patch is to fix a VERIFY() failure in getsockopt() seen on CI.
2021-12-28 18:52:38 +01:00
Daniel Bertalan
4e1898df99 UserspaceEmulator: Exclude special ranges from RangeAllocator
If we do not mark these ranges as reserved, RangeAllocator might later
give us addresses that overlap these, which then causes an assertion
failure in the SoftMMU.  This behavior led to recurring CI failures, and
sometimes made programs as simple as `/bin/true` fail.

Fixes "Crash 1" reported in #9104
2021-12-28 19:28:13 +02:00
ryanb-dev
979f300337 LibVT: Handle window resize after history overflow
Addresses an issue in which a window resize event after history
overflow would cause the Terminal to crash due to a failed assertion.

The problematic assertion was removed and the logic updated to
support inserting lines even when the start of the history is at an
offset (due to an overflow).

Resolves #10987
2021-12-28 20:28:58 +03:30
TheGrizzlyDev
ebaf211260 ThemeEditor: Implement a way to simulate color blindness in preview
Implement a mechanism that allows us to alter colors so that they
mimic those a colorblind person would see. From the color we can then
alter the colors for the whole preview so we can simulate everything
in the theme including icons/decorations.

This filter is also available as a Filter in LibGfx so it can be
reused in multiple other places.

The color simulation algorithm is based on this one
https://github.com/MaPePeR/jsColorblindSimulator publicly available.
2021-12-28 17:10:44 +01:00
Linus Groh
1c05d39abc LibJS: Also throw exception when returning throw completion from await
...for now - the reason being that the AST breaks 'completion bubbling'
and returns a plain Value, and code at the call site relies on the VM
having an exception set when converting the plain value back into a
completion.

Fixes #11301.
2021-12-28 14:48:32 +01:00
Andreas Kling
416b0374fb Kernel: Fix race condition in TmpFSInode::notify_watchers()
We were doing this dance in notify_watchers():

    set_metadata_dirty(true);
    set_metadata_dirty(false);

This was done in order to force out inode watcher events immediately.
Unfortunately, this was racy, as if SyncTask got scheduled at the wrong
moment, it would try to flush metadata for a clean inode. This then got
trapped by the VERIFY() statement in Inode::sync_all():

    VERIFY(inode.is_metadata_dirty());

This patch fixes the issue by replacing notify_watchers() with lazy
metadata notifications like all other filesystems.
2021-12-28 13:00:28 +01:00
Andreas Kling
b24dc84ad9 Meta: Add SSE3, SMAP and SMEP to our bochsrc
- SSE3 makes LibM's trunc() not SIGILL (due to FISTTP).
- SMAP and SMEP allow us to exercise more kernel security mechanisms.
2021-12-28 11:51:50 +01:00
Maciej
6cfa58c7f3 HackStudio: Highlight AF files as INI 2021-12-28 11:36:12 +01:00
Maciej
00d1dbb95b TextEditor: Highlight AF files as INI 2021-12-28 11:36:12 +01:00
Brian Gianforcaro
ec21edb602 Ports: Update stress-ng port to 0.13.09
This change updates the port to the latest version, as part of that work
I basically reported the application, as we have added a lot of LibC
functionality which we were missing before. I've also updated the port
to mark stressor's we don't support as nops, instead of trying to avoid
compiling them at all. This will make the port much easier to maintain
in the future.
2021-12-28 11:00:51 +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
Brian Gianforcaro
fb8df01036 LibC: Add rindex() and index() APIs
These POSIX APIs are defined as mapping directly to
`strrchr` and `strchr` respectively.

These are needed for the latest version of the stress-ng port,
and also give us better POSIX compliance.
2021-12-28 11:00:51 +01:00
Brian Gianforcaro
c4b1e49036 LibC: Add alphasort() implementation
This is a POSIX API required for the latest stress-ng port.
2021-12-28 11:00:51 +01:00
Brian Gianforcaro
fa5d81be7a LibC: Add POSIX spec comments for dirent APIs 2021-12-28 11:00:51 +01:00
Daniel Bertalan
52beeebe70 Kernel: Remove the KString::try_create(String::formatted(...)) pattern
We can now directly create formatted KStrings with KString::formatted.

:^)
2021-12-28 01:55:22 -08:00
faxe1008
7d6058415e Taskbar: Add context menu to remove quicklaunch items
This change adds a context menu for each app button to remove items
from the quicklaunch section of the Taskbar.
2021-12-28 00:57:48 -08:00
faxe1008
c74afdde26 Taskbar: Add dropping of AppFiles to QuickLaunch
This change adds the capability to drop AppFiles to the quick launch
section of the Taskbar. All logic was moved to a new
QuickLaunchWidget.
2021-12-28 00:57:48 -08:00
Liav A
7e8beadd57 Kernel/Net: Move Realtek network adapters code to a separate directory 2021-12-28 00:56:47 -08:00