Commit graph

22808 commits

Author SHA1 Message Date
Max Wipfli fc6d051dfd AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.

To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
2021-06-30 11:13:54 +02:00
Max Wipfli 9b8f35259c AK: Remove the LexicalPath::is_valid() API
Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
2021-06-30 11:13:54 +02:00
Max Wipfli caa9daf59e AK: Use east const style in LexicalPath.{cpp,h} 2021-06-30 11:13:54 +02:00
Luke 37361821dd Kernel/PCI: Keep track of the currently mapped bus in MMIO mode
There is a check in map_bus_region to make sure we don't pointlessly
remap the bus region if the previous mapping was for the same bus.
This is tracked with `m_mapped_bus`.

However, nothing was actually updating `m_mapped_bus`, and it is
initialised to 0. This means that if we start with a device on bus 0,
the read in data will be valid. If we map say bus 1 then bus 0 again,
the map for bus 0 will now be ignored and invalid data will be read in.

Fixed by updating `m_mapped_bus` with the currently mapped bus.
2021-06-30 11:13:04 +02:00
Luke 02810f15b1 Kernel/PCI: Don't unmap determine_memory_mapped_bus_region after init
This can be accessed after init via lspci.
2021-06-30 11:12:44 +02:00
Max Wipfli 9f0ce2dc81 LibGUI: Add PasswordBox
This patch adds a PasswordBox. At the moment, it's simply a TextBox with
it's substitution code point set to '*', and the undo and redo actions
disabled.
2021-06-30 11:12:25 +02:00
Max Wipfli de67d86696 LibGUI: Add glyph substitution to TextEditor
This patch adds the member variable m_substitution_code_point to
GUI::TextEditor. If non-zero, all gylphs to be drawn will be substituted
with the specified code point. This is mainly needed to support a
PasswordBox.

While the primary use-case is for single-line editors, multi-line
editors are also supported.

To prevent repeated String construction, a m_substitution_string_data
members has been added, which is an OwnPtr<Vector<u32>>. This is used as
a UTF-32 string builder. The substitution_code_point_view method uses
that Vector to provide a Utf32View of the specified length.
2021-06-30 11:12:25 +02:00
Max Wipfli 37961bf7cb LibGUI: Fix double-clicking words in syntax-highlighted text
This patch fixes a bug where double-clicking on a word in a TextEditor
with syntax highlighting would also select an additional character after
the word. This also simplifies the logic for double- and
triple-clicking.
2021-06-30 11:12:25 +02:00
FalseHonesty 988e17ed05 LibVideo: Migrate to east-const style & apply other minor fixes
This patch brings all of LibVideo up to the east-const style in the
project. Additionally, it applies a few fixes from the reviews in #8170
that referred to older LibVideo code.
2021-06-30 11:03:51 +02:00
FalseHonesty 7d4053dde1 LibVideo/VP9: Implement most of block_mode_info methods (6.4.15-6.4.18) 2021-06-30 11:03:51 +02:00
FalseHonesty 42fdaa7f60 LibVideo/VP9: Implement most of inter_frame_mode_info (6.4.11-6.4.14) 2021-06-30 11:03:51 +02:00
FalseHonesty e687f05b42 LibVideo/VP9: Implement intra_frame_mode_info procedure (6.4.6) 2021-06-30 11:03:51 +02:00
FalseHonesty cc1a9e3d1c LibVideo/VP9: Add SAFE_CALL macro to help propagate failure state 2021-06-30 11:03:51 +02:00
FalseHonesty 741677b992 LibVideo/VP9: Refactor how TreeParser accesses decoder data
The TreeParser requires information about a lot of the decoder's
current state in order to parse syntax tree elements correctly, so
there has to be some communication between the Decoder and the
TreeParser. Previously, the Decoder would copy its state to the
TreeParser when it changed, however, this was a poor choice. Now,
the TreeParser simply has a reference to its owning Decoder, and
accesses its state directly.
2021-06-30 11:03:51 +02:00
FalseHonesty 375dbad144 LibVideo/VP9: Begin decoding VP9 blocks 2021-06-30 11:03:51 +02:00
FalseHonesty 2ce4155b42 LibVideo/VP9: Successfully parse partition syntax element 2021-06-30 11:03:51 +02:00
FalseHonesty 7ff6315246 LibVideo/VP9: Begin creating a tree parser to parse syntax elements 2021-06-30 11:03:51 +02:00
FalseHonesty cfd65eafa9 LibVideo/VP9: Begin decoding tiles 2021-06-30 11:03:51 +02:00
FalseHonesty f9899fc17f LibVideo/VP9: Parse compressed header data
This patch adds compressed header parsing to the VP9 decoder (section
6.4 of the spec). This is the final decoder step before we can start to
decode tiles.
2021-06-30 11:03:51 +02:00
Andrew Kaster e821b349b2 Kernel: Give Devices without a custody a less fake absoulte_path
This hack allows self-test mode run-tests-and-shutdown.sh to give
TestProcFs a stat(2)-able /proc/self/fd/0. For some reason, when
stdin is a SerialDevice, /proc/self/fd/0 will be a symlink to the device
as expected, but, calling realpath or stat on /proc/self/fd/0 will error
out. realpath will give the string from Device::absolute_path() which
would be something like "device:4,64 (SerialDevice)". When VFS is trying
to resolve_path so that we can stat the file, it would bail out on this
fake-y path.

Change the fake path (that doesn't show up when you ls a device, nor
when checking the devices tab in SystemMonitor) from the major/minor
device number and class_name() to /dev/device_name(). There's probably
a very hairy yak standing behind this issue that was only discovered due
to the ProcFS rework.
2021-06-30 12:07:57 +04:30
Andrew Kaster ae4240788c Userland: Unlink file after waiting for child in run-tests
TestProcFs expects to be able to stat its stdout and stderr. The new
ProcFS implemetnation properly forwards the symlinks for
/proc/pid/fd/[1,2] to the temporary file that we had unlinked prior to
spawning the process. However, this makes it so that a normal stat on
the symlink to that file fails (as expected). Move the unlink to after
we've waited on the child, so that we know it won't be trying any funny
business with its stdout/stderr anymore.
2021-06-30 09:39:57 +04:30
Andrew Kaster cc0a376c95 Base+Utilities: Add run-tests program to run system tests with LibTest
This test program heavily pulls from the JavaScriptTestRunner/test-js,
but with a twist. Instead of loading JavaScript files into the current
process, constructing a JS environment for them, and executing test
suites/tests directly, run-tests posix_spawns each test file.

Test file stdout is written to a temp file, and only dumped to console
if the test fails or the verbose option is passed to the program. Unlike
test-js, times are always printed for every test executed for better
visibility in CI.
2021-06-30 08:18:28 +04:30
Andrew Kaster 601c9e89de Userland+Tests: Split out generic test runner from JS TestRunner
Split out the functionality to gather multiple tests from the filesystem
and run them in turn into Test::TestRunner, and leave the JavaScript
specific test harness logic in Test::JS::TestRunner and friends.
2021-06-30 08:18:28 +04:30
Andrew Kaster 44a6715584 Tests: TestProcFs cannot assume stdin/stdout/stderr are the same
If someone runs the test with shell redirection going on, or in a way
that changes any of the standard file descriptors this assumption will
not hold. When running from a terminal normally, it is true however.

Instead, check that /proc/self/fd/[0,1,2] are symlinks, and can be
stat-d by verifying that both stat and lstat succeed, and give different
struct stat contents.
2021-06-30 08:18:28 +04:30
Andrew Kaster 5e8a0c014e LibRegex: Make regex::Regex move-constructible and move-assignable
For some reason the default move constructor and default move-assign
operator were deleted, so we explicitly default them instead.
2021-06-30 08:18:28 +04:30
Andrew Kaster b15fe2b926 LibCore: Add getter for how many groups exist in a Core::ConfigFile
This can be used by an application to find out if any config sections
were loaded from the file after a reparse.
2021-06-30 08:18:28 +04:30
davidot fc9cc74555 LibJS: Handle the different realms case in ArraySpeciesCreate 2021-06-29 23:34:06 +01:00
Andreas Kling 384cffaa04 LibWeb: Fix build breakage after merging the oldish DOM inspector PR 2021-06-29 23:11:09 +02:00
Andreas Kling fd06b8b713 Kernel: ProcFS and SysFS component indices should be InodeIndex
This fixes the x86_64 kernel build. :^)
2021-06-29 23:07:02 +02:00
Adam Hodgen 1e5e02c70b LibWeb+Browser: Support DOM Inspector for OutOfProcessWebView
This introduces a new DOMTreeJSONModel, which provides the Model for the
InspectorWidget when the Browser is running using the
OutOfProcessWebView.

This Model is constructed with a JSON object received via IPC from the
WebContentServer.
2021-06-29 23:06:48 +02:00
Adam Hodgen cd6b9613c5 LibWeb+WebContent: Add IPC flow for Inspect DOM Tree
Add `inspect_dom_tree` to WebContentServer and 'did_get_dom_tree' to
WebContentClient.

These two async methods form a request & response for requesting a JSON
representation of the Content's DOM tree.
2021-06-29 23:06:48 +02:00
Adam Hodgen 4affe052b8 LibWeb: Add JSON serialization method to DOM::Node
This method builds a JSON object representing the full state of the
DOM tree.

The JSON that is built will be used for building the DOM Inspector
widget for the OutOfProcessWebView.
2021-06-29 23:06:48 +02:00
Ali Mohammad Pur f4eab69785 LibHTTP: Finish the request up on TLS connection finish
...unless it has already been done.
Otherwise we'd be spinning in RequestServer waiting for more read
events.
2021-06-30 01:23:25 +04:30
Max Wipfli 866244eec5 Meta: Add my emails to .mailmap 2021-06-30 00:59:23 +04:30
Andreas Kling bdc905ab93 Kernel: Make sure JSON blobs in core dumps are correctly terminated
I regressed this in 648480f715.
We have to make sure JsonObjectSerializer::finish() is called before
writing out the blob. This is done automatically when the serializer
is destroyed, so just wrap them in scopes.
2021-06-29 22:28:52 +02:00
ngc6302h e2187f2956 SoundPlayer: Don't limit duration inference to WAV files 2021-06-30 00:58:06 +04:30
ngc6302h 80dba466db FileIconProvider: Use sound icon for flac file extension 2021-06-30 00:58:06 +04:30
ngc6302h 595ba17cfa LaunchServer: Add flac file association to /bin/SoundPlayer 2021-06-30 00:58:06 +04:30
Andreas Kling 0dbf786aed Kernel+AK: Don't compile JSON parser into the kernel
The kernel doesn't consume JSON, it only produces it. So there's no
need for the kernel to have a JSON parser built into it. :^)
2021-06-29 22:19:29 +02:00
Andreas Kling 9766fccb88 Kernel: Remove some unnecessary JSON related includes 2021-06-29 22:11:10 +02:00
Andreas Kling 648480f715 Kernel: Use JsonObjectSerializer in the core dump generation code 2021-06-29 22:07:36 +02:00
Andreas Kling 8d0cc3adc5 Kernel: Don't create a JsonArray when generating /proc/cpuinfo 2021-06-29 21:47:20 +02:00
Ali Mohammad Pur 2665cdf2a1 LibGUI: Don't allocate a scope-local MouseEvent on the heap
This fixes the build by hiding the problem from the compiler, but it's
a useful change in and of itself anyway.
A malloc/free per every mouse event is pretty annoying, especially when
we can actually avoid it.
2021-06-29 21:40:41 +02:00
Liav A 1f98d7d638 Kernel/ProcFS: Tighten modified time value across the filesystem objects
It didn't make any sense to hardcode the modified time of all created
inodes with "mepoch", so we should query the procfs "backend" to get
the modified time value.
Since ProcFS is dynamically changed all the time, the modified time
equals to the querying time.
This could be changed if desired, by making the modified_time()
method virtual and overriding it in different procfs-backed objects :)
2021-06-29 20:53:59 +02:00
Liav A d79d9e833e Kernel/ProcFS: Tighten permissions on the exposed objects
This is needed so we properly set the limits for different objects in
the filesystem.
2021-06-29 20:53:59 +02:00
Liav A 47149e625f Kernel/ProcFS: Split code into more separate files
Instead of using one file for the entire "backend" of the ProcFS data
and metadata, we could split that file into two files that represent
2 logical chunks of the ProcFS exposed objects:
1. Global and inter-process information. This includes all fixed data in
the root folder of the ProcFS, networking information and the bus
folder.
2. Per-process information. This includes all dynamic data about a
process that resides in the /proc/PID/ folder.

This change makes it more easier to read the code and to change it,
hence we do it although there's no technical benefit from it now :)
2021-06-29 20:53:59 +02:00
Liav A 7c87891c06 Kernel: Don't copy a Vector<FileDescriptionAndFlags>
Instead of copying a Vector everytime we need to enumerate a Process'
file descriptions, we can just temporarily lock so it won't change.
2021-06-29 20:53:59 +02:00
Liav A 12b6e69150 Kernel: Introduce the new ProcFS design
The new ProcFS design consists of two main parts:
1. The representative ProcFS class, which is derived from the FS class.
The ProcFS and its inodes are much more lean - merely 3 classes to
represent the common type of inodes - regular files, symbolic links and
directories. They're backed by a ProcFSExposedComponent object, which
is responsible for the functional operation behind the scenes.
2. The backend of the ProcFS - the ProcFSComponentsRegistrar class
and all derived classes from the ProcFSExposedComponent class. These
together form the entire backend and handle all the functions you can
expect from the ProcFS.

The ProcFSExposedComponent derived classes split to 3 types in the
manner of lifetime in the kernel:
1. Persistent objects - this category includes all basic objects, like
the root folder, /proc/bus folder, main blob files in the root folders,
etc. These objects are persistent and cannot die ever.
2. Semi-persistent objects - this category includes all PID folders,
and subdirectories to the PID folders. It also includes exposed objects
like the unveil JSON'ed blob. These object are persistent as long as the
the responsible process they represent is still alive.
3. Dynamic objects - this category includes files in the subdirectories
of a PID folder, like /proc/PID/fd/* or /proc/PID/stacks/*. Essentially,
these objects are always created dynamically and when no longer in need
after being used, they're deallocated.
Nevertheless, the new allocated backend objects and inodes try to use
the same InodeIndex if possible - this might change only when a thread
dies and a new thread is born with a new thread stack, or when a file
descriptor is closed and a new one within the same file descriptor
number is opened. This is needed to actually be able to do something
useful with these objects.

The new design assures that many ProcFS instances can be used at once,
with one backend for usage for all instances.
2021-06-29 20:53:59 +02:00
Liav A 1baa05d6b2 Kernel/SysFS: Add PCI exposed folder 2021-06-29 20:53:59 +02:00
Liav A 0259781402 Ports: Fix dmidecode patches
Since we have a SysFS now, we can just let dmidecode to read the DMI
blobs from it.
2021-06-29 20:53:59 +02:00