Commit graph

1223 commits

Author SHA1 Message Date
Andreas Kling
1e4c010643 LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous
purpose was actually to load executables for the kernel, and that is
now handled by the kernel itself.

This patch includes some drive-by cleanup in LibDebug and CrashDaemon
enabled by the fact that we no longer need to keep the ref-counted
ELF::Loader around.
2020-12-25 02:14:56 +01:00
Itamar
bbedd320b5 Toolchain+LibC: Fix usage of crt files
We now configure the gcc spec files to use a different crt files for
static & PIE binaries.

This relieves us from the need to explicitly specify the desired crt0
file in cmake scripts.
2020-12-24 21:46:35 +01:00
Itamar
a83a9f3a55 Loader: Support loading non-position independent executables 2020-12-24 21:46:35 +01:00
Sahan Fernando
bcecd2fa2f DynamicLoader: Call libc's exit when exitting, to flush standard streams 2020-12-24 20:49:05 +01:00
Sahan Fernando
12f214e2f0 Userland: Make grep exit after hitting EOF on stdin 2020-12-24 20:48:54 +01:00
Sahan Fernando
3eeb00b003 Userland: Add strace parameter for output log file 2020-12-24 20:48:54 +01:00
Brendan Coles
b71edba06d Userland: Add pmap utility 2020-12-24 13:22:24 +01:00
Linus Groh
af007ce126 open: Mention full URL in 'Failed to open' error message
Just showing the URL's path is confusing, that would show '/' for
something like foo://bar.
2020-12-24 10:25:18 +01:00
Linus Groh
5bb0bd8c6d open: Handle file:// URLs properly
open(1) was able to handle most URLs as well as paths, but not file://
URLs (which occur when dragging something from the output of ls, for
example). We have to create an URL from the user-supplied argument using
create_with_url_or_path(), check whether it's a file:// URL or not and
*then* use real_path_for() on the URL's path().
2020-12-24 10:25:18 +01:00
Linus Groh
46a12e32d3 open: Remove extraneous newline from error output
This wasn't removed when fprintf was replaced by warnln.
2020-12-24 10:25:18 +01:00
Andreas Kling
8653128ca8 cp: Don't copy the set-uid or set-gid bits
Also simplify the file copying logic a bit to avoid two syscalls
per file. We now create the file with the right mode right away
instead of creating it first, and then fchmod'ing it later.

Fixes #4479.
2020-12-23 01:03:32 +01:00
Érico Nogueira Rolim
a8f0e489a4
LibCore: Rename identifiers that can clash with libc macros (#4127)
POSIX allows the default streams (stdin, stdout and stderr) to be
macros, which means that on such systems (musl libc is one) building
Lagom will fail due to the File::std*() names.

Also fix any files that use these identifiers.
2020-12-22 23:37:11 +01:00
Tom
5f51d85184 Kernel: Improve time keeping and dramatically reduce interrupt load
This implements a number of changes related to time:
* If a HPET is present, it is now used only as a system timer, unless
  the Local APIC timer is used (in which case the HPET timer will not
  trigger any interrupts at all).
* If a HPET is present, the current time can now be as accurate as the
  chip can be, independently from the system timer. We now query the
  HPET main counter for the current time in CPU #0's system timer
  interrupt, and use that as a base line. If a high precision time is
  queried, that base line is used in combination with quering the HPET
  timer directly, which should give a much more accurate time stamp at
  the expense of more overhead. For faster time stamps, the more coarse
  value based on the last interrupt will be returned. This also means
  that any missed interrupts should not cause the time to drift.
* The default system interrupt rate is reduced to about 250 per second.
* Fix calculation of Thread CPU usage by using the amount of ticks they
  used rather than the number of times a context switch happened.
* Implement CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE and use it
  for most cases where precise timestamps are not needed.
2020-12-21 18:26:12 +01:00
Brendan Coles
a3fdf5148b Userland: userdel: Resolve home directory realpath before removal 2020-12-21 12:23:50 +01:00
Brendan Coles
39c92dad83 Userland: useradd: Add command line option to set user password 2020-12-21 09:57:26 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
b30acdb4b7 LibTLS+Userland: Remove all uses of ByteBuffer::slice_view()
This was another way to get a non-owning ByteBuffer wrapper.
2020-12-19 18:29:13 +01:00
Andreas Kling
d5600e966a LibTLS+LibCrypto: Remove all remaining uses of ByteBuffer::wrap() 2020-12-19 18:29:13 +01:00
Andreas Kling
a8dbfc3398 LibCrypto: Yet more ByteBuffer::wrap() removal. Not much left now! 2020-12-19 18:29:13 +01:00
Andreas Kling
e517505e35 LibTLS: Even more ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling
f82b0a78ef LibTLS+LibCrypto: More ByteBuffer -> Span conversion 2020-12-19 18:29:13 +01:00
Andreas Kling
8e20208dd6 LibTLS+LibCrypto: Replace a whole bunch of ByteBuffers with Spans 2020-12-19 18:29:13 +01:00
Andreas Kling
685d5f4e25 LibProtocol: Remove use of ByteBuffer::wrap() in protocol API 2020-12-19 13:09:02 +01:00
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