Commit Graph

911 Commits

Author SHA1 Message Date
Michel Hermier
69cabb3ead Everywhere: Add serenity_dev_{makedev,major,minor}
Add them in `<Kernel/API/Device.h>` and use these to provides
`{makedev,major,minor}` in `<sys/sysmacros.h>`. It aims to be more in
line with other Unix implementations and avoid code duplication in user
land.
2022-01-09 00:58:44 +01:00
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
Andreas Kling
95df924e0e Kernel: Remove EWHYTHO error code :^)
This error code was a hack for catching error handling mistakes in the
kernel. It's no longer used anywhere.
2022-01-08 20:10:58 +01:00
Rummskartoffel
ba0d46e31a gzip: Don't fail when trying to compress empty files
Given an empty file, gzip would try to create a zero-size memory mapping
of that file, which would fail with EINVAL.
2022-01-08 15:29:38 +01:00
Rummskartoffel
748218d5d0 gzip: Port to LibMain 2022-01-08 15:29:38 +01:00
Marcus Nilsson
d2b99010e4 jp: Use File::standard_input() when reading from stdin
Trying to open '/dev/stdin' resulted in ENOENT. Instead use the
standard_input() helper to get the File.
2022-01-08 06:19:09 -08:00
Liav A
ff25958b51 Userland: Introduce the pmemdump utility
This utility helps to dump the physical memory space from /dev/mem.
It supports both read(2) and mmap(2) on it so we could use mmap(2) for
fast dumping of the memory, or read(2) when we need to read unaligned
physical regions.
2022-01-08 13:21:16 +02:00
Rummskartoffel
f9c4f65e1f less: Fix crash on empty input 2022-01-08 11:56:37 +01:00
Julian Eigmüller
fec0829c86 man: Fix error handling when section is specified
Previously, man would only check if a path is not associated with a
manpage when no section was specified via the command line.

So `man gibberish` would fail with "no man page for gibberish", but `man
2 gibberish` would fail with a runtime error and still open a pipe to
  the pager leading to a nasty crash.

Moving the check outside the "if (!section)" block fixes this.

Also: if a section is specified, the error message now echoes it back
(no manpage for foo in section bar).
2022-01-07 21:31:46 +01:00
mjz19910
10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Brian Gianforcaro
6bf91d00ef run-tests: Make reproducing test failures behave closer to selftest mode
In CI / or local testing when you run `serenity.sh tests`, the system
will boot itself in self test mode, and the test runner will be launched
by SystemServer. Previously we were setting up settings for that
environment in the `SystemServer.ini`. This makes reproducing CI
failures a bit confusing, as the system will behavior differently if you
run in self-test mode, vs running `run-tests-and-shutdown.sh` or
`run-tests` manually in a session.

This change moves the settings to `run-tests`, so no matter how you try
to run the test runner, it will always behave the same.
2022-01-07 01:19:09 -08:00
Lucas CHOLLET
080c3164c7 du: Display true size of directory instead of 4 KiB
For each directory, we now go through each file and sum-up the contents.
2022-01-06 18:19:31 +01:00
RasmusNylander
4e65c4dae4 LibKeyboard: Change some Optional<T> returns to ErrorOr<T>
Makes CharacterMapFile::load_from_file and CharacterMap::load_from_file
return ErrorOr instead of Optional. This makes them a little nicer to
use and a little easier to read, as they seem to have been approximating
this.
2022-01-06 17:54:03 +01:00
Jun Zhang
0ac7931545 Utilities/ln: Port to LibMain
This patch simply ports the utility ln to LibMain :^)
2022-01-06 13:32:22 +01:00
Linus Groh
9d0d3affd4 LibJS: Replace the custom unwind mechanism with completions :^)
This includes:

- Parsing proper LabelledStatements with try_parse_labelled_statement()
- Removing LabelableStatement
- Implementing the LoopEvaluation semantics via loop_evaluation() in
  each IterationStatement subclass; and IterationStatement evaluation
  via {For,ForIn,ForOf,ForAwaitOf,While,DoWhile}Statement::execute()
- Updating ReturnStatement, BreakStatement and ContinueStatement to
  return the appropriate completion types
- Basically reimplementing TryStatement and SwitchStatement according to
  the spec, using completions
- Honoring result completion types in AsyncBlockStart and
  OrdinaryCallEvaluateBody
- Removing any uses of the VM unwind mechanism - most importantly,
  VM::throw_exception() now exclusively sets an exception and no longer
  triggers any unwinding mechanism.
  However, we already did a good job updating all of LibWeb and userland
  applications to not use it, and the few remaining uses elsewhere don't
  rely on unwinding AFAICT.
2022-01-06 12:36:23 +01:00
mjz19910
1f1383fe1e unzip: Remove useless .characters() calls 2022-01-04 23:53:46 -08:00
mjz19910
2351bb2db9 Utilities/CMakeList: Remove duplicate target_link_libraries(...) 2022-01-04 19:14:57 -08:00
mjz19910
87b719a494 Utilities/CMakeList: Sort target_link_libraries(...) 2022-01-04 19:14:57 -08:00
Linus Groh
9e50bd91a6 js: Remove uses of TRY_OR_DISCARD()
Slightly more verbose, but that's the last user of TRY_OR_DISCARD gone!
2022-01-04 23:37:26 +00:00
Marco Cutecchia
732e41714a ls: Fix duplicated error message when opening a directory fails 2022-01-04 22:47:57 +01:00
Marco Cutecchia
70f707d806 stat: Print an error if 'stat' fails 2022-01-04 22:47:57 +01:00
Michel Hermier
22efc34ec5 LibCrypto: Make Digests able to return bytes 2022-01-05 01:07:21 +03:30
Michel Hermier
25251f1b05 checksum: Use :hex-dump to format digest value 2022-01-05 01:07:21 +03:30
Michel Hermier
23fe07a148 checksum: Make name detection working even with a path 2022-01-05 01:07:21 +03:30
mjz19910
154d33f240 unzip: Port to LibMain 2022-01-04 10:59:42 +00:00
mjz19910
7c05db19a1 zip: Port to LibMain :^) 2022-01-04 10:59:42 +00:00
Mathieu PATUREL
571d090609 profile: Specify the /proc/profile path in the help message 2022-01-04 07:56:54 +00:00
Mathieu PATUREL
cdbcb70913 profile: Don't print anything when disabling profiling
Just like when enabling profiling. Plus it's more unixy to not print
anything on success
2022-01-04 07:56:54 +00:00
Andrew Kaster
f8ea9cd64e Userland: Resolve unused-but-set-varaible warnings
These are almost always bugs, so enable globally.

Remove unused counter variables in SystemMonitor and disk_benchmark.
2022-01-04 07:51:31 +00:00
Andrew Kaster
170a7e263c Userland: Fail Core::find_executable_in_path on empty inputs
Before this patch, `which ""` or `type ""` would say that the empty
string is `/usr/local/bin/`.

Convert callers to consistently call is_empty() on the returned string
while we're at it, to support eventually removing the is_null() String
state in the future.
2022-01-04 07:38:42 +00:00
mjz19910
7f9bd34d07 wc: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
fc78bbe78c which: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
92493b210a wsctl: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
d4748c608c xargs: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
f705f57d9a yes: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
e9a15995fd uname: Port to LibMain 2022-01-04 07:33:23 +00:00
mjz19910
35cd7c9a91 uniq: Port to LibMain 2022-01-04 07:33:23 +00:00
circl
69c757e92f tar: Implement -C option
This allows specifying which directory to extract to or create
from.

I would have used the *at variants of the functions, but some
weren't implemented yet.
2022-01-04 06:22:34 +00:00
Linus Groh
85f0fc2b83 LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}()
and having to check those first, and then making another Optional from
the unwrapped value:

    completion.has_value() ? completion.value() : Optional<Value> {}
    //                       ^^^^^^^^^^^^^^^^^^
    //         Implicit creation of non-empty Optional<Value>

This way we need to unwrap the optional ourselves, but can easily pass
it to something else as well.

This is in anticipation of the AST using completions :^)
2022-01-03 21:50:50 +01:00
Andreas Kling
c6ce606e47 LibCore+id: Make more use of Core::System wrappers in Core::Account 2022-01-02 18:08:02 +01:00
Lucas CHOLLET
4d557a4b81 rm: Check before removing '/'
A simple check to not erase '/' by mistake.
2022-01-02 17:37:35 +01:00
mjz19910
cd7b50a074 uptime: Port to LibMain :^) 2022-01-02 09:42:56 +00:00
Xavier Defrang
b17fef5133 mkdir: Use FilePermissionsMask to handle mode option 2022-01-01 17:33:43 +00:00
Xavier Defrang
005b0f7384 chmod: Use FilePermissionsMask to handle mode argument 2022-01-01 17:33:43 +00:00
circl
4b40d2cc07 chown+chgrp: Add --no-dereference option
This option will change the ownership of the symlink rather than the
file it points to.
2022-01-01 15:08:49 +01:00
Kenneth Myhra
22c27e1ba9 fgrep: Port fgrep to LibMain 2022-01-01 14:40:41 +01:00
Kenneth Myhra
8aafe6cd1f errno: Port to LibMain 2022-01-01 14:40:41 +01:00
Kenneth Myhra
2e0f53c25d du: Port to LibMain
This ports 'du' utility to LibMain. Also moves to use StringView and
StringView literals more instead of raw C strings.
2022-01-01 14:40:41 +01:00
davidot
676554d3f8 LibJS: Convert resolve_binding() to ThrowCompletionOr
The spec has a note stating that resolve binding will always return a
reference whose [[ReferencedName]] field is name. However this is not
correct as the underlying method GetIdentifierReference may throw on
env.HasBinding(name) thus it can throw. However, there are some
scenarios where it cannot throw because the reference is known to exist
in that case we use MUST with a comment.
2021-12-30 15:29:33 +01:00
creator1creeper1
dfaa6c910c Utilities/lsusb: Propagate errors in JSON decoding 2021-12-30 14:37:02 +01:00