Commit Graph

1319 Commits

Author SHA1 Message Date
TheMorc
b2086c8d77 Demos+Games: Pledge "sendfd" in demos and games 2021-01-15 18:47:07 +01:00
Andreas Kling
12879184ce UserspaceEmulator: Support the anon_create, sendfd and recvfd syscalls 2021-01-15 14:17:19 +01:00
Andreas Kling
20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00
Andreas Kling
0b0514d46b LibGUI+WindowServer: Use anonymous files for window backing stores :^)
This patch replaces the use of shbufs for GUI::Window backing stores
with the new anonymous files mechanism.

Backing bitmaps are now built on memory allocated with anon_create().
They are passed across the IPC socket as IPC::File. This means that
WindowServer now pledges "recvfd" and graphical clients need to pledge
"sendfd" to work.

To support the cached bitmap swapping optimization on the WindowServer
side, each backing store is assigned an incrementing serial number on
the client side. (This allows us to re-use an already mapped file.)
2021-01-15 13:57:00 +01:00
Andreas Kling
4d97b955e6 LibGfx: Allow creating a Gfx::Bitmap backed by an anonymous file
Gfx::Bitmap::create_with_anon_fd() creates such a Bitmap, and also
optionally takes ownership of the file, making sure to close() it
on destruction.
2021-01-15 13:56:54 +01:00
Andreas Kling
fb4993f067 Kernel: Add anonymous files, created with sys$anon_create()
This patch adds a new AnonymousFile class which is a File backed by
an AnonymousVMObject that can only be mmap'ed and nothing else, really.

I'm hoping that this can become a replacement for shbufs. :^)
2021-01-15 13:56:47 +01:00
Andreas Kling
96f8fcdcba LibGUI: Add a WindowBackingStore class
Instead of storing the back/front buffers of a GUI::Window as just
Gfx::Bitmap, wrap them in a WindowBackingStore class.

This will allow us to add more information alongside the bitmaps while
keeping the back/front swapping logic simple.
2021-01-15 10:54:19 +01:00
Lenny Maiorani
7e71de8f1f Http[s]Protocol: Make the code start_download DRY
Problem:
- `HttpProtocol::start_download` and `HttpsProtocol::start_download`
  implementations are the same except for a few types.

Solution:
- Follow the "Don't Repeat Yourself" mantra and de-duplicate the code
  using templates.
2021-01-15 09:44:21 +01:00
Brendan Coles
a44739473b Tests: Test set uid/gid not dropped upon file rename 2021-01-15 08:24:43 +01:00
Andreas Kling
b8c3ea8b30 LibGUI: Hold on to notification icon until NotificationServer responds
This broke when switching IPC messages to support move-only types.
This pattern is not ideal, but the real fix for this will be using fd
passing instead of shbufs.

Fixes #4955.
2021-01-15 08:22:54 +01:00
Mart G
29102051d9 SpaceAnalyzer: Fix TreeMapWidget layout issue for small rects.
For small rects there was a disagreement between two parts of the
layout algorithm. There is a function that decides if there is
enough space in a rectangle for a label. But this function was
called on two slightly different rectangles.
2021-01-14 16:45:55 +01:00
Brendan Coles
30d515bb61 Tests: Add LibC stdlib mktmp function tests for unique filenames 2021-01-14 13:15:51 +01:00
Andreas Kling
f1f7bf567b LibIPC: Add an expressive way to close an IPC::File after sending it
If you don't need a file descriptor after sending it to someone over
IPC, construct it with IPC::File(fd, IPC::File::CloseAfterSending)
and LibIPC will take care of it for you. :^)
2021-01-14 09:50:14 +01:00
Andreas Kling
7f2d8e8884 LibIPC: Close received IPC::File fd's by default unless taken
When receiving a file descriptor over IPC, the receiver must now call
take_fd() on the IPC::File to take over the descriptor. Otherwise,
IPC::File will close the file on destruction.
2021-01-14 09:50:14 +01:00
Andreas Kling
384d047e3e IPCCompiler: Use move semantics in generated IPC message constructors
This allows us to use move-only types as IPC message parameters.
2021-01-14 09:50:14 +01:00
Brendan Coles
2f65363488 DHCPClient: handle /proc/net/adapters invalid JSON gracefully 2021-01-14 08:35:34 +01:00
Linus Groh
f253f68768 LibJS: Rename ErrorType::ProxyGetOwnDescriptor{Undef => Undefined}Return
This seems like an unnecessary and uncommon abbreviation.
2021-01-14 08:13:32 +01:00
Linus Groh
cab3049dcc LibJS: Rename ErrorType::ToObjectNullOr{Undef => Undefined}
This seems like an unnecessary and uncommon abbreviation.
2021-01-14 08:13:32 +01:00
Andrew Kaster
f67f8fdbf2 LibCore: Include fcntl.h in more places that we use fcntl for Lagom
Looks like it's more than just TcpServer where we do this :)
2021-01-13 15:02:11 +01:00
Andrew Kaster
a65ccfee3a LibCore: Include fcntl before using it for non-linux lagom builds
SOCK_NONBLOCK is a linux-ism that serenity and linux support. For lagom
builds, we use ioctl/fcntl to get a non-blocking socket the old
fashioned way. Some file re-org unhid the fcntl.h dependency of TcpServer,
so add the header explicitly.
2021-01-13 09:52:32 +01:00
AnotherTest
72be904259 LibLine: Use StringView::find() to find '::' in history entries
Fixes an issue mentioned in #4926.
2021-01-12 23:36:20 +01:00
Andreas Kling
1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Nico Weber
d551263b11 LibGfx: Make it possible to apply an (integer) scale to a Painter
This adds a scale factor to Painter, which will be used for HighDPI
support. It's also a step towards general affine transforms on Painters.

All of Painter's public API takes logical coordinates, while some
internals deal with physical coordinates now. If scale == 1, logical
and physical coordinates are the same. For scale == 2, a 200x100 bitmap
would be covered by a logical {0, 0, 100, 50} rect, while its physical
size would be {0, 0, 200, 100}.

Most of Painter's functions just assert that scale() == 1 is for now,
but most functions called by WindowServer are updated to handle
arbitrary (integer) scale.

Also add a new Demo "LibGfxScaleDemo" that covers the converted
functions and that can be used to iteratively add scaling support
to more functions.

To make Painter's interface deal with logical coordinates only,
make translation() and clip_rect() non-public.
2021-01-12 23:32:54 +01:00
Linus Groh
545b4879e4 LibGfx: Make Painter::draw_pixel() with thickness = 1 work with RGBA
The underlying fill_rect() works correctly, but the special case for
thickness = 1 was not blending the new color with the target pixel's
color, causing RGBA colors to be painted as their RGB counterpart.
2021-01-12 21:41:14 +01:00
AnotherTest
a90905c54c Shell: Use lstat instead of access to check if glob target exists
Fixes #4905
2021-01-12 16:23:26 +01:00
AnotherTest
b2b3ccb12d LibCore: Don't create an RPC server when built for lagom
There's no reason to have this, and it will most likely fail anyway
(since there's likely no /tmp/rpc).
2021-01-12 16:21:34 +01:00
Andreas Kling
f2a6ee76c0 LibPthread: Add pthread_equal() 2021-01-12 13:42:45 +01:00
Andreas Kling
bee1145bdf LibPthread: Stub pthread_setcancelstate() and pthread_setcanceltype() 2021-01-12 13:40:48 +01:00
Andreas Kling
51a2d3c1fa Libraries: Remove LibUnwind
This was not used for anything.
2021-01-12 13:32:34 +01:00
Andreas Kling
aea2eac3d1 HexEditor: Hide unnecessary scrollbars in the main file view 2021-01-12 13:31:32 +01:00
Andreas Kling
20a18d2137 Demos: Remove HelloWorld demo 2021-01-12 13:17:00 +01:00
Andreas Kling
c7ac7e6eaf Services: Move to Userland/Services/ 2021-01-12 12:23:01 +01:00
Andreas Kling
4055b03291 DevTools: Move to Userland/DevTools/ 2021-01-12 12:18:55 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Andreas Kling
dc28c07fa5 Applications: Move to Userland/Applications/ 2021-01-12 12:05:23 +01:00
Andreas Kling
aa939c4b4b Games: Move to Userland/Games/ 2021-01-12 12:04:23 +01:00
Andreas Kling
b8d6a56fa3 MenuApplets: Move to Userland/MenuApplets/ 2021-01-12 12:04:20 +01:00
Andreas Kling
7fc079bd86 Demos: Move to Userland/Demos/ 2021-01-12 12:04:17 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00
Andreas Kling
c4e2fd8123 Shell: Move to Userland/Shell/ 2021-01-12 12:04:07 +01:00
Lenny Maiorani
e6f907a155 AK: Simplify constructors and conversions from nullptr_t
Problem:
- Many constructors are defined as `{}` rather than using the ` =
  default` compiler-provided constructor.
- Some types provide an implicit conversion operator from `nullptr_t`
  instead of requiring the caller to default construct. This violates
  the C++ Core Guidelines suggestion to declare single-argument
  constructors explicit
  (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit).

Solution:
- Change default constructors to use the compiler-provided default
  constructor.
- Remove implicit conversion operators from `nullptr_t` and change
  usage to enforce type consistency without conversion.
2021-01-12 09:11:45 +01:00
Emanuele Torre
9dc44bf8c4 wc: Remove a memory leak. 2021-01-12 09:01:21 +01:00
Emanuele Torre
dcd259a100 wc: printf(), fprintf(stderr, ...) -> out(), outln(), warnln().
Problem:
- We were using some incorrect format strings in printf-functions:
 * "%7lu" to print `size_t` values instead of "%7zu";
 * "%7i" to print `unsigned int` values instead of "%7u".

Solution:
- Use out(), outln() and warnln() instead of printf-functions. :^)
2021-01-12 09:01:21 +01:00
Emanuele Torre
725eb702b7 wc: Fix code style.
`unsigned int` -> `unsigned`.
Use brace initialisers instead of equal initialisers for struct members.
Prefix global variables with `g_`.
Wrap multi-line statements in curly braces.

Also:
Use const references instead of references when possible.
Rename `file_name` to `file_specifier`: "-" is not a file name.
Rename `files` to `file_specifiers`.
Avoid some useless checks.
2021-01-12 09:01:21 +01:00
Brendan Coles
959970e060 userdel: Use pledge() and unveil() 2021-01-12 08:59:24 +01:00
Brendan Coles
eece9edd91 useradd: Use pledge() 2021-01-12 08:58:59 +01:00
Andreas Kling
e5234f9560 strace: Use pledge() 2021-01-11 22:36:09 +01:00
Andreas Kling
f03800cee3 Kernel: Add dedicated "ptrace" pledge promise
The vast majority of programs don't ever need to use sys$ptrace(),
and it seems like a high-value system call to prevent a compromised
process from using.

This patch moves sys$ptrace() from the "proc" promise to its own,
new "ptrace" promise and updates the affected apps.
2021-01-11 22:32:59 +01:00
Sahan Fernando
6d97b623cd Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Andreas Kling
2f3b901f7f AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used.

Instead of having valid/invalid states and storing an error in case
it's invalid, a MappedFile is now always valid, and the factory
function that creates it will return an OSError if mapping fails.
2021-01-10 16:49:13 +01:00