Commit Graph

3546 Commits

Author SHA1 Message Date
Andreas Kling
05e08afcd8 IPCCompiler: Generate getters for message ID's and message names
Each endpoint namespace will have an enum class MessageID where you can
find all of its messages.
2019-08-03 16:19:14 +02:00
Andreas Kling
fae3091999 IPCCompiler: Typedef the response message types as "ResponseType"
Each message will now have a typedef called ResponseType as an alias
for the expected response type. This will aid in implementing the sync
messaging code.
2019-08-03 16:06:40 +02:00
Andreas Kling
016335edde IPCCompiler: Generate endpoint and message classes
These are not entirely finished but it's starting to take shape. :^)
2019-08-03 15:50:16 +02:00
Andreas Kling
a40e763b2a LibIPC: Start fleshing out a separate IPC library
This will be a place to put object serialization/deserialization logic,
message parsing, endpoint management, etc.
2019-08-03 15:29:40 +02:00
Andreas Kling
aa8a3d4a89 IPCCompiler: Start working on a simple IPC definition language
Instead of doing everything manually in C++, let's do some codegen.
This patch adds a crude but effective IPC definition parser, along
with two initial definition files for the AudioServer's client and
server endpoints.
2019-08-03 15:17:41 +02:00
Andreas Kling
c5903ec4bb AK: Remove two redundant RefPtr constructors.
We already have constructors for "const T*" and "const T&" so we don't
need to have non-const variants.
2019-08-03 14:16:05 +02:00
Andreas Kling
69281c22d4 FontEditor(UI): Update the groupbox to have the right background color 2019-08-03 11:39:34 +02:00
Andreas Kling
47511b5930 GWidget: Implement set_backcolor() and set_forecolor()
These are set-color-from-string variants used by the VisualBuilder's
code generator.
2019-08-03 11:35:10 +02:00
Andreas Kling
54c77cb714 GVariant: Try to do color string parsing in GVariant::to_color()
If the underlying variant type is a String, try to parse out a color
when to_color() is called.

This makes VisualBuilder apply the saved colors when loading forms.
2019-08-03 11:34:02 +02:00
Andreas Kling
e43b27a3fa LibDraw: Add Color::from_string(StringView)
This parses hex colors in either #RRGGBBAA or #RRGGBB format.
No other formats are supported at the moment.
2019-08-03 11:33:34 +02:00
Andreas Kling
f511421aaa Kernel+ProcessManager: Add some more info to /proc/PID/fds
- "seekable": whether the fd is seekable or sequential.
- "class": which kernel C++ class implements this File.
- "offset": the current implicit POSIX API file offset.
2019-08-03 08:42:40 +02:00
Andreas Kling
7f25959fa2 LibCore: Make get_current_user_home_path() return String & close passwd
This API was returning a "const char*" and it was unclear who took care
of the underlying memory. Returning a String makes that obvious.

Also make sure we close the /etc/passwd file when we're done with it.
2019-08-03 08:32:07 +02:00
Andreas Kling
8a703c0076 ProcessManager: Add a new per-proces "open files" view showing open FDs
This uses the data from /proc/PID/fds with ease now that it's JSON. :^)
2019-08-03 08:26:45 +02:00
Conrad Pankoff
45c5a91afc Piano: Add mouse support for playing notes
Fixes #332
2019-08-03 07:59:41 +02:00
rhin123
c02868f000 LibGUI: Allow setting window icon before show(). 2019-08-02 21:18:21 +02:00
Andreas Kling
33b0c4cfaf LibAudio: Explicitly ignore IPC postprocessing requests
We don't need to do any IPC postprocessing in LibAudio (yet.)
This is the mechanism used by LibGUI to do repaint coalescing etc.
2019-08-02 19:57:30 +02:00
Andreas Kling
7c7343de98 Kernel: mount() should fail if the provided device is not a disk device
In the future, we should allow mounting any block device. At the moment
there is too much filesystem code that depends on the underlying device
being a DiskDevice.
2019-08-02 19:31:59 +02:00
Andreas Kling
a6fb055028 Kernel: Generalize VFS metadata lookup and use it in mount() and stat()
Refactored VFS::stat() into VFS::lookup_metadata(), which can now be
used for general VFS metadata lookup by path.
2019-08-02 19:28:18 +02:00
Andreas Kling
ae4d707684 Kernel: Align the KResult value storage appropriately.
We should figure out how to convert this code to using AK::Result.
2019-08-02 19:22:48 +02:00
Andreas Kling
31de5dee26 Kernel: Some improvements to the mount syscall
- You must now have superuser privileges to use mount().
- We now verify that the mount point is a valid path first, before
  trying to find a filesystem on the specified device.
- Convert some dbgprintf() to dbg().
2019-08-02 19:03:50 +02:00
Andreas Kling
c76668644b Build: Add /dev/{hda,hdb,hdc,hdd} files
Now that we can mount additional hard drives, let's actually have some
more device files in /dev so you can use them. :^)
2019-08-02 18:33:00 +02:00
Jesse
401c87a0cc Kernel: mount system call (#396)
It is now possible to mount ext2 `DiskDevice` devices under Serenity on
any folder in the root filesystem. Currently any user can do this with
any permissions. There's a fair amount of assumptions made here too,
that might not be too good, but can be worked on in the future. This is
a good start to allow more dynamic operation under the OS itself.

It is also currently impossible to unmount and such, and devices will
fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on
getting `umount` done ASAP to rectify this (as well as working on less
assumption-making in the mount syscall. We don't want to just be able
to mount DiskDevices!). This could probably be fixed with some `-t`
flag or something similar.
2019-08-02 15:18:47 +02:00
Andreas Kling
3f91d2d0cc CEventLoop: Devirtualize take_pending_events_from(CEventLoop) 2019-08-02 13:58:55 +02:00
Bobby Raduloff
0b94f9c236 Meta: Added instructions for WSL in the README. (#399) 2019-08-02 13:57:14 +02:00
Andreas Kling
fe25426ee4 AK: Simplify RefPtr and NonnullRefPtr's leak_ref() functions
Use AK::exchange() to switch out the internal storage. Also mark these
functions with [[nodiscard]] to provoke an compile-time error if they
are called without using the return value.
2019-08-02 12:05:09 +02:00
Andreas Kling
15866714da AK: Add anti-null assertions in RefPtr.
This gives us better error messages when dereferencing null RefPtrs.
2019-08-02 12:00:43 +02:00
Andreas Kling
cbc1272810 AK: Fix ref leaks in RefPtr assignment operators.
Many of the RefPtr assignment operators would cause ref leaks when we
call them to assign a pointer that's already the one kept.
2019-08-02 11:56:55 +02:00
Andreas Kling
06f82901b7 AK: Explicitly delete NonnullRefPtr::operator=(RefPtr).
This gives us much better error messages when you try to use them.
Without this change, it would complain about the absence of functions
named ref() and deref() on RefPtr itself. With it, we instead get a
"hey, this function is deleted" error.

Change operator=(T&) to operator=T(const T&) also, to keep assigning
a const T& to a NonnullRefPtr working.
2019-08-02 11:51:28 +02:00
Andreas Kling
6db879ee66 AK: Fix ref leak in NonnullRefPtr::operator=(T&).
We would leak a ref when assigning a T& to a NonnullRefPtr that already
contains that same T.
2019-08-02 11:35:05 +02:00
Andreas Kling
d9cc3e453c AK: Add assertions when dereferencing an OwnPtr.
This will make it immediately obvious what the problem is when you're
dereferencing a null OwnPtr.
2019-08-02 10:34:40 +02:00
Andreas Kling
a9a1a5dfa9 AK: Add a test for iterating a HashTable during clear (should assert)
Ideally we should also verify that the assertion actually happens,
but we need some support in the TestSuite framework for that.
2019-08-02 09:25:35 +02:00
Andreas Kling
6560116b67 TestSuite: Hijack the ASSERT macros during unit tests.
Instead of aborting the program when we hit an assertion, just print a
message and keep going.

This allows us to write tests that provoke assertions on purpose.
2019-08-02 09:23:03 +02:00
Andreas Kling
31793b8f3a AK: Fix typo in the WeakPtr test. Behavior was actually correct.
Also remove an unused variable.
2019-08-02 09:21:42 +02:00
Andreas Kling
4e59300650 AK: Fix typo in TestVector.cpp, oops. 2019-08-02 08:59:26 +02:00
Andreas Kling
5e01ebfc56 Kernel: Clean up thread stacks when a thread dies
We were forgetting where we put the userspace thread stacks, so added a
member called Thread::m_userspace_thread_stack to keep track of it.

Then, in ~Thread(), we now deallocate the userspace, kernel and signal
stacks (if present.)

Out of curiosity, the "init_stage2" process doesn't have a kernel stack
which I found surprising. :^)
2019-08-01 20:17:12 +02:00
Andreas Kling
3ad6ae1842 Kernel: Delete non-main threads immediately after finalizing them
Previously we would wait until the whole process died before actually
deleting its threads.
2019-08-01 20:01:23 +02:00
Andreas Kling
55d6efd485 Scheduler: Fix bitrotted SCHEDULER_RUNNABLE_DEBUG code
The runnable lists have moved from Thread to Scheduler.
2019-08-01 20:00:56 +02:00
Andreas Kling
09cd3a7a07 Scheduler: Fix deadlock when first scheduling candidate being inspected
Somewhat reproducible by opening ProcessManager and trying to view the
stacks for WindowServer.

Regressed in 53262cd08b.
2019-08-01 19:33:36 +02:00
Andreas Kling
38c80d5e6d LibHTML: Make some use of Vector::empend(). 2019-08-01 16:50:15 +02:00
Andreas Kling
8b34b1222b ProcFS: Make some use of Vector::empend(). 2019-08-01 16:34:02 +02:00
Andreas Kling
4afafeae50 Ext2FS: Make some use of Vector::empend(). 2019-08-01 16:31:05 +02:00
Andreas Kling
9230b42f28 AK: Use Vector::empend() a bit in the unit tests, and fix a bug.
There was a bug in the "prepend_vector_object" test but it was masked
by us not printing failures. (The bug was that we were adding three
elements to the "objects" vector and then checking that another
vector called "more_objects" indeed had three elements. Oops!)
2019-08-01 16:24:31 +02:00
Andreas Kling
8434548f14 TestSuite: Actually print failed comparions.. :^) 2019-08-01 16:22:50 +02:00
Andreas Kling
eeff0cd570 AK: Don't allow constructing an OwnPtr from a const NonnullOwnPtr&
OwnPtr's must move around, they can't be copy constructed.
2019-08-01 15:46:18 +02:00
Andreas Kling
79ce75d862 AK: Add Vector::empend().
This is a complement to append() that works by constructing the new
element in-place via placement new and forwarded constructor arguments.

The STL calls this emplace_back() which looks ugly, so I'm inventing
a nice word for it instead. :^)
2019-08-01 15:35:45 +02:00
Andreas Kling
f4bae8971c Documentation: Add a paragraph about NonnullOwnPtr to SmartPointers.md 2019-08-01 14:35:50 +02:00
Andreas Kling
1c50dce7d2 SystemServer: Remove always-true "if (pid == 0)" check
This code should probably be structured differently to handle things
like children dying, etc. But not right now.

Found by PVS-Studio.
2019-08-01 14:08:43 +02:00
Andreas Kling
673a98258b GDirectoryModel: Fix redundant identical comparison.
Found by PVS-Studio.
2019-08-01 14:01:37 +02:00
Andreas Kling
ab8891c064 LibCore: Initialize pid/id variables in CoreIPC{Client,Server}
Also rename CoreIPCServer::m_pid to m_client_pid for clarification.

Found by PVS-Studio.
2019-08-01 11:42:30 +02:00
Andreas Kling
4271bebbef more: Don't printf(string), printf("%s", string)!
Found by PVS-Studio.
2019-08-01 11:39:41 +02:00