Commit Graph

931 Commits

Author SHA1 Message Date
Xavier Defrang
6ca34f5647 mkdir: Implement --mode option
Only supports permissions given in octal format
at the moment.
2021-12-21 13:13:04 -08:00
Xavier Defrang
1255316d26 mkdir: Use LibMain 2021-12-21 13:13:04 -08:00
Timothy Flynn
10a8b6d411 Userland: Add unveil/pledge requisites for dynamic Unicode data loading
Loading libunicodedata.so will require dlopen(), which in turn requires
mmap(). The 'prot_exec' pledge is needed for this.

Further, the .so itself must be unveiled for reading. The "real" path is
unveiled (libunicodedata.so.serenity) as the symlink (libunicodedata.so)
itself cannot be unveiled.
2021-12-21 13:09:49 -08:00
Ali Mohammad Pur
f0709c7a24 LibC+AK: Implement all sorts of wprintf variants 2021-12-21 21:24:36 +03:30
Linus Groh
92672b1520 Meta: Add a fuzzer for the QOILoader 2021-12-21 13:27:27 +01:00
Linus Groh
0717e484f6 file: Add description & image details for image/x-qoi 2021-12-21 13:27:27 +01:00
Andreas Kling
bcd49ad834 touch: Port to LibMain :^) 2021-12-20 22:16:05 +01:00
PerikiyoXD
bdc028da1c cp: Print proper error message with strerror
When cp fails, now it prints an error string (strerror)
instead of an error code.
2021-12-20 10:40:02 -08:00
Junior Rantila
3d63e688f7 watch: Port to LibMain 2021-12-19 18:26:57 -08:00
Max Trussell
99b263a2db Userland/Notify: Check if optional icon arg is null before loading
The commandline "notify" application was always attempting to load an
icon path from an optional argument, even when the argument was
omitted. In this case, the image icon argument would be a null pointer
and the notify program would crash.

This fix adds a conditional to only attempt to load the icon file if
the icon_path variable is not a null pointer
2021-12-19 00:50:53 -08:00
Andreas Kling
b38f8902d2 LibCore+passwd+usermod: Make Core::Account::sync() return ErrorOr<void> 2021-12-16 22:48:17 +01:00
Andreas Kling
e5a5091b6f su: Port to LibMain :^) 2021-12-16 22:48:17 +01:00
Andreas Kling
411c696057 passwd: Use LibCore syscall wrapper for setegid() 2021-12-16 22:48:17 +01:00
Andreas Kling
99eaeedf4e usermod: Use LibCore syscall wrapper for setegid() 2021-12-16 22:48:17 +01:00
Andreas Kling
9e9662b695 pls: Port to LibMain :^) 2021-12-16 22:48:17 +01:00
sin-ack
69ef211925 Kernel+LibC: Move errno definitions to Kernel/API/POSIX
This fixes at least half of our LibC includes in the kernel. The source
of truth for errno codes and their description strings now lives in
Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-16 22:21:35 +03:30
Kenneth Myhra
a32cbf1df3 expr: Use StringView literals more (instead of raw C strings) 2021-12-16 02:10:47 -08:00
Kenneth Myhra
c5c0c7c620 expr: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
0edceb91c4 functrace: Port to LibMain and move away from raw C strings
Ports to LibMain and uses StringView more (rather than raw C strings).
2021-12-16 02:10:47 -08:00
Kenneth Myhra
160f3224a5 flock: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
54f6829533 file: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
27e63d40f1 fdtdump: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
a35f51f0f0 dirname: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
4726532735 diff: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
cd8bd27835 df: Port to LibMain 2021-12-16 02:10:47 -08:00
Kenneth Myhra
156899a63f ddate: Port to LibMain 2021-12-16 02:10:47 -08:00
Jean-Baptiste Boric
dc83fd5ee8 strace: Remove formatting support for SC_select 2021-12-12 21:48:50 +01:00
Jean-Baptiste Boric
e486d23c3f strace: Add formatting support for SC_poll 2021-12-12 21:48:50 +01:00
Jean-Baptiste Boric
809855be57 strace: Sort syscalls formatters in alphabetic order 2021-12-12 21:48:50 +01:00
Kenneth Myhra
62ddd7613c config: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
65f4d868e5 dd: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
00dbac9d16 date: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
5c15b97ca4 cut: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
7cb19b2965 cpp-processor: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
121fe820d9 cpp-parser: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
1a81d79705 cpp-lexer: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
601b60324a comm: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
d86c84a700 clear: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
6e066bf1cd cksum: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
67a18d51c7 chres: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
cc3710e19f chown: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
c8080fc2ca chgrp: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
59d299955e checksum: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Kenneth Myhra
6b6d7286b5 cal: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
David Lindbom
235a2b35d6 passwd: Port to LibMain 2021-12-11 13:16:55 -08:00
bugreport0
8a4b9c0926 passwd: Remove redundant pledge() 2021-12-11 03:17:11 -08:00
Linus Groh
038d354b5d LibJS: Remove Object::value_of()
Being really close to Object.prototype.valueOf() name wise makes this
unnecessarily confusing - while it sometimes serves as the
implementation of a valueOf() function, it's an abstraction which the
spec doesn't have.
Use the appropriate getters to retrieve specific internal slots instead,
most commonly [[FooData]] from the primitive wrapper objects.
For the Object class specifically, use the Value(Object*) ctor instead.
2021-12-10 22:52:36 +00:00
James Puleo
dd25dfbc20 js: Improve usage of TRY when executing a file program 2021-12-08 17:17:35 -08:00
Ben Wiederhake
9f91f610e2 test-crypto: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Ben Wiederhake
152d455143 strace: Handle strings more gracefully
In particular, strace can now stomach memory errors while copying
invalid strings.

Example with a valid string:
    dbgputstr("95.976 traceme(38:38) Well, Hello Friends!") = 55
Example with an invalid string:
    dbgputstr(Error(errno=14){0x00012345, 678b}) = -14 EFAULT
(ANSI escapes removed for readability.)
2021-12-05 22:59:09 +01:00
Ben Wiederhake
49adebf0fc strace: Use new PT_PEEKBUF function
This necessarily introduces some usages (and benefits!) of the new
ErrorOr<> pattern. To keep commits atomic, I do not yet rewrite the
entire program to use ErrorOr<> correctly.
2021-12-05 22:59:09 +01:00
Idan Horowitz
13dec3cdde LibC: Add a couple of missing errno codes
These are required to compile a port.
2021-12-05 12:53:29 +01:00
Idan Horowitz
e521ffd156 Kernel: Add support for the MSG_WAITALL sys$recvmsg flag 2021-12-05 12:53:29 +01:00
Idan Horowitz
5514d60d8d Kernel: Add support for the MSG_DONTROUTE sys$sendmsg flag 2021-12-05 12:53:29 +01:00
Kenneth Myhra
d465d3a457 chmod: Port to LibMain :^)
This ports chmod to LibMain + changes input parameters on several
functions from raw C strings to StringView.
2021-12-04 15:05:46 -08:00
Andreas Kling
d7a116bb0e groups: Port to LibMain :^) 2021-12-04 14:24:04 +01:00
Andreas Kling
2511da1f57 gron: Use StringView literals more (instead of raw C strings) 2021-12-04 14:24:04 +01:00
Andreas Kling
855c425719 gron: Port to LibMain :^) 2021-12-04 14:24:04 +01:00
Andreas Kling
b0659b50dc jp: Port to LibMain :^) 2021-12-04 14:24:04 +01:00
Andreas Kling
de182d4b46 stat: Modernize slightly :^)
- Port to LibMain
- Use AK::Format instead of printf()
2021-12-04 14:24:04 +01:00
Andreas Kling
0de575ec11 ls: Port to LibMain :^) 2021-12-04 14:24:04 +01:00
Tim Schumacher
0ca63cfd6e find: Implement support for multiple directories 2021-12-03 15:39:00 +01:00
Tim Schumacher
5a21c3b389 find: Use a Vector for parsing instead of moving optind 2021-12-03 15:39:00 +01:00
Tim Schumacher
4ca35ac1b8 find: Port to LibMain 2021-12-03 15:39:00 +01:00
Andreas Kling
fd2ea6923c top: Use Core::System::ioctl() 2021-11-30 23:34:40 +01:00
Andreas Kling
9815ad556a fortune: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
8ba9a54310 lspci: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
6e7ff8cf1c netstat: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
fbeebce4e3 whoami: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
cac3f3c81f top: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Timothy Flynn
6ad00088c0 js: Implement pretty-printing of Intl.DateTimeFormat 2021-11-29 22:48:46 +00:00
kleines Filmröllchen
9c40311622 Utilites: Add abench utility
abench (audio benchmark) is an audio benchmarking utility that allows
testing decoder performance.
2021-11-28 13:33:51 -08:00
kleines Filmröllchen
96d02a3e75 LibAudio: New error propagation API in Loader and Buffer
Previously, a libc-like out-of-line error information was used in the
loader and its plugins. Now, all functions that may fail to do their job
return some sort of Result. The universally-used error type ist the new
LoaderError, which can contain information about the general error
category (such as file format, I/O, unimplemented features), an error
description, and location information, such as file index or sample
index.

Additionally, the loader plugins try to do as little work as possible in
their constructors. Right after being constructed, a user should call
initialize() and check the errors returned from there. (This is done
transparently by Loader itself.) If a constructor caused an error, the
call to initialize should check and return it immediately.

This opportunity was used to rework a lot of the internal error
propagation in both loader classes, especially FlacLoader. Therefore, a
couple of other refactorings may have sneaked in as well.

The adoption of LibAudio users is minimal. Piano's adoption is not
important, as the code will receive major refactoring in the near future
anyways. SoundPlayer's adoption is also less important, as changes to
refactor it are in the works as well. aplay's adoption is the best and
may serve as an example for other users. It also includes new buffering
behavior.

Buffer also gets some attention, making it OOM-safe and thereby also
propagating its errors to the user.
2021-11-28 13:33:51 -08:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::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
f25466ae08 bt: Port to LibMain :^) 2021-11-27 11:14:16 +01:00
Kenneth Myhra
8c4625e3b1 asctl: Port to LibMain :^) 2021-11-27 11:14:16 +01:00
Kenneth Myhra
880888fcc7 aplay: Port to LibMain 2021-11-27 11:14:16 +01:00
Kenneth Myhra
494f177d22 allocate: Port to LibMain :^) 2021-11-27 11:14:16 +01:00
Andreas Kling
7341faceeb cat: Remove accidentally-committed unused macro 2021-11-27 00:48:44 +01:00
Andreas Kling
0b8fb8358e cp: Port to LibMain :^) 2021-11-26 23:27:57 +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
5bf6503ed1 cat: Use TRY() and LibCore syscall wrappers a lot more :^) 2021-11-26 23:27:57 +01:00
Kenneth Myhra
98e65f71da echo: Port to LibMain :^) 2021-11-25 21:41:46 +01:00
Kenneth Myhra
d7336879d1 basename: Port to LibMain 2021-11-25 21:41:12 +01:00
Kenneth Myhra
430e231f5e copy: Port to LibMain :^) 2021-11-25 21:41:02 +01:00
Kenneth Myhra
507de4bc1d cat: Port to LibMain :^) 2021-11-25 21:40:52 +01:00
Andreas Kling
76cb6ddfcf man: Use LibCore syscall wrappers for pipe2() and dup2() 2021-11-24 23:07:31 +01:00
Andreas Kling
1682cd10be man: Port to LibMain :^) 2021-11-24 23:07:31 +01:00
Ben Wiederhake
3e7e503dee strace: Implement get_process_name and gettid 2021-11-24 22:56:39 +01:00
Ben Wiederhake
2dd5c7d2cc strace: Implement dbgputstr syscall 2021-11-24 22:56:39 +01:00
Jelle Raaijmakers
f97c9a5968 Kernel: Allow higher audio sample rates than 65kHZ (u16)
Executing `asctl set r 96000` no longer results in weird sample rates
being set on the audio devices. SB16 checks for a sample rate between 1
and 44100 Hz, while AC97 implements double-rate support which allows
sample rates between 8kHz and 96kHZ.
2021-11-24 19:08:13 +01:00
Idan Horowitz
58397f356f js: Add command line flag for disabling source line hints 2021-11-24 18:05:24 +00:00
Idan Horowitz
15fafdc645 js: Pretty-print custom error types 2021-11-24 18:05:24 +00:00
Idan Horowitz
11d1950e74 js: Add command line flag for disabling ANSI colors 2021-11-24 18:05:24 +00:00
Andreas Kling
ca23644397 logout: Port to LibMain :^) 2021-11-24 00:25:22 +01:00
faxe1008
02a7cfaad6 usermod: Port to LibMain 2021-11-23 22:54:25 +01:00
faxe1008
b49bed5152 userdel: Port to LibMain 2021-11-23 22:54:25 +01:00
faxe1008
b2e7102194 lsusb: Port to LibMain 2021-11-23 22:54:25 +01:00
faxe1008
097c1e5335 blockdev: Port to LibMain 2021-11-23 22:54:25 +01:00
faxe1008
b918e798e6 base64: Port to LibMain 2021-11-23 22:54:25 +01:00
faxe1008
f47d92af72 arp: Port to LibMain 2021-11-23 22:54:25 +01:00
Andreas Kling
6386b54746 dmesg: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Andreas Kling
e6579e7029 ps: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Andreas Kling
120168203e keymap: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Andreas Kling
8b5c0e8e71 pmap: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Andreas Kling
03b6ff2bf0 utmpupdate: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Andreas Kling
d117c4cccc truncate: Add a basic set of pledge promises 2021-11-23 12:31:21 +01:00
Andreas Kling
9eb7030b55 truncate: Port to LibMain and use LibCore syscall wrappers :^) 2021-11-23 12:27:33 +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
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
2fbcab46bf Everywhere: Use ArgsParser::parse() with Main::Arguments directly
Use the updated API everywhere we are currently manually passing in
`arguments.argc` and `arguments.argv`.
2021-11-22 21:13:42 -08:00
Linus Groh
8fa5dc7241 js: Use pledge()
It is now no longer possible to make network connections from a hijacked
js(1) :^)
2021-11-22 23:07:43 +01:00
Linus Groh
cfecfbb214 js: Port to LibMain :^)
This wasn't particularly difficult, and there's not much use for the
nicer interface yet either. While unveil() is of limited use in js(1)
as it should be able to open arbitrary files, I feel like we should be
able to add a pledge() call.
2021-11-22 23:07:43 +01:00
Tim Schumacher
75978d5fff tar: Support extracting symlinks
We can now extract GitHub's LLVM tarballs. :^)
2021-11-22 21:57:42 +01:00
Andreas Kling
f5927f167b nproc: Port to LibMain :^) 2021-11-22 19:43:26 +01:00
Andreas Kling
561e50108d w: Port to LibMain :^)
This unlocked a bunch of TRY() opportunities. Not just system calls, but
also Core::File::open() and JsonValue::from_string().
2021-11-22 19:40:27 +01:00
Andreas Kling
843262497a id: Port to LibMain :^)
This is a first port of a simple program to LibMain. A bunch of code is
immediately simplified thanks to the LibSystem wrappers and ability to
use TRY(). This is pretty cool!
2021-11-22 19:28:31 +01:00
Tim Schumacher
0d679bf348 tar: Implement usage of prefixes when extracting 2021-11-22 09:03:47 +01:00
Ben Wiederhake
d5c687b50f kcov-example: Print helpful error if kcov feature is missing 2021-11-21 13:52:25 +01:00
Ben Wiederhake
253d62cb18 SystemServer+kcov-example: Make /dev/kcov0 available again
Apparently this device entry got lost while converting to DevTmpFS.
2021-11-21 13:52:25 +01:00
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Itamar
7950f5cb51 LibDebug: Add ProcessInspector base class
ProcessInspector is an abstract base class for an object that can
inspect the address space of a process.

Concrete sub classes need to implement methods for peeking & poking
memory and walking the loaded libraries.

It is currently only implemented by DebugSession.
2021-11-20 21:22:24 +00:00
Pankaj Raghav
0e873464ed Hexdump: Add verbose option
Verbose option overrides the default coalescing
behaviour by displaying the complete output.
2021-11-19 12:17:57 +03:30
Pankaj Raghav
d72158045c Hexdump: Allow identical lines to coalesce
Coalesce feature is enabled by default when using
the program. Any number of lines identical to the preceding line
will be replaced by a single asterik.
2021-11-19 12:17:57 +03:30
davidot
22e679d844 LibJS + js: Rethrow exception on the vm after bytecode interpreter run
When the bytecode interpreter was converted to ThrowCompletionOr<Value>
it then also cleared the vm.exception() making it seem like no exception
was thrown.
Also removed the TRY_OR_DISCARD as that would skip the error handling
parts.
2021-11-17 13:12:05 +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
faxe1008
06cb526feb config: Add option to remove config key 2021-11-14 22:42:52 +01:00
Tim Schumacher
2e8330f78c Utilities/tr: Rework squeezing to be supported during more operations 2021-11-13 23:34:49 +01:00
Tim Schumacher
6fe37a1e52 Utilities/grep: Implement using multiple patterns 2021-11-13 11:42:26 +01:00
Tim Schumacher
c94574d313 Utilities/tar: Ignore directory entry if it already exists 2021-11-13 11:42:08 +01:00
Tim Schumacher
c81cef614a Utilities/grep: Implement line-counting mode 2021-11-12 21:29:18 +00:00
Tim Schumacher
7ce693840b Utilities/tr: Implement squeezing repeated characters 2021-11-12 21:23:29 +00:00
Ali Mohammad Pur
070d2eaa51 LibJS+LibTest+js: Convert BC::Interpreter::run to ThrowCompletionOr<>
Note that this is just a shallow API change.
2021-11-12 13:01:59 +00:00
Tim Schumacher
ba29798039 Utilities: cut: Implement field-based cutting 2021-11-11 09:47:41 +01:00
Tim Schumacher
96ea4f71bd Utilities: cut: Split up into file and line processing 2021-11-11 09:47:41 +01:00
Tim Schumacher
4d18b21fb5 Utilities: cut: Work exclusively with ranges 2021-11-11 09:47:41 +01:00
Tim Schumacher
ed3a5f6b9d Utilities: cut: Move string splitting into expand_list 2021-11-11 09:47:41 +01:00
Tim Schumacher
2358f6cbda Utilities: cut: Migrate to ArgsParser 2021-11-11 09:47:41 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a15ed8743d AK: Make ByteBuffer::try_* functions return ErrorOr<void>
Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
2021-11-10 21:58:58 +01:00
Tim Schumacher
bd6c48f6ea Utilities: tar: Always create parent directory when extracting 2021-11-10 14:48:20 +01:00
Ben Wiederhake
4512e89159 strace: Interpret errno codes for pointer-like return codes 2021-11-10 14:47:31 +01:00
Ben Wiederhake
81b6be4bf4 strace: Switch to new flag handler, support more flags
In particular, strace now supports all O_*, MSG_*, MAP_*, and PROT_*
flags, as well as a more context-dependent default value (e.g.
"PROT_NONE").
2021-11-10 14:47:31 +01:00
Ben Wiederhake
491ed375fc strace: Better support for bitflags, show unrecognized flags 2021-11-10 14:47:31 +01:00
faxe1008
100e25d1d3 pape: Add set-random option 2021-11-08 16:36:02 -08: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
4a2b718ba2 LibCore: Use ErrorOr<T> for Core::File::copy_file() 2021-11-08 00:35:27 +01:00