Commit graph

1633 commits

Author SHA1 Message Date
Andreas Kling
2e6ab58117 LibGfx: Reduce header dependencies of StylePainter 2020-02-16 09:41:56 +01:00
Tibor Nagy
9041e95e79 LibGUI: Render ScrollBar buttons as pressed when they are being pressed 2020-02-16 09:41:40 +01:00
Tibor Nagy
fc24b2b57d LibGUI: Make ResizeCorner theme-aware 2020-02-16 08:01:20 +01:00
Shannon Booth
42399167b3 LibCore: Add DirIterator::next_full_path() 2020-02-16 02:19:22 +01:00
Andreas Kling
a356e48150 Kernel: Move all code into the Kernel namespace 2020-02-16 01:27:42 +01:00
Tibor Nagy
7ec1b2e44b LibGUI: Unfocused TextEditors should use inactive selection colors 2020-02-15 18:42:13 +01:00
Tibor Nagy
4d95163400 LibGUI: Use inactive selection colors from palette instead of hardcoding them 2020-02-15 18:42:13 +01:00
Tibor Nagy
99192fd29f LibGfx: Add inactive selection colors 2020-02-15 18:42:13 +01:00
Andreas Kling
d5e167e725 LibBareMetal: Install headers so ports can pick them up 2020-02-15 13:31:41 +01:00
Andreas Kling
a4d857e3c5 LibIPC+IPCCompiler: Add IPC::Decoder, let classes decode themselves
This shaves ~5 seconds off of a full build, not too bad. Also it just
seems nicer to push this logic out to classes. It could be better but
it's a start. :^)
2020-02-15 12:11:19 +01:00
Andreas Kling
2ae9a56c3f LibIPC: Move IPC::Encoder functions out of line
Compiling anything that includes generated IPC messages is painfully
slow at the moment. This moves the encoding helpers out of line, which
helps a bit. Doing the same for decoding will help more.
2020-02-15 12:10:48 +01:00
Andreas Kling
ef01af1cb2 LibIPC+IPCCompiler: Remove some unused members from generated messages 2020-02-15 12:10:48 +01:00
Shannon Booth
6764b77788 LibCore: Add SkipParentAndBaseDir flag in DirIterator
Sometimes we may want to iterate over dotfiles but not include the
parent or base directory
2020-02-15 11:40:05 +01:00
Shannon Booth
3879d75219 LibCore: Simplify some of DirIterator's code
The main changes are in advance_next() where we flatten some of the
nesting to improve readability
2020-02-15 11:40:05 +01:00
Andreas Kling
0e3a9d8e9d LibCore: Reduce header dependencies of EventLoop 2020-02-15 02:09:00 +01:00
Andreas Kling
b011ea9962 LibGUI: Reduce menu-related header dependencies 2020-02-15 01:56:30 +01:00
Andreas Kling
9e83bbe1cd LibGUI: Reduce header dependencies of GUI::Action 2020-02-15 01:34:00 +01:00
Andreas Kling
10ccc9e11c LibGUI: Don't leak every tooltip window ever :^) 2020-02-15 01:27:37 +01:00
Andreas Kling
dcb0766d3f LibGUI: Remove some header dependencies from Application.h 2020-02-15 01:18:32 +01:00
Andreas Kling
93e9c2732b LibGfx: Remove unused Bitmap::load_from_file() for loading raw RGBA
This was not used anywhere but added unnecessary members to Bitmap.
2020-02-15 01:06:32 +01:00
Andreas Kling
9c0c677d57 LibGfx: Reduce header dependencies of Bitmap and Font 2020-02-15 01:03:37 +01:00
Andreas Kling
34b5ff7c29 LibGfx: Move a bunch of LogStream::operator<< to cpp files 2020-02-15 00:58:54 +01:00
Andreas Kling
3866e0d4d4 LibCore: Move LogStream::operator<< overloads into cpp files 2020-02-15 00:58:52 +01:00
Andreas Kling
2a41bff329 LibCore: Remove a bunch of unnecessary forward declarations
Now that we get LibCore forward declarations from <LibCore/Forward.h>,
we don't need to declare things manually.
2020-02-15 00:32:33 +01:00
Andreas Kling
66903ad987 LibGfx: Remove Utf8View.h dependency from Font.h 2020-02-15 00:27:50 +01:00
Andreas Kling
e1ff4fa034 LibGUI: Remove more header dependencies from Widget.h 2020-02-15 00:24:14 +01:00
Andreas Kling
69400c2ca1 LibCore: Replace manual forward declarations with <LibCore/Forward.h> 2020-02-15 00:13:44 +01:00
Andreas Kling
6a3cd11a80 AK: Remove manual forward declarations with <AK/Forward.h> 2020-02-15 00:12:31 +01:00
Andreas Kling
a368cf7d51 LibGfx: Replace manual forward declarations with <LibGfx/Forward.h> 2020-02-15 00:10:34 +01:00
Andreas Kling
34c7322d77 LibGUI: Remove some header dependencies from Widget.h 2020-02-14 23:53:11 +01:00
Andreas Kling
08cae2773d LibGfx: More work on header dependency reduction 2020-02-14 23:33:21 +01:00
Andreas Kling
3fe2640c8c LibGfx: Add forward declaration header
This patch adds <LibGfx/Forward.h> with forward declarations for Gfx.
2020-02-14 23:31:18 +01:00
Andreas Kling
8f7333f080 LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to
shrink the header dependency graph.
2020-02-14 23:31:18 +01:00
Andreas Kling
3bbf4610d2 AK: Add a forward declaration header
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.

Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Andreas Kling
5884ef8425 LibGUI: Add missing Event.cpp file 2020-02-14 17:35:04 +01:00
Andreas Kling
814d59f462 LibGUI: Port the drag&drop code to Core::MimeData 2020-02-14 13:18:59 +01:00
Andreas Kling
3cba9c3c25 LibCore: Add Core::MimeData class
This object contains zero or more { mime_type, data } entries and will
be used for clipboard data as well as drag & drop.
2020-02-14 13:17:26 +01:00
Andreas Kling
2c14e46b96 LibGUI: Indicate ItemView drag acceptance with a little rectangle
If an index accepts a drag, we now draw a little rectangle around it
when the drag moves over it.
2020-02-13 21:50:50 +01:00
Andreas Kling
f0ae353c9e LibGUI: Allow dropping drags on AbstractView
You can now drop things on an AbstractView, which will ask its model if
the drag is acceptable to drop at the index where it's dropped.

If it's accepted by the model, the view will fire the on_drop hook.
2020-02-13 21:49:14 +01:00
Andreas Kling
8b3864c70a LibGUI: Have FileSystemModel accept url-list drags onto directories 2020-02-13 21:48:32 +01:00
Andreas Kling
6e7ca44dee LibGUI: Add GUI::Model::accepts_drag(index, data_type)
This allows a model to indicate whether it would accept a drag with a
given data type being dropped on a given index.
2020-02-13 21:45:46 +01:00
Andreas Kling
3ce80bec97 WindowServer+LibGUI: Add a "drag move" event
This allows windows/widgets to learn when something is being dragged
over them. They can then repaint themselves somehow to indicate that
they are willing to accept a drop.

Currently this is piggybacking somewhat on the mouse event mechanism
in WindowServer. I'm not sure that's the best design but it seemed
easier to do it this way right now.
2020-02-13 21:43:32 +01:00
Andreas Kling
f88fe5dc3f LibGUI: Don't assert when hovering spacing around single-child Splitter
Fixes #1215.
2020-02-13 20:00:01 +01:00
Andreas Kling
3e486f75ff AK: Move escape_html_entities() from LibHTML to AK
This sort of thing can be useful to things that don't want to link with
all of LibHTML.
2020-02-13 08:46:00 +01:00
Andreas Kling
90fec9c732 LibCore: Add "static bool Core::File::exists(filename)" 2020-02-12 21:17:00 +01:00
Andreas Kling
0cdf68f668 LibGUI: Always unhighlight table view column headers when cursor leaves
If the cursor left a table view column header while also pressing it,
we would keep the header highlighted. This was not consistent with how
regular buttons behaved.
2020-02-12 19:35:25 +01:00
Andreas Kling
29aee5e0d6 LibGUI: Make last auto-sized widget in a BoxLayout fill remaining space
Since space is divided evenly between widgets with SizePolicy::Fill,
we were sometimes ending up with a couple of unused pixels after the
last widget (due to rounding.)

Fix this by always giving the slack pixels at the end to the very last
auto-sized widget in the layout.

This fixes an issue where it was sometimes possible to click on an
"unreachable" part of a Splitter widget. :^)
2020-02-12 14:05:50 +01:00
Andreas Kling
5e42fe76d6 LibGUI: Use Core::DateTime in FileSystemModel 2020-02-11 20:43:32 +01:00
Andreas Kling
8f89cc85d1 LibCore: Add DateTime::from_timestamp(time_t) 2020-02-11 19:48:46 +01:00
Andreas Kling
b8cf83926a LibCore: Add a basic Core::DateTime class
This is just to have a pleasant way to print the current time for now:

    dbg() << Core::DateTime::now();

Or if you want it as a string:

    Core::DateTime::now().to_string();
2020-02-11 19:43:29 +01:00
Andreas Kling
29aa8373d4 LibC: Add localtime_r() 2020-02-11 19:36:59 +01:00
Andreas Kling
57e4410044 Revert "LibC: Remove isfoo() declarations from ctype.h"
This reverts commit 2ba06662b6.

This broke the toolchain build. Apparently libstdc++v3 depends on the
declarations of isfoo() helpers.
2020-02-11 19:36:47 +01:00
Andreas Kling
2ba06662b6 LibC: Remove isfoo() declarations from ctype.h
We'll keep the definitions in ctype.cpp so you can link against them
but there's no reason to have competing declarations and macros.
2020-02-11 17:41:16 +01:00
Andreas Kling
92e2afe584 LibGUI: Tweak C++ syntax highlighting colors a bit :^) 2020-02-11 13:07:21 +01:00
Andreas Kling
9a09437c46 LibGUI: Splitter should forget resize candidates after cursor leaves
Otherwise we'll keep highlighting the grabbable rect even after the
cursor has left the splitter widget.
2020-02-11 11:53:38 +01:00
Andreas Kling
8a605922bb LibGUI: Make splitters 1px wider as 3px is slightly too narrow 2020-02-11 11:53:38 +01:00
Andreas Kling
1fc887c576 LibGUI: Only highlight grabbable area between a Splitter's children
We were previously cheating by setting the entire splitter's background
color to the hover highlight color. This looked goofy whenever there
were transparent widgets inside a splitter, since the highlighted color
would shine through when hovering.

This was especially noticeable in SystemMonitor, which now looks much
better. :^)
2020-02-11 11:53:38 +01:00
Andreas Kling
3f58f0e87c LibGfx: Add Rect::operator!=(Rect) 2020-02-11 11:53:38 +01:00
Andreas Kling
f4fa758959 LibGUI: Add a Widget::did_layout() that gets called after layout
This will allow widgets to implement post-layout behaviors.
2020-02-11 11:53:38 +01:00
Andreas Kling
7aa62665a3 LibGUI: Factor out Splitter hit testing into a separate function 2020-02-11 11:53:38 +01:00
Shannon Booth
7b6d450b6a LibGfx: Assert that an empty bitmap is not created 2020-02-11 11:00:09 +01:00
Andreas Kling
7323d085dd LibGUI: Single-line GUI::TextEditor should not have "go to line" action 2020-02-10 19:49:49 +01:00
Andreas Kling
580a94bc44 Kernel+LibC: Merge sys$stat() and sys$lstat()
There is now only one sys$stat() instead of two separate syscalls.
2020-02-10 19:49:49 +01:00
Andreas Kling
3713d31750 LibCore: TCP and UDP servers should parent Notifiers to themselves
This makes things look a little more neat in Inspector. :^)
2020-02-10 14:15:56 +01:00
William McPherson
aa149b9330 LibAudio/Piano: Replace floats with doubles
We should default to double-precision so that clients can make the
choice to use float or double.
2020-02-10 14:04:27 +01:00
William McPherson
d55d2b2794 LibAudio/aplay: Handle WAV header errors properly
We shouldn't just ASSERT() if the header parse fails. This was crashing
Piano completely.
2020-02-10 14:04:27 +01:00
Andreas Kling
6cbd72f54f AK: Remove bitrotted Traits::dump() mechanism
This was only used by HashTable::dump() which I used when doing the
first HashTable implementation. Removing this allows us to also remove
most includes of <AK/kstdio.h>.
2020-02-10 11:55:34 +01:00
Liav A
7c4dd0c8cf LibELF: Use VirtualAddress class from LibBareMetal 2020-02-09 19:38:17 +01:00
Liav A
de3637d85f LibBareMetal: Add Memory definitions
Add classes of VirtualAddress & PhysicalAddress.
2020-02-09 19:38:17 +01:00
Liav A
2a699cec98 LibC: Apply a change for the Bootstrapper environment 2020-02-09 19:38:17 +01:00
Liav A
7c507c27bf LibBareMetal: Creating a new library for freestanding environments 2020-02-09 19:38:17 +01:00
Andreas Kling
67ccdbe384 LibCore: Add File::is_directory() helpers 2020-02-09 14:15:55 +01:00
Andreas Kling
3a7e49fe07 LibCore: Allow constructing a Core::HttpRequest from a raw HTTP request
This patch adds a very simple HTTP request parser that can be useful
for implementing say.. a web server. :^)
2020-02-09 14:15:55 +01:00
Andreas Kling
3b95d61b22 LibGfx: Naive RGB/HSV conversion 2020-02-08 12:30:12 +01:00
Andreas Kling
2b0b7cc5a4 Net: Add a basic sys$shutdown() implementation
Calling shutdown prevents further reads and/or writes on a socket.
We should do a few more things based on the type of socket, but this
initial implementation just puts the basic mechanism in place.

Work towards #428.
2020-02-08 00:54:43 +01:00
Andreas Kling
bb8e65be41 LibGUI+HackStudio: Move syntax highlighting from HackStudio to LibGUI
This patch introduces the GUI::SyntaxHighlighter class, which can be
attached to a GUI::TextEditor to provide syntax highlighting.

The C++ syntax highlighting from HackStudio becomes a new class called
GUI::CppSyntaxHighlighter. This will make it possible to get C++ syntax
highlighting in any app that uses a GUI::TextEditor. :^)

Sidenote: It does feel a bit weird having a C++ lexer in a GUI toolkit
library, and we'll probably end up moving this out to a separate place
as this functionality grows larger.
2020-02-07 20:07:15 +01:00
Andreas Kling
6a9cc66b97 LibGUI: Remove leading G from filenames 2020-02-06 20:33:02 +01:00
Andreas Kling
2e219255a2 IPCCompiler: Put message classes in the Messages namespace 2020-02-06 20:21:49 +01:00
Andreas Kling
73110e25a9 WindowServer: Move classes into WindowServer namespace
Also remove the leading WS from names and filenames.
2020-02-06 20:03:37 +01:00
William McPherson
82d17d2c79 LibAudio: Implement Audio::WavWriter
This class mirrors WavLoader and uses the same variable names so they
can be read side-by-side.

In a simple use-case, you construct a WavWriter object with your file
path and audio parameters, call write_samples() with your bytes and then
either finalize() to finish writing the file or allow the destructor to
do it automatically.

finalize() is needed because the WAV header cannot be written until the
size of the data section is known. You only need to call this manually
if you want to write a WAV file and then immediately load it.

You can also use one WavWriter instance multiple times by repeatedly
calling finalize() and set_file().
2020-02-06 19:13:53 +01:00
Andreas Kling
97edc82a26 LibAudio: Remove leading A from filenames 2020-02-06 15:18:03 +01:00
Andreas Kling
258d798b34 LibCore: Merge the CSyscallUtils namespace into Core 2020-02-06 15:04:57 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Andreas Kling
7415e6ef9f LibIPC: Remove leading I from filenames 2020-02-06 14:54:09 +01:00
Andreas Kling
799b0a4fa8 LibGUI: Rename {H,V}BoxLayout => {Horizontal,Vertical}BoxLayout 2020-02-06 14:44:13 +01:00
Andreas Kling
dccf335d5b LibGUI: Add HorizontalSlider and VerticalSlider convenience classes 2020-02-06 14:43:16 +01:00
Andreas Kling
6a71ba1deb LibGUI: Add HorizontalSplitter and VerticalSplitter convenience classes 2020-02-06 14:40:59 +01:00
Andreas Kling
8bb75084fd LibGfx: Unpublish FloatPoint from the global namespace 2020-02-06 14:35:54 +01:00
Andreas Kling
5c2028db24 LibGfx: Unpublish FloatSize from the global namespace 2020-02-06 14:35:06 +01:00
Andreas Kling
8505d8d15d LibGfx: Unpublish FloatRect from the global namespace 2020-02-06 14:33:05 +01:00
Andreas Kling
418adf3e86 LibPthread: Install immediately after building 2020-02-06 14:29:07 +01:00
Andreas Kling
fb4930754e LibM: Install immediately after building 2020-02-06 14:28:35 +01:00
Andreas Kling
5c06c32df4 LibGfx: Prefer using Gfx::Bitmap::load_from_file instead of load_png()
Code that just wants to open a Gfx::Bitmap from a file should not be
calling the PNG codec directly.
2020-02-06 13:39:17 +01:00
Andreas Kling
f8b00aa290 LibGfx: Unpublish Gfx::Size from the global namespace 2020-02-06 13:32:14 +01:00
Andreas Kling
9b87843af1 LibGfx: Unpublish Gfx::Point from global namespace 2020-02-06 13:08:32 +01:00
Andreas Kling
20cfd2a6bf LibGfx: Unpublish Gfx::Rect from global namespace 2020-02-06 13:02:38 +01:00
Andreas Kling
c39d44fc2e LibGfx: Rename GraphicsBitmap.{cpp,h} => Bitmap.{cpp,h} 2020-02-06 12:07:05 +01:00
Andreas Kling
9ac94d393e LibGfx: Rename from LibDraw :^) 2020-02-06 12:04:00 +01:00
Andreas Kling
11580babbf LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really
wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename
the library to LibGfx. :^)
2020-02-06 11:56:38 +01:00
Andreas Kling
92f77864de LibAudio: Put all classes in the Audio namespace and remove leading A 2020-02-06 10:40:02 +01:00
Andreas Kling
f2a087126c LibC: Add posix_openpt(), grantpt() and unlockpt()
This makes getting a pseudoterminal pair a little bit more portable.
Note that grantpt() and unlockpt() are currently no-ops, since we've
already granted the pseudoterminal slave to the calling user.

We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
2020-02-05 21:17:41 +01:00
Andreas Kling
6d1740e4be LibIPC: Remove IPC::Encoder overloads for size_t
Clients of this code should use explicitly-sized types instead.
2020-02-05 20:37:51 +01:00
Andreas Kling
d264e8fcc5 LibIPC: Put all classes in the IPC namespace and remove the leading I 2020-02-05 19:57:18 +01:00
Andreas Kling
5b7924b9e7 LibProtocol: Rename namespace LibProtocol => Protocol 2020-02-05 19:13:44 +01:00
joshua stein
0c20f98c1c LibDraw: Override set_{non,}volatile in GIFLoader 2020-02-05 18:39:45 +01:00
joshua stein
dac07a5d76 LibCore: CEventLoop: If timeval_sub makes tv_sec negative, use 0 2020-02-05 18:39:45 +01:00
joshua stein
dab78c90f3 LibGUI: Don't specify LibC/ for standard includes 2020-02-05 18:39:45 +01:00
joshua stein
534d27693c LibGUI: Remove unused m_layout_dirty 2020-02-05 18:39:45 +01:00
joshua stein
7d06e37a63 LibDraw: Fix building with clang 2020-02-05 18:39:45 +01:00
joshua stein
f5ecb31fc8 LibDraw: Make [gs]et_pixel arguments used 2020-02-05 18:39:45 +01:00
joshua stein
9143208419 LibDraw: Don't specify LibC/ in standard include paths 2020-02-05 18:39:45 +01:00
joshua stein
482611766a LibThread: Store thread id as pthread_t, use pthread_self()
Serenity calls pthread_self() for gettid() anyway but this makes it
portable.
2020-02-05 18:39:45 +01:00
joshua stein
b5fc1fcb46 LibIPC: Add support for 64-bit size_t in IEncoder 2020-02-05 18:39:45 +01:00
joshua stein
f6a8b1b69a LibCore: Fix building with clang 2020-02-05 18:39:45 +01:00
joshua stein
868b1a24bb LibC: Move struct stat to sys/stat.h 2020-02-05 18:39:45 +01:00
Sergey Bugaev
b3a24d732d Kernel+LibC: Add sys$waitid(), and make sys$waitpid() wrap it
sys$waitid() takes an explicit description of whether it's waiting for a single
process with the given PID, all of the children, a group, etc., and returns its
info as a siginfo_t.

It also doesn't automatically imply WEXITED, which clears up the confusion in
the kernel.
2020-02-05 18:14:37 +01:00
Sergey Bugaev
a6cb7f759e Kernel+LibC: Add some Unix signal types & definitions 2020-02-05 18:14:37 +01:00
Sergey Bugaev
aafa5a9d09 LibC: Fix misplaced brace
It doesn't really make a difference since waitpid() is declared to have
extern "C" linkage in the header anyway, but still.
2020-02-05 18:14:37 +01:00
Kenzi Jeanis
6c9d66ed4b LibC: Add byteswap.h, forwarding bswap_N to GCC builtins 2020-02-03 19:53:54 +01:00
Kenzi Jeanis
e2110b633e LibC: Copy the net directory into /usr/include during build 2020-02-03 19:51:12 +01:00
Sergey Bugaev
589bd0a7de LibC: Implement getsid()
We've had a declaration, but not a definition.
2020-02-03 19:50:45 +01:00
Sergey Bugaev
a6e7797a31 LibC: Move waitpid() to sys/wait.h
That's where POSIX says it should be.
2020-02-03 19:50:45 +01:00
Sergey Bugaev
4e79a60b78 LibC: Implement isblank() 2020-02-03 19:50:45 +01:00
Andreas Kling
fa97ff1c83 LibC: Allow opting into malloc() and free() performance event logging
If a program is started with LIBC_PROFILE_MALLOC in the environment,
it will now generate PERF_EVENT_MALLOC and PERF_EVENT_FREE.
2020-02-02 20:29:50 +01:00
Andreas Kling
c5bd9d4ed1 LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
2020-02-02 15:15:33 +01:00
Andreas Kling
2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Andreas Kling
d67da8c101 LibGUI: Add GHBoxLayout and GVBoxLayout convenience classes 2020-02-02 15:09:48 +01:00
asliturk
9dfe6521fc LibGUI: Save current wallpaper setting to WindowManager.ini. 2020-02-02 15:08:37 +01:00
Jesse Buhagiar
5f78e2ff3a LibC: Implement putpwent()
It was previously impossible to (correctly) put an entry into the
password file via libc. This patch implements the functionality
to do so.
2020-02-02 10:58:45 +01:00
Jesse Buhagiar
dfaa5ecf81 LibC: Implement append modes for fopen()
Previously, `fopen()` didn't contain an implementation for the
append modes, even though the Kernel supports it via `O_APPEND`.

This patch rectifies that by implementing them so an assert is
no longer thrown.
2020-02-02 10:58:45 +01:00
Jesse Buhagiar
cdbdd397db LibC: Move FILE definition to bits/FILE.h
There are some headers in libc that require us to have definitions,
such as `FILE` available to us (such as in `pwd.h`). It is bad
practice to include the entirety of `stdio.h`, so it makes more
sense to put `FILE` into it's own header.
2020-02-02 10:58:45 +01:00
Andrew Kaster
117820f610 Meta: Claim copyright on files added by me
Demos/DynamicLink, LibC/cxxabi.cpp, and LibELF/ELFDynamic*.[cpp/h]
2020-02-02 02:05:38 +01:00
Andreas Kling
5b47b0d867 LibGUI: Make GAction scoped to its CObject parent (widget or window)
Unparented GActions are still parented to the application like before,
making them globally available.

This makes it possible to have actions that work whenever a specific
window is active, no matter which widget is currently focused. :^)
2020-02-02 02:03:39 +01:00
Andreas Kling
6ab9dc4ff4 LibCore: is<CObject>(object) should not default to true
Otherwise we'll lie about anything that doesn't implement is<T>() and
think it's indeed a T.
2020-02-02 02:03:39 +01:00
Andreas Kling
d0c230855d LibCore: Fix CArgsParser build on my host machine 2020-02-01 20:18:53 +01:00
Andreas Kling
998765a7a6 LibC: The exec() family of functions should not search "." by default
We should only execute the filename verbatim if it contains a slash (/)
character somewhere. Otherwise, we need to look through the entries in
the PATH environment variable.

This fixes an issue where you could easily "override" system programs
by placing them in a directory you control, and then waiting for
someone to come there and run e.g "ls" :^)

Test: LibC/exec-should-not-search-current-directory.cpp
2020-02-01 16:14:09 +01:00
Andreas Kling
089110af93 LibPthread: Disable debug spam by default 2020-02-01 12:25:51 +01:00
Sergey Bugaev
831ff2d0ac LibGUI: Only consider starting a drag from an already selected item
This means we can deselect other items immediately when performing a mouse-down
on an unselected item.
2020-01-28 15:08:27 +01:00
Sergey Bugaev
f9b4d981a8 LibGUI+FileManager: Try better to detect executables
We will now consider a file to be an executable if any of the executable
permission bits are set.
2020-01-28 15:08:27 +01:00
Sergey Bugaev
9276582535 LibCore: Rewrite CArgsParser
This is a complete reimplementation of CArgsParser with a different API.

Now, CArgsParser properly supports and distinguishes between:
* Positional arguments (required or not)
* Options

Options can be short and/or long.

The API allows you to add custom option and argument types. A few types are
pre-implemented for convenience:
* Boolean options (take no value)
* String and integer options (take a required value)
* String and integer arguments
* Vector-of-string arguments

This commit doesn't include changes for all the users of CArgsParser (see next
commit for that).
2020-01-28 13:50:18 +01:00
Andreas Kling
e7512ae2d1 GFileSystemModel: Don't copy the null-terminator after readlink() 2020-01-28 10:52:10 +01:00
Andreas Kling
c5db596c78 LibGUI: Fix crash when trying to scroll above the head of the document
We can't go higher than line 0. Can't rely on max() here since line
numbers are unsigned.

Fixes #1145.
2020-01-27 22:59:46 +01:00
Andreas Kling
f7b394af7d LibGUI: Add symlink targets as a column in GFileSystemModel
Also make sure to hide this column by default where we don't expect
to see it.
2020-01-27 22:19:05 +01:00
Andreas Kling
f2f0965edd LibGUI: Have GFileSystemModel use stat instead of lstat for the root
This allows you to set the GFileSystemModel root to a symlink to a
directory and it nicely opens that directory like you would expect.
2020-01-27 22:10:19 +01:00
Andreas Kling
65961d3ffc LibC: Add WSTOPSIG macro
This macro can be used on the "status" output from sys$waitpid() to
find out which signal caused the waitee process to stop.

Fixes #794.
2020-01-27 20:47:56 +01:00
Andreas Kling
23ffd6c319 Kernel+LibC+Userland: Switch to 64-bit time_t
Let's not have that 2038 problem people are talking about. :^)
2020-01-27 10:59:29 +01:00
Andreas Kling
6906edee9a LibGUI: Add 64-bit signed integer support to GVariant
What was previously the "Int" type is now "Int32" and "Int64".
2020-01-27 10:55:10 +01:00
Linus Groh
174583cda5 LibVT: Add parameter names in function signatures for clarity 2020-01-26 15:58:06 +01:00
Linus Groh
3549623dc6 LibVT: Rename escape$r to DECSTBM (Set Top and Bottom Margins) 2020-01-26 15:58:06 +01:00
Linus Groh
79f88db6fb LibVT: Remove empty line 2020-01-26 15:58:06 +01:00
Linus Groh
fd8c250866 LibVT: Replace escape$h_l with SM (Set Mode) / RM (Reset Mode) 2020-01-26 15:58:06 +01:00
Linus Groh
be57b81336 LibVT: Rename escape$f to HVP (Horizontal and Vertical Position) 2020-01-26 15:58:06 +01:00
Linus Groh
2edd8e37ae LibVT: Rename escape$c to DA (Device Attributes) 2020-01-26 15:58:06 +01:00
Linus Groh
dcb5bf9e50 LibVT: Rename escape$m to SGR (Select Graphic Rendition) 2020-01-26 15:58:06 +01:00
Linus Groh
296afbe624 LibVT: Rename escape$H to CUP (Cursor Position) 2020-01-26 15:58:06 +01:00
Linus Groh
5cdfc58242 LibVT: Rename escape$D to CUB (Cursor Backward) 2020-01-26 15:58:06 +01:00
Linus Groh
428a55a196 LibVT: Rename escape$C to CUF (Cursor Forward) 2020-01-26 15:58:06 +01:00
Linus Groh
35310dbd22 LibVT: Rename escape$B to CUD (Cursor Down) 2020-01-26 15:58:06 +01:00
Linus Groh
cc73284c64 LibVT: Rename escape$A to CUU (Cursor Up) 2020-01-26 15:58:06 +01:00
Andreas Kling
3c129172d4 LibCore: Add UDP socket and server classes 2020-01-26 14:45:07 +01:00
Andreas Kling
8e7e502f37 LibCore: CSocket::set_blocking() was backwards 2020-01-26 14:29:33 +01:00
Andreas Kling
f24173b0f1 LibC: Only accept the first response from LookupServer in netdb code
If a DNS server responds with multiple answers for a question, we will
get a newline-separated sequence of answers from LookupServer.

However, we don't handle this properly yet in LibC, so just split the
response by line and only care about the first answer for now.
2020-01-26 12:23:37 +01:00
Andreas Kling
8c1f2d7131 LibVT: Rename escape$K and escape$J to EL and ED respectively
We should rename all of these functions to match the real VT100 names.
This will make it 100% easier to work on LibVT.

For reference: https://vt100.net/docs/vt100-ug/
2020-01-25 20:54:40 +01:00
Andreas Kling
4ed5c13792 LibVT: Fix off-by-ones in ED (Erase in Display) and EL (Erase in Line) 2020-01-25 20:51:49 +01:00
Andreas Kling
a3069b16fd LibVT: Make backspace (BS) non-destructive
I did not realize this was a thing. This fixes an artifact in vttest.
2020-01-25 20:39:23 +01:00
Andreas Kling
dca92af431 LibVT: Support IND and RI (cursor down/up basically) 2020-01-25 20:26:35 +01:00
Andreas Kling
0d191aae13 LibVT: Rename EscapeState::ExpectBracket => GotEscape
Seems like there are many escape sequences that don't start with
brackets, so let's call the post-escape state "GotEscape" instead. :^)
2020-01-25 20:02:31 +01:00
Andreas Kling
897ad1b927 LibVT: Support NEL (Next Line)
I think this can just behave as if you sent a newline character ('\n').
2020-01-25 20:01:43 +01:00
Andreas Kling
ab77bd4c3a LibVT: Support <esc>#8 to fill screen with E's
This is apparently a "confidence test" supported by VT100.
2020-01-25 19:52:35 +01:00
Andreas Kling
25f04b06ad LibVT: Don't go into "stomp" state after moving the cursor
The curious "stomp" state occurs when you type your way all the way
over to the right side of the terminal buffer, and we "stomp" once on
the very last column, before jumping to the next line.

We should never go into "stomp" state in response to programmatically
setting the cursor position. This fixes a small artifact in vttest.
2020-01-25 19:50:23 +01:00
Andreas Kling
20e41ab381 LibVT: Support HVP (Horizontal and Vertical Position) (final 'f') 2020-01-25 19:49:42 +01:00
Andreas Kling
e6f5ce8285 LibVT: Support the DA (Device Attributes) request (final 'c')
This is used by vttest on startup to query the device for identity.
2020-01-25 19:12:08 +01:00
Andreas Kling
74829cdb75 LibIPC: Short-cirtcuit post_message() if socket already disconnected
To allow for more asynchronous teardown of IClientConnection, make the
post_message() function simply return if called after the IPC socket
has been closed.
2020-01-25 10:34:32 +01:00
Andreas Kling
b0192cfb38 Meta: Remove some copyright headers added in error 2020-01-25 10:34:32 +01:00
Sergey Bugaev
c0b32f7b76 Meta: Claim copyright for files created by me
This changes copyright holder to myself for the source code files that I've
created or have (almost) completely rewritten. Not included are the files
that were significantly changed by others even though it was me who originally
created them (think HtmlView), or the many other files I've contributed code to.
2020-01-24 15:15:16 +01:00
Andreas Kling
1c34348b0c GTextEditor: Create the "go to line" action eagerly
Previously it was created the first time you requested a context menu
for the GTextEditor by right-clicking in it.

That meant it wasn't possible to use Ctrl+L to "go to line" before you
had first right-clicked the editor.
2020-01-23 21:33:15 +01:00
Andreas Kling
a33259483a GTextEditor: Move "Go to line" feature from HackStudio into GTextEditor
This is a handy feature for any multi-line GTextEditor, so let's just
have it in the base widget. :^)

Fixes #1122.
2020-01-23 21:33:15 +01:00
Andreas Kling
9e2c595c64 GTextEditor: Make color of non-highlighted line numbers darker
Fixes #1123.
2020-01-23 21:33:15 +01:00
Andreas Kling
b88be25214 GTextEditor: Disable auto-indentation while pasting
Fixes #1121.
2020-01-23 21:33:15 +01:00
Andreas Kling
14b83ee12f LibGUI: Give GTextDocument access to the GTextEditor during commands
It's useful for the GTextDocument to have access to the initiating
GTextEditor widget during the initial execution of a command.

Since commands are executed via calls to GUndoCommand::redo(), we do
this by wrapping the invocation of redo() in a new helper called
GTextDocumentUndoCommand::execute_from(GTextDocument::Client).

This is then used to fetch the current auto-indentation feature state
and the soft tab width, both used by text insertion.
2020-01-23 21:33:15 +01:00
Andreas Kling
a93f35ac71 LibCore: Remove redundant check in CObject::dispatch_event() 2020-01-23 21:33:15 +01:00
Andreas Kling
3de5439579 AK: Let's call decrementing reference counts "unref" instead of "deref"
It always bothered me that we're using the overloaded "dereference"
term for this. Let's call it "unreference" instead. :^)
2020-01-23 15:14:21 +01:00
Andreas Kling
4aa1b5b40e LibC: The pwd and grp related functions need to preserve empty fieldso
Now that String::split() defaults to keep_empty=false, we need to make
sure the pwd and grp functions in LibC keep the empty ones.

This fixes "id" moaning about invalid lines in /etc/group.
2020-01-23 14:33:58 +01:00
Sergey Bugaev
b6aae25244 LibGUI: Rename GAbstractColumnView to GAbstractTableView
This is to prevent confusion with GColumnsView, which is unrelated.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
dec95cb8b3 LibGUI: Let GModel specify the drag data type
GModel subclasses can now override drag_data_type() to specify which type
GAbstractView should set for drag data. The default implementation returns a
null string, which disables dragging from this widget.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
d3ce7ae0e3 LibGUI: Move most of mouse event handling to GAbstractView
This deduplicates existing code, and also gives all the model-backed widgets
selection manipulation and drag support for free :^)
2020-01-22 21:22:23 +01:00
Sergey Bugaev
fd11c96e8e LibGUI: Misc tweaks
Minus two empty lines because clang-format insists on it,
and plus an underscore.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
91d3fc54be LibGUI: Move index_at_event_position() up to GAbstractView
It's now an abstract (pure virtual) public method in GAbstractView that
individual widgets have to implement. This will allow us to move more
selection-related logic into GAbstractView in order to share it between
implementations.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
ff66101f9e LibGUI: Add GItemView::index_at_event_position()
This replaces GItemView::item_at_event_position(), which used to return a raw
int, requiring callers to call model()->index() with it again.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
2ccad40a16 LibGUI: Add GListView::index_at_event_position()
And port GListView::mousedown_event() to it.
2020-01-22 21:22:23 +01:00
Sergey Bugaev
b4923938e1 LibVT: Input dragged file path into the terminal on drop
We also support dropping plain text and non-file URLs.
2020-01-22 21:22:23 +01:00
Andreas Kling
72d68b4025 LibCore: Fix broken "stay_within" mechanism in event dispatch
The "stay_within" parameter to CObject::dispatch_event() optionally
specifies a node in the CObject parent chain where event dispatch
should stop bubbling upwards.

Since event dispatch is done recursively, this was not working right,
as we would simply return from the innermost dispatch loop, leaving
the event un-accepted, which meant that the penultimately inner
dispatch loop would pick up the event and keep bubbling it anyway.

This made it possible for events to jump across window boundaries
within an application, in cases where one window was a CObject ancestor
of another window. This is typically the case with dialog windows.

Fix #1078.
2020-01-21 21:55:25 +01:00
Andreas Kling
a5e482833d LibGUI: Make GDialog accept escape key press events
Anyone who "handles" an event should really also be accepting it.
2020-01-21 21:55:25 +01:00
Andreas Kling
82cb5b6f64 LibGUI: GFileSystemModel::index() now survives negative inputs
If asked to create an index with negative row and/or column, we should
just return an invalid GModelIndex() instead of asserting.
2020-01-21 21:55:25 +01:00
Andreas Kling
ecd5589d4f LibGUI: Fix missing initializer for GColumnsView::m_model_column 2020-01-21 21:55:25 +01:00
Andreas Kling
a14f08fcc9 LibGUI: Import GColorPicker from the PaintBrush application 2020-01-21 21:55:25 +01:00
Andreas Kling
66598f60fe SystemMonitor: Show process unveil() state as "Veil"
A process has one of three veil states:

- None: unveil() has never been called.
- Dropped: unveil() has been called, and can be called again.
- Locked: unveil() has been called, and cannot be called again.
2020-01-21 18:56:23 +01:00
Andreas Kling
5b992b130a LibDraw: Remove old PNG_STOPWATCH_DEBUG debug code 2020-01-21 15:40:14 +01:00
Andreas Kling
07075cd001 Kernel+LibC: Clean up open() flag (O_*) definitions
These were using a mix of decimal, octal and hexadecimal for no reason.
2020-01-21 13:34:39 +01:00
Andreas Kling
6081c76515 Kernel: Make O_RDONLY non-zero
Sergey suggested that having a non-zero O_RDONLY would make some things
less confusing, and it seems like he's right about that.

We can now easily check read/write permissions separately instead of
dancing around with the bits.

This patch also fixes unveil() validation for O_RDWR which previously
forgot to check for "r" permission.
2020-01-21 13:27:08 +01:00
Andreas Kling
0569123ad7 Kernel: Add a basic implementation of unveil()
This syscall is a complement to pledge() and adds the same sort of
incremental relinquishing of capabilities for filesystem access.

The first call to unveil() will "drop a veil" on the process, and from
now on, only unveiled parts of the filesystem are visible to it.

Each call to unveil() specifies a path to either a directory or a file
along with permissions for that path. The permissions are a combination
of the following:

- r: Read access (like the "rpath" promise)
- w: Write access (like the "wpath" promise)
- x: Execute access
- c: Create/remove access (like the "cpath" promise)

Attempts to open a path that has not been unveiled with fail with
ENOENT. If the unveiled path lacks sufficient permissions, it will fail
with EACCES.

Like pledge(), subsequent calls to unveil() with the same path can only
remove permissions, not add them.

Once you call unveil(nullptr, nullptr), the veil is locked, and it's no
longer possible to unveil any more paths for the process, ever.

This concept comes from OpenBSD, and their implementation does various
things differently, I'm sure. This is just a first implementation for
SerenityOS, and we'll keep improving on it as we go. :^)
2020-01-20 22:12:04 +01:00
Andreas Kling
b25210ee1b LibGUI: Use clamp() is various places 2020-01-20 13:17:16 +01:00
Andreas Kling
e07b34b9b8 Kernel+AK: Add/fix uintptr_t and intptr_t definitions
We should move towards using uintptr_t instead of u32 for pointers
everywhere, to prepare for an eventual 64-bit port.
2020-01-20 13:13:03 +01:00
Shannon Booth
6ea70f5724 LibDraw: Add beginnings of a triangle class
Currently the points of a triangle do not need to be initialised in a
certain orientation. Currently, the only real method in the class is
`contains`. However we can continue extending the class if and when we
need more functionality.
2020-01-19 08:45:23 +01:00
Andreas Kling
545e2ba065 LibC: Use the templated type consistently in strtol_impl<T> 2020-01-18 11:41:04 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Shannon Booth
22d1961c9a LibGUI: Handle "Return" key events
I kept on trying to use the enter key to navigate a tree view, when only
left and right arrow keys are used for this. Now also suport the return
key, is used as a toggle to open a tree.
2020-01-18 00:27:39 +01:00
Sergey Bugaev
cee597a728 LibCore: Make CIODevice::read_all() actually read all data
It used to only read the data it could get without blocking. Andreas says this
was intentional, but it's counterintuitive and no code that uses read_all()
actually expects it to return only a part of the data. So change it to always
read data until an EOF (or an error) is received.
2020-01-17 21:49:58 +01:00
Sergey Bugaev
e0013a6b4c Kernel+LibC: Unify sys$open() and sys$openat()
The syscall is now called sys$open(), but it behaves like the old sys$openat().
In userspace, open_with_path_length() is made a wrapper over openat_with_path_length().
2020-01-17 21:49:58 +01:00
Andreas Kling
c6e552ac8f Kernel+LibELF: Don't blindly trust ELF symbol offsets in symbolication
It was possible to craft a custom ELF executable that when symbolicated
would cause the kernel to read from user-controlled addresses anywhere
in memory. You could then fetch this memory via /proc/PID/stack

We fix this by making ELFImage hand out StringView rather than raw
const char* for symbol names. In case a symbol offset is outside the
ELF image, you get a null StringView. :^)

Test: Kernel/elf-symbolication-kernel-read-exploit.cpp
2020-01-16 22:11:31 +01:00
Andreas Kling
60143c8d4e LibC: Add strnlen() 2020-01-16 22:11:31 +01:00
joshua stein
5c25983844 LibVT: enforce a minimum size of 1 column and 1 row
Fixes #829
2020-01-16 12:41:09 +01:00
joshua stein
24b8a27190 LibVT: only use default bold font if it's the same size as our font
When the new font is a different size, just use that font for bold
glyphs as well.  It would be nice to find a matching bold version of
the new font automatically in the future.
2020-01-15 22:30:34 +01:00
Andreas Kling
09fd59a1b5 LibC: Add INADDR_LOOPBACK 2020-01-15 22:11:44 +01:00
joshua stein
c6c7e40bd1 Build: more IPCCompiler-generated dependencies 2020-01-15 21:52:09 +01:00
Andreas Kling
fd64e97c8a LibDraw+LibHTML: Make link colors themeable
Add "Link", "ActiveLink" and "VisitedLink" colors to the system theme
definition, and implement support for them in LibHTML.

Note that <body link="foo" alink="bar" vlink="baz"> takes precedence
over the system colors. Author style also takes precedence, since we
only fetch the system color in case the CSS color is -libhtml-link.
2020-01-13 20:33:15 +01:00
Andreas Kling
3b2f20ed4d LibM: Implement some naive functionality to make VVVVVV run 2020-01-13 19:01:44 +01:00
DrewStratford
2a8de4cdec LibCore: Fix segfault in CArgsParser (#1072)
CArgsParser::parse_next_param did not properly ensure that, when
a param required a following argument, there were enough parameters left to
complete the parse. This meant that params_left could become negative,
avoiding parse_next_param's termination condition, and cause a segfault
when reading from argv with an out of bounds index.

This fixes the check to ensure that we do in fact have the right amount
of parameters and also adds an assertion to ensure that params_left does
not become negative.
2020-01-13 14:52:25 +01:00
Andrew Kaster
046d6a6bbb LibELF: Add methods to validate the ELF and program headers
These will make sure there's no funny business or funny offsets in the
main ELF header or each Program Header. More can still be done (like
validating section headers), but this is a good start
2020-01-13 13:03:30 +01:00
Andrew Kaster
4cb7c8ea85 LibC: Move even more methods and globals out of crt0.o 2020-01-13 13:03:30 +01:00
Sergey Bugaev
dd54d13d8d Kernel+LibC: Allow passing mount flags to chroot()
Since a chroot is in many ways similar to a separate root mount, we can also
apply mount flags to it as if it was an actual mount. These flags will apply
whenever the chrooted process accesses its root directory, but not when other
processes access this same directory for the outside. Since it's common to
chdir("/") immediately after chrooting (so that files accessed through the
current directory inherit the same mount flags), this effectively allows one to
apply additional limitations to a process confined inside a chroot.

To this effect, sys$chroot() gains a mount_flags argument (exposed as
chroot_with_mount_flags() in userspace) which can be set to all the same values
as the flags argument for sys$mount(), and additionally to -1 to keep the flags
set for that file system. Note that passing 0 as mount_flags will unset any
flags that may have been set for the file system, not keep them.
2020-01-12 20:02:11 +01:00
Andreas Kling
45e7c2ba69 LibDraw: Remove debug spam about loading system themes 2020-01-12 10:01:22 +01:00
0xtechnobabble
ecf58ddd4f TextEditor: Implement replacement functionality
This patch adds a new replace widget that cooperates with the find
widget, the replace widget takes the input in the find textbox, searches
for occurences of that input, and replaces them with the input provied
in the replace textbox.
2020-01-12 01:41:36 +01:00
Andreas Kling
75c5e9af56 LibGUI: Fix assertion failure in GItemView::mouse_up() 2020-01-11 22:12:36 +01:00
Andreas Kling
ec1ae37f69 SystemMonitor+LibCore: Show process pledges in SystemMonitor :^) 2020-01-11 21:33:12 +01:00
Andreas Kling
41c504a33b Kernel: Add pledge() syscall :^)
This patch implements basic support for OpenBSD-style pledge().
pledge() allows programs to incrementally reduce their set of allowed
syscalls, which are divided into categories that each make up a subset
of POSIX functionality.

If a process violates one of its pledged promises by attempting to call
a syscall that it previously said it wouldn't call, the process is
immediately terminated with an uncatchable SIGABRT.

This is by no means complete, and we'll need to add more checks in
various places to ensure that promises are being kept.

But it is pretty cool! :^)
2020-01-11 20:45:51 +01:00
Sergey Bugaev
61c1106d9f Kernel+LibC: Implement a few mount flags
We now support these mount flags:
* MS_NODEV: disallow opening any devices from this file system
* MS_NOEXEC: disallow executing any executables from this file system
* MS_NOSUID: ignore set-user-id bits on executables from this file system

The fourth flag, MS_BIND, is defined, but currently ignored.
2020-01-11 18:57:53 +01:00
Sergey Bugaev
2fcbb846fb Kernel+LibC: Add O_EXEC, move exec permission checking to VFS::open()
O_EXEC is mentioned by POSIX, so let's have it. Currently, it is only used
inside the kernel to ensure the process has the right permissions when opening
an executable.
2020-01-11 18:57:53 +01:00
Sergey Bugaev
4566c2d811 Kernel+LibC: Add support for mount flags
At the moment, the actual flags are ignored, but we correctly propagate them all
the way from the original mount() syscall to each custody that resides on the
mounted FS.
2020-01-11 18:57:53 +01:00
Andreas Kling
eede6cfd06 LibPthread: Fix incompatible pthread_setname_np(), pthread_getname_np()
Other implementations of pthread_setname_np() do not take the name
length as an argument.

For pthread_getname_np(), other implementations take the buffer size
as a size_t.

This patch brings us in line with other implementations.
2020-01-11 12:54:30 +01:00
Andreas Kling
24c736b0e7 Kernel: Use the Syscall string and buffer types more
While I was updating syscalls to stop passing null-terminated strings,
I added some helpful struct types:

    - StringArgument { const char*; size_t; }
    - ImmutableBuffer<Data, Size> { const Data*; Size; }
    - MutableBuffer<Data, Size> { Data*; Size; }

The Process class has some convenience functions for validating and
optionally extracting the contents from these structs:

    - get_syscall_path_argument(StringArgument)
    - validate_and_copy_string_from_user(StringArgument)
    - validate(ImmutableBuffer)
    - validate(MutableBuffer)

There's still so much code around this and I'm wondering if we should
generate most of it instead. Possible nice little project.
2020-01-11 12:47:47 +01:00
Andreas Kling
f5092b1c7e Kernel: Pass a parameter struct to mount()
This was the last remaining syscall that took a null-terminated string
and figured out how long it was by walking it in kernelspace *shudder*.
2020-01-11 10:56:02 +01:00
Andreas Kling
e380142853 Kernel: Pass a parameter struct to rename() 2020-01-11 10:36:54 +01:00
Andreas Kling
46830a0c32 Kernel: Pass a parameter struct to symlink() 2020-01-11 10:31:33 +01:00
Andreas Kling
c97bfbd609 Kernel: Pass a parameter struct to mknod() 2020-01-11 10:27:37 +01:00
Andreas Kling
6536a80aa9 Kernel: Pass a parameter struct to chown() 2020-01-11 10:17:44 +01:00
Andreas Kling
ddd0b19281 Kernel: Add a basic chroot() syscall :^)
The chroot() syscall now allows the superuser to isolate a process into
a specific subtree of the filesystem. This is not strictly permanent,
as it is also possible for a superuser to break *out* of a chroot, but
it is a useful mechanism for isolating unprivileged processes.

The VFS now uses the current process's root_directory() as the root for
path resolution purposes. The root directory is stored as an uncached
Custody in the Process object.
2020-01-10 23:14:04 +01:00
Andreas Kling
485443bfca Kernel: Pass characters+length to link() 2020-01-10 21:26:47 +01:00
Andreas Kling
416c7ac2b5 Kernel: Rename Syscall::SyscallString => Syscall::StringArgument 2020-01-10 20:16:18 +01:00
Andreas Kling
0695ff8282 Kernel: Pass characters+length to readlink()
Note that I'm developing some helper types in the Syscall namespace as
I go here. Once I settle on some nice types, I will convert all the
other syscalls to use them as well.
2020-01-10 20:13:23 +01:00
Andreas Kling
6a529ea425 LibGUI: Fix rendering GColumnsView separator
Patch by Sergey Bugaev.
2020-01-10 18:25:44 +01:00
Sergey Bugaev
edb61d8bfd LibGUI: Add GColumnsView
This is a shiny new widget that can display a tree using Miller columns ^:)

In many cases, the columns view can be used as an alternative to tree view,
but it has its own set of limitations:

* It can only display one model column (so it cannot replace a table)
* It takes up a lot of horizontal space, so it's only suitable if the item text
  is fairly short
* It can only display one subtree at a time

But as long as a usecase doesn't suffer from these limitations, a columns view
can be *much* more intuitive than a tree view.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
10324f95b0 LibGUI+FileManager: Misc tweaks courtesy of clang-format 2020-01-10 17:45:59 +01:00
Sergey Bugaev
fdeb91e000 LibGUI+FileManager: Merge GDirectoryModel into GFileSystemModel
We used to have two different models for displaying file system contents:
the FileManager-grade table-like directory model, which exposed rich data
(such as file icons with integrated image previews) about contents of a
single directory, and the tree-like GFileSystemModel, which only exposed
a tree of file names with very basic info about them.

This commit unifies the two. The new GFileSystemModel can be used both as a
tree-like and as a table-like model, or in fact in both ways simultaneously.
It exposes rich data about a file system subtree rooted at the given root.

The users of the two previous models are all ported to use this new model.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
0f18a16e2c LibGUI: Add GAbstractView::activate_selected()
This is a nice little utility to activate all the selected items,
which is what you usually want to do.
2020-01-10 17:45:59 +01:00
Sergey Bugaev
caa08938e5 LibGUI: Fix GModel::is_valid() behavior for tree-like models 2020-01-10 17:45:59 +01:00
Sergey Bugaev
303fa75d36 LibGUI: Fix tree view column positioning when some columns are hidden 2020-01-10 17:45:59 +01:00
Andreas Kling
8f20b173fd LibC: Remove useless retry loop in connect_to_lookup_server() 2020-01-10 13:52:20 +01:00
Andreas Kling
952bb95baa Kernel: Enable SMAP protection during the execve() syscall
The userspace execve() wrapper now measures all the strings and puts
them in a neat and tidy structure on the stack.

This way we know exactly how much to copy in the kernel, and we don't
have to use the SMAP-violating validate_read_str(). :^)
2020-01-10 12:20:36 +01:00
Andreas Kling
197e73ee31 Kernel+LibELF: Enable SMAP protection during non-syscall exec()
When loading a new executable, we now map the ELF image in kernel-only
memory and parse it there. Then we use copy_to_user() when initializing
writable regions with data from the executable.

Note that the exec() syscall still disables SMAP protection and will
require additional work. This patch only affects kernel-originated
process spawns.
2020-01-10 10:57:06 +01:00