Commit graph

1200 commits

Author SHA1 Message Date
Brendan Coles
853664bd3c LibC: stdlib: Add clearenv() function 2020-12-17 19:39:56 +01:00
Andreas Kling
56701f91f9 ln: Make the 'path' argument optional
If 'path' is omitted, we create a link with the basename of whatever
the target is. This matches what other systems do.
2020-12-16 23:26:35 +01:00
Brendan Coles
b9d99849ad Userland: Add beep utility 2020-12-16 17:29:28 +01:00
Itamar
d2a984f2c7 Loader: Don't re-load self-dependant libraries 2020-12-14 23:05:53 +01:00
Itamar
72ca45e300 UserspaceEmulator: Support dynamically loaded programs
When loading dynamic objects, the emulator loads the interpreter,
generates an auxiliary vector and starts executing the loader.

Additionally, this commits also makes the MallocTracer and backtrace
symbolication work for dynamically loaded programs.
2020-12-14 23:05:53 +01:00
Itamar
f12e13e81c Loader: Take main program name from auxiliary vector 2020-12-14 23:05:53 +01:00
Itamar
efe4da57df Loader: Stabilize loader & Use shared libraries everywhere :^)
The dynamic loader is now stable enough to be used everywhere in the
system - so this commit does just that.
No More .a Files, Long Live .so's!
2020-12-14 23:05:53 +01:00
Itamar
07b4957361 Loader: Add dynamic loader program
The dynamic loader exists as /usr/lib/Loader.so and is loaded by the
kernel when ET_DYN programs are executed.

The dynamic loader is responsible for loading the dependencies of the
main program, allocating TLS storage, preparing all loaded objects for
execution and finally jumping to the entry of the main program.
2020-12-14 23:05:53 +01:00
Linus Groh
b04e0a7677 jp: Remove trailing comma at end of object/array to make output valid JSON
It's ironic that `jp` currently refuses to parse its own output :^)
2020-12-14 20:25:01 +01:00
Linus Groh
c07176bd53 jp: Only output colors when stdout is a TTY 2020-12-14 20:25:01 +01:00
Linus Groh
e68f4111ea jp: Use new format functions 2020-12-14 20:25:01 +01:00
Andreas Kling
22c582a887 LibWeb: Make HTMLDocumentParser take an existing document
We shouldn't really be creating the document objects inside the parser,
since that makes it hard to hook up e.g JavaScript bindings early on.
2020-12-13 16:59:22 +01:00
Andreas Kling
b9b7b2b28a LibCore: Make IODevice::read_line() return a String
Almost everyone using this API actually wanted String instead of a
ByteBuffer anyway, and there were a bunch of slightly different ways
clients would convert to String.

Let's just cut out all the confusion and make it return String. :^)
2020-12-13 11:54:11 +01:00
Tom
bcb9363a97 LibPthread: Return errors as positive return values
pthread implementations generally return errors as a positive non-zero
value. Our kernel generally returns errors as negative values. If we
receive a negative value from a system call, turn it into a positive
return value to relay the error appropriately.

Also, fix the tt test utility to not rely on errno, as the pthread
library does not use errno.
2020-12-12 21:28:12 +01:00
Sahan Fernando
9453032bf6
Userland: Fix overly-eager loop detection in cp (#4368)
The bug is that if you try to cp DIR_A to DIR_B where DIR_A and DIR_B
have the same parent directory and DIR_A's name is a prefix of DIR_B
(e.g. foo -> foo2, bar -> barbar), it thinks that it's a subdirectory
(since it checks if DIR_A's realpath is a prefix of DIR_B's realpath).

The easiest solution is to put a path delimiter at the end before the
comparison, since you can't have a / in the middle of a directory name.

For example if DIR_A is /home/anon/foo and DIR_B is /home/anon/foo2,
then DIR_A's realpath is a prefix of DIR_B's realpath even though DIR_B
is not inside DIR_A.
2020-12-09 20:56:50 +01:00
Sahan Fernando
a3bcff0db8 Userland: Fix segfault in sort 2020-12-09 20:55:06 +01:00
Ben Wiederhake
8f392683c7 Userland: Fix typo in 'pro' help 2020-12-06 15:50:02 +01:00
Ben Wiederhake
4ec77ba929 Userland: Write some '--help' descriptions where appropriate 2020-12-06 00:06:53 +01:00
Linus Groh
745801e109 js: Improve pretty-printing of various objects
For many object types we only ever used the regular print_object() in
the js REPL - resulting in a useless "{  }".

This patch adds more individual representations for the following types:
- Boolean/Number/String object: print wrapped value
- ArrayBuffer: print byteLength and hex-formatted bytes in chunks of 16
- TypedArray: print length, byteLength, buffer pointer and values
- Proxy: print target and handler

Also improve the existing pretty-printing output:
- More consistency, most objects now follow the format "[Type] ..."
- Some coloring tweaks
- No two spaces in empty arrays & objects

Possible future improvements:
- Add line breaks between elements of long arrays & objects

Closes #4310.
2020-12-05 10:05:28 +01:00
Linus Groh
1fab67ea52 test-js: Use new format functions 2020-12-03 21:55:02 +01:00
Linus Groh
7cbdf465ba test-js: Set test root correctly when specified as positional arg
When a test root path was given to test-js it was never used, causing
test-js to always fail.
2020-12-03 21:55:02 +01:00
Julian Offenhäuser
bad8cd3d8f Applications+Userland: Switch to new Audio::Loader API 2020-12-02 16:31:30 +01:00
Tom
046d6855f5 Kernel: Move block condition evaluation out of the Scheduler
This makes the Scheduler a lot leaner by not having to evaluate
block conditions every time it is invoked. Instead evaluate them as
the states change, and unblock threads at that point.

This also implements some more waitid/waitpid/wait features and
behavior. For example, WUNTRACED and WNOWAIT are now supported. And
wait will now not return EINTR when SIGCHLD is delivered at the
same time.
2020-11-30 13:17:02 +01:00
AnotherTest
b45f3ea0f8 Userland: Implement -I/-a (binary-mode) and -i (insensitive) for grep
This fixes #4195 and closes #4196.
2020-11-29 20:32:10 +01:00
AnotherTest
129a58a2e5 LibCore: Do not try to null-terminate a ByteBuffer in read_line()
That's just silly :)
Also fix that one use of read_line() which assumes it will
null-terminated in mount.cpp (this would've blown up if the IODevice was
at EOF and had a line with the same size as max_size).
2020-11-29 20:32:10 +01:00
Lenny Maiorani
a34939bcd5
Tests/Kernel: Remove redundant if (#4111)
Problem:

- If `fork()` fails the system tries to call `execl()`. That will
  either succeed and replace the running process image or it will fail
  and it needs to try again. The `if` is redundant because it will
  only be evaluated if `execl()` fails.

Solution:
- Remove the `if`.
2020-11-29 10:41:02 +01:00
AnotherTest
ee548ca5b9 Userland: Make mv capable of moving multiple files
Closes #4188.
2020-11-29 10:14:43 +01:00
Sergey Bugaev
952c0dc2a0 Userland: Implement find -name clause
Closes https://github.com/SerenityOS/serenity/issues/4191
2020-11-28 14:28:58 +01:00
Brendan Coles
2adcdbcc1e Tests: Add Kernel tests for unveil system call browse 'b' flag 2020-11-28 10:08:00 +01:00
AnotherTest
3200ff5f4f LibJS+js: Rename RegExp.{content => pattern}
The spec talks about it as 'pattern', so let's use that instead.
2020-11-27 21:32:41 +01:00
AnotherTest
45e5661296 Userland: Add support for 'match' in 'expr' 2020-11-27 21:32:41 +01:00
Emanuel Sprung
12dd40a2a5 Userland: Add grep utility
Grep supports only extended regular expressions, and is able to handle one pattern
handed over via -e or directly after the options. Also, multiple files can be
handed over. Recursive mode is outstanding, but no real magic :^)
2020-11-27 21:32:41 +01:00
Andreas Kling
ffa4405083 LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate()
Also fix up some misleading error messages in the 'tt' test program.
2020-11-26 19:33:44 +01:00
Andreas Kling
a5e560ee49 test-js: Don't keep a pointer to a temporary String's characters
This was only an issue in the Lagom build.
2020-11-26 19:33:35 +01:00
Sergey Bugaev
b1fd06eb4c Userland: Add a test for pthread_once() 2020-11-24 21:36:28 +01:00
BenJilks
91b2af34e1 base64: Fix not outputting all decoded data
It would use printf to output the data, so if it contains a null
terminator it'll stop.
2020-11-22 16:07:00 +01:00
Lenny Maiorani
446a19ba51
test-crypto: Remove foo.response file created by testing (#4110)
Problem:
- Test creates a file and leaves it in the source tree.

Solution:
- Remove the creation of the file since it is never checked.
2020-11-20 21:18:43 +01:00
Spencer Dixon
f23d9a73aa Userland: Add -v verbose flag to 'rm' 2020-11-17 09:40:03 +01:00
Spencer Dixon
2dab9d4bac Userland: Add -v verbose flag to 'mv' 2020-11-17 09:40:03 +01:00
Spencer Dixon
7ba28b5b0b Userland: Add -v verbose flag to 'cp' 2020-11-17 09:40:03 +01:00
Andreas Kling
adabcf24ec Everywhere: Add missing <AK/ByteBuffer.h> includes
All of these files were getting ByteBuffer.h from someone else and then
using it. Let's include it explicitly.
2020-11-15 13:11:21 +01:00
Brendan Coles
d739483ee8 Userland: Tests: Use mkstemp temporary files in tests 2020-11-15 00:50:57 +01:00
Brendan Coles
f8c980a06b Userland: chroot: Add --userspec/-u flag to set uid/gid for chroot 2020-11-14 17:14:30 +01:00
AnotherTest
d3c52cef86 LibCrypto: Implement GCM mode 2020-11-14 10:18:54 +01:00
AnotherTest
2cc867bcba test-crypto: Silence the "creating bytebuffer..." debug 2020-11-14 10:18:54 +01:00
Brendan Coles
664322d34b Userland: Add test-gfx-font for Gfx::Font tests 2020-11-14 10:08:25 +01:00
Nico Weber
5c2e8b6189 Lagom: Add ntpquery to lagom build 2020-11-12 21:21:33 +01:00
Brendan Coles
7a512c4cc4 Userland: env: Add -i / --ignore-environment arg to clear env 2020-11-12 18:01:45 +01:00
Linus Groh
7fc98a96a9 test-js: Add canParseSource() native function
This allows us to check code for syntax errors without relying on
Function(), which can lead to false negatives as certain things are
valid in a function context, but not outside one.
2020-11-12 10:14:57 +01:00
Brendan Coles
549786e89a Userland: Add test for file SUID+SGID bits stripped when modified 2020-11-11 21:27:29 +01:00