Arne Elster
cdaa179eeb
LibCore: Fix relative seeking in IODevice
...
The recently introduced read buffer in IODevice broke relative seeking.
The amount of data in the buffer wouldn't get taken into account.
2021-11-30 10:51:10 +01:00
Andreas Kling
83056efc1a
LibCore: Add syscall wrapper for dup()
2021-11-28 23:14:19 +01:00
Andreas Kling
cb9cac4e40
LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>
...
This allows us to use TRY() in decoding helpers, leading to a nice
reduction in line count.
2021-11-28 23:14:19 +01:00
Andreas Kling
982ac34437
LibCore: Add syscall wrappers for sendfd() and recvfd()
2021-11-28 23:14:18 +01:00
Brian Gianforcaro
44ffe3e5bb
LibCore: Allow System::pledge execpromises argument to be omitted
...
It appears that we don't have almost no cases of a callers passing
exec promises when they call `pledge()`. To simplify the code a bit we
add a default parameter that will pass nullptr for us to `pledge()`.
2021-11-28 08:04:57 +01:00
Brian Gianforcaro
fcc00c9a27
LibCore+cat: Switch Core::System::read/write to take a Span of bytes
...
In the spirit of the Core::System name space having "modern" facades
for classically C functions / Kernel interfaces, it seems appropriate
that we should take Span's of data instead of raw pointer + length
arguments.
2021-11-28 08:04:57 +01:00
Kenneth Myhra
951d8a06d8
LibCore: Add syscall wrapper for gethostname()
2021-11-27 11:14:16 +01:00
Andreas Kling
f1cc3d0fc4
Userland: Use Core::ArgsParser's Vector<StringView> API everywhere
...
...and remove the Vector<String> variant since there are no remaining
users of this API.
2021-11-26 23:27:57 +01:00
Andreas Kling
395ba619d8
LibCore: Add Vector<StringView> variant of add_positional_argument()
2021-11-26 23:27:57 +01:00
Andreas Kling
748c8b4879
LibCore: Add syscall wrapper for ptsname()
2021-11-24 23:24:53 +01:00
Andreas Kling
a152b1f215
LibCore: Add syscall wrapper for dup2()
2021-11-24 23:07:31 +01:00
Andreas Kling
71bc9bee0a
LibCore: Add syscall wrapper for pipe2()
2021-11-24 23:07:31 +01:00
Andreas Kling
b81ce827b6
LibCore: Add Core::Object::try_add<T>(...)
...
This is a fallible version of add<T>(...) that returns ErrorOr<T>.
It can be used together with TRY() to handle allocation failures when
instantiating new Core::Objects.
2021-11-24 13:52:01 +01:00
Andreas Kling
8b7b726680
LibCore: Add kill() syscall wrapper
2021-11-24 00:25:22 +01:00
Timothy Flynn
7f780e43a6
LibCore: Allow moving, but not copying, DirIterator
...
An explicit move constructor is required to null-out the moved-from
directory descriptor. Otherwise, we would call closedir() twice when
using ErrorOr<DirIterator>::release_value().
2021-11-23 22:58:05 +01:00
Andreas Kling
5a3f5582ba
LibCore: Add try_create(...) helper to all Core::Object derived classes
...
This is like construct(...) but returns ErrorOr<NonnullRefPtr<T>>.
2021-11-23 15:44:59 +01:00
Andreas Kling
16356ca478
LibCore: Add syscall wrappers for read() and write()
2021-11-23 15:44:59 +01:00
Andreas Kling
3db9979e40
LibCore: Add syscall wrapper for stat()
2021-11-23 12:23:54 +01:00
Andreas Kling
4a213869f2
LibCore: Add syscall wrapper for ftruncate()
2021-11-23 12:23:54 +01:00
Andreas Kling
4bf08e4d52
LibCore: Add syscall wrapper for close()
2021-11-23 12:23:54 +01:00
Andreas Kling
0ed5f84bd9
LibCore: Use open() wrapper in Core::MappedFile :^)
2021-11-23 12:23:54 +01:00
Andreas Kling
50416c286d
LibCore: Add syscall wrapper for open()
2021-11-23 11:59:50 +01:00
Andreas Kling
094fa900a3
LibCore: Use mmap() and munmap() wrappers in Core::MappedFile
2021-11-23 11:51:46 +01:00
Andreas Kling
45842a5208
LibCore: Add syscall wrapper for munmap()
2021-11-23 11:51:11 +01:00
Andreas Kling
53e9b9758e
LibCore: Add syscall wrapper for mmap()
...
For convenience on SerenityOS, this also takes a custom alignment
request, and a memory region name. These are non-POSIX extensions.
2021-11-23 11:48:40 +01:00
Andreas Kling
a62d16fbe9
LibCore: Use syscall wrappers in MappedFile::map_from_fd_and_close()
2021-11-23 11:36:00 +01:00
Andreas Kling
58fb3ebf66
LibCore+AK: Move MappedFile from AK to LibCore
...
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Andreas Kling
c1a3968c66
LibCore: Make LocalSocket takeover mechanism return ErrorOr<T>
2021-11-23 11:33:36 +01:00
Andreas Kling
c37a02341b
LibCore: Add Core::System wrappers for fstat() and fcntl()
2021-11-23 11:33:36 +01:00
Andreas Kling
21a5fb0fa2
LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
...
With this change, System::foo() becomes Core::System::foo().
Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Mustafa Quraish
7720644ae2
LibCore: Let ArgsParser::parse() accept Main::Arguments
...
Instead of manually passing in `arguments.argc` and `arguments.argv`,
we can now just pass in the arguments directly.
2021-11-22 21:13:42 -08:00
qiu-x
c0a7e0ad23
LibCore: Fix LocalSocket.cpp
build on FreeBSD
...
This fixes the build on FreeBSD by chagning LOCAL_PEERPID to
LOCAL_PEERCRED inside a ifdef
2021-11-20 21:11:30 +00:00
Andreas Kling
216e21a1fa
AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
...
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling
587f9af960
AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
...
Also add slightly richer parse errors now that we can include a string
literal with returned errors.
This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Benjamin S Osenbach
d82e41440c
LibCore: Don't include crypt.h in Account.cpp on FreeBSD
...
Fixes #10803 .
2021-11-16 19:06:13 +00:00
Andreas Kling
80d4e830a0
Everywhere: Pass AK::ReadonlyBytes by value
2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485
Everywhere: Pass AK::StringView by value
2021-11-11 01:27:46 +01:00
Tim Schumacher
80cb44afae
Everywhere: Move shared library checks into a common function
...
While we're at it, unify the various different conditions that are
scattered accross the codebase.
2021-11-10 14:42:49 +01:00
Andreas Kling
0b0c4e82b9
LibCore: Replace Result<T, E> use with ErrorOr<T> in Core::FileWatcher
2021-11-08 00:35:27 +01:00
Andreas Kling
4eeab4cfc8
LibCore: Replace Result<T, E> use with ErrorOr<T> in Core::Account
2021-11-08 00:35:27 +01:00
Andreas Kling
e76b21a66f
LibCore: Use ErrorOr<T> for Core::get_password()
2021-11-08 00:35:27 +01:00
Andreas Kling
a7f1f1c34b
LibCore: Use ErrorOr<T> for Core::File::open()
2021-11-08 00:35:27 +01:00
Andreas Kling
fac2550143
LibCore: Use ErrorOr<T> for Core::File::size()
2021-11-08 00:35:27 +01:00
Andreas Kling
4a2b718ba2
LibCore: Use ErrorOr<T> for Core::File::copy_file()
2021-11-08 00:35:27 +01:00
Andreas Kling
c7e62d448c
LibCore: Use ErrorOr<T> for Core::File::remove()
...
This function returns a subclass of Error, which is now possible.
2021-11-08 00:35:27 +01:00
Andreas Kling
b2170c11a4
LibCore: Use ErrorOr<T> for Core::File::link_file()
2021-11-08 00:35:27 +01:00
Andreas Kling
e5dde37e24
AK: Bring AK::Error into the global namespace
2021-11-08 00:35:27 +01:00
Andreas Kling
e2eabb4132
LibCore: Use ErrorOr<T> in Core::AnonymousBuffer
2021-11-08 00:35:27 +01:00
Ben Wiederhake
f9167c9265
Base+LibCore: Store booleans in human-readable format
...
Fixes #10640 .
2021-11-04 23:44:02 +01:00
Tor-björn Claesson
53c8faaafc
LibCore: Trim trailing whitespaces from ConfigFile values
...
Previously, trailing whitespaces were not removed from values in
config files. This could cause errors with poorly formatted files.
This commit fixes this by trimming whitespaces from values in
ConfigFile::reparse().
2021-11-04 18:53:17 +01:00