Commit graph

12894 commits

Author SHA1 Message Date
AnotherTest
da1b080935 LibLine: Make ^R search match the input anywhere in a given line
This is closer to what other line editors (and shells) do, and makes ^R
actually useful.
2020-09-07 11:42:56 +02:00
AnotherTest
da56e208ef LibLine: Disable editing events while searching
This also makes the editor clean as many lines as the searching took,
for instance, in the case of <C-r><C-c>ls<tab>, two lines should be
cleaned, not just one.

Fixes #3413.
2020-09-07 11:42:56 +02:00
Nico Weber
e8131f503d Kernel: Let TimeManagement keep epoch time as timespec
Previously, it was kept as just a time_t and the sub-second
offset was inferred from the monotonic clock. This means that
sub-second time adjustments were ignored.

Now that `ntpquery -s` can pass in a time with sub-second
precision, it makes sense to keep time at that granularity
in the kernel.

After this, `ntpquery -s` immediately followed by `ntpquery` shows
an offset of 0.02s (that is, on the order of network roundtrip time)
instead of up to 0.75s previously.
2020-09-07 11:22:48 +02:00
Nico Weber
4ac5cc2461 ntpquery: Compute and print delay and offset 2020-09-07 11:22:48 +02:00
AnotherTest
39d14c22d1 LibLine: Treat ^D as EOF only when the buffer is empty
As opposed to when the cursor is at the start of the buffer.
Fixes #3421.
2020-09-07 11:21:28 +02:00
Andreas Kling
18ff9c3fc2 Meta: Fix shellcheck whines in check-symbols.sh 2020-09-07 00:00:12 +02:00
Andreas Kling
638790c9a4 Travis: Fix wrong path to Meta/check-symbols.sh 2020-09-06 23:49:19 +02:00
AnotherTest
02f251bb4a LibGUI: Fix OOB read in Clipboard::set_data() 2020-09-06 22:22:17 +02:00
Muhammad Zahalqa
125ea6a214 AK: Vector use Traits<T>::equals in find
Use Traits<T>::equals for equality checking in search
functions instead of  operator==
2020-09-06 21:56:32 +02:00
Muhammad Zahalqa
ad3e6ef344 AK: SinglyLinkedList use Traits<T>::equals in find
Use Traits<T>::equals for equality checking in search
functions instead of  operator==
2020-09-06 21:56:32 +02:00
Nico Weber
f1a6884a51 ntpquery: Add a -s flag to make it adjust the time 2020-09-06 21:50:55 +02:00
Nico Weber
0fff4e11a6 LibC: Add settimeofday 2020-09-06 21:50:55 +02:00
Nico Weber
0736ae4116 ntpquery: Use time.google.com as default NTP server for now
Using a pool.ntp.org server seems nicer and more open-source-y,
but until our pool use is approved, let's put in a default value
that works.

(time.google.com serves smeared time instead of doing leap seconds.
pool.ntp.org doesn't serve smeared time. I intend to implement
client-side leap second smearing since nobody likes jumpy timestamps.
For now, we get this for free.)
2020-09-06 21:50:55 +02:00
Nico Weber
8016b2c546 ntpquery: Record destination timestamp as well 2020-09-06 21:50:55 +02:00
Itamar
1c20e684f3 Travis: Run script that checks for forbidden symbols in LibC
check-symbols.sh fails the build if undefined __cx_guard_* symbols are
found in  LibC.

This will help us catch port breakage sooner.
2020-09-06 21:36:36 +02:00
Itamar
542f665b27 LibC: Avoid generating calls to__cxa_guard_* functions in netdb.cpp
g++ seems to generate calls to __cxa_guard_* functions when we use
non-trivial initialization of local statics.
Requiring these symbols breaks some ports since these symbols are
defined in libcstdc++ which we do not link against when building ports.

This commit turns some local statics into global statics in netdb.cpp so
libc wouldn't need these symbols.
2020-09-06 21:36:36 +02:00
Itamar
c5b0e0b96b LibC: Don't include things required for getopt_long in unistd.h
Previously, we were including the whole of <getopt.h> in <unistd.h>.
However according to the posix <unistd.h> doesn't have to contain
everything we had in <getopt.h>.

This fixes some symbol collisions that broke the git port.
2020-09-06 21:36:36 +02:00
Tom
efac3d27d2 AK: Add Bitmap::count_in_range and Bitmap::fill_range 2020-09-06 21:20:08 +02:00
asynts
cd2815ed87 AK: Add LogStream overload for ReadonlyBytes.
This is extremely useful for debugging.
2020-09-06 20:47:35 +02:00
Andreas Kling
bc48181939 Userland: Add missing license headers to "w" and "utmpupdate" 2020-09-06 20:44:16 +02:00
Andreas Kling
4e2ccde85a Userland: Shorten "w" idle time format
Let's just say "123s" for now (instead of "123 sec")
2020-09-06 19:13:52 +02:00
Andreas Kling
6dc5cda50d Userland: Bring back improved "LOGIN@" column in "w"
This actually looks a lot nicer if we slim down the datetime format.
Also remove the "FROM" column which was the one I actually didn't want.
2020-09-06 19:13:00 +02:00
Andreas Kling
c995166c56 utmpupdate: Store the login time in /var/run/utmp as a Unix timestamp
This is obviously nicer and makes it easy for other programs to do what
they want with the timestamp.
2020-09-06 19:08:09 +02:00
Andreas Kling
d531b4fa61 Userland: Show the current foreground process name in "w" output
Add a "WHAT" column that shows which command is currently executing in
each active session. Very neat :^)
2020-09-06 19:05:08 +02:00
Andreas Kling
6d8c4af9c2 LibCore+top: Use pid_t for pgid/pgrp/sid numbers 2020-09-06 19:04:47 +02:00
Andreas Kling
5a934c37cf Userland: Remove "LOGIN@" column from "w" since it's not really useful
Maybe we can bring this back once we have remote logins, or at least
make it optional then. At the moment, it's not very interesting.
2020-09-06 18:59:56 +02:00
Andreas Kling
abce7e7ca2 Userland: Show idle times in "w" output
The idle time is based on the mtime of the session's TTY :^)
2020-09-06 18:58:58 +02:00
Andreas Kling
4527d9852a Kernel: Track time-of-last-write in SlavePTY and report it as mtime 2020-09-06 18:48:24 +02:00
Andreas Kling
ae9c5bf216 Userland: Tweak "w" output just slightly 2020-09-06 18:48:00 +02:00
Andreas Kling
48a0b76a77 Kernel: Make File weakable
This will be useful for some things. This also removes the need for
TCPSocket to be special about this.
2020-09-06 18:46:46 +02:00
Andreas Kling
22831033d0 Kernel: Virtualize the File::stat() operation
Instead of FileDescriptor branching on the type of File it's wrapping,
add a File::stat() function that can be overridden to provide custom
behavior for the stat syscalls.
2020-09-06 18:31:51 +02:00
Andreas Kling
5444cabd39 Kernel: Rename FileDescription::fstat() => stat() 2020-09-06 18:17:07 +02:00
Andreas Kling
c14de7da99 Kernel: Remove bogus FIXME in TTY::write()
Failure to send SIGTTOU to the current process is not something that
should cause write() to fail with -ESRCH.
2020-09-06 18:13:04 +02:00
Andreas Kling
8e489b451a Userland: Add a simple 'w' program that shows current terminal sessions
This fetches information from /var/run/utmp and shows the interactive
sessions in a little list. More things can be added here to make it
more interesting. :^)
2020-09-06 16:16:10 +02:00
Andreas Kling
3c49a82ae9 Terminal: Use utmpupdate to update /var/run/utmp
We now put entries for interactive terminal sessions in the utmp file.
They are removed when you exit the terminal.
2020-09-06 16:15:51 +02:00
Andreas Kling
171bfcff36 utmpupdate: Use pledge() and unveil() 2020-09-06 16:14:27 +02:00
Andreas Kling
dcd47655d0 utmpupdate: Add a program for updating /var/run/utmp
To keep track of ongoing terminal sessions, we now have a sort-of
traditional /var/run/utmp file, like other Unix systems.
Unlike other Unix systems however, ours is of course JSON. :^)

The /bin/utmpupdate program is used to update the file, which is
not writable by regular user accounts. This helper program is
set-GID "utmp".
2020-09-06 16:10:27 +02:00
Andreas Kling
35b844ba4c LibCore: Add Core::IODevice::truncate()
This is just a wrapper around ftruncate(). Today I also learned that
ftruncate() does not reset the file descriptor offset. :^)
2020-09-06 16:09:26 +02:00
Andreas Kling
9dafbc82ff AK: Add JsonObject::remove() 2020-09-06 16:09:09 +02:00
Andreas Kling
8a6a9a8fb6 LibWeb: Move DOM event dispatch to its own class
For now, the new DOM::EventDispatcher is very simple, it just iterates
over the set of listeners on an EventTarget and invokes the callbacks
as it goes.

This simplifies EventTarget subclasses since they no longer have to
implement the callback mechanism themselves.
2020-09-06 14:48:14 +02:00
AnotherTest
521475dc01 LibLine: Do not reset suggestion state immediately when encountering esc
Some multikey binding might depend on the suggestion state, and this is
indeed the case for 'reverse tab', which is just '^[[Z'.
Fixes #3407.
2020-09-06 13:00:02 +02:00
asynts
4c317a94c7 LibCompress: Simplify logic in deflate implementation. 2020-09-06 12:54:45 +02:00
asynts
6de63782c7 Streams: Consistent behaviour when reading from stream with error.
The streaming operator doesn't short-circuit, consider the following
snippet:

    void foo(InputStream& stream) {
        int a, b;
        stream >> a >> b;
    }

If the first read fails, the second is called regardless. It should be
well defined what happens in this case: nothing.
2020-09-06 12:54:45 +02:00
asynts
5d85be7ed4 LibCompress: Add another unit test.
I suspected an error in CircularDuplexStream::read(Bytes, size_t). This
does not appear to be the case, this test case is useful regardless.

The following script was used to generate the test:

    import gzip

    uncompressed = []
    for _ in range(0x100):
        uncompressed.append(1)
    for _ in range(0x7e00):
        uncompressed.append(0)
    for _ in range(0x100):
        uncompressed.append(1)

    compressed = gzip.compress(bytes(uncompressed))
    compressed = ", ".join(f"0x{byte:02x}" for byte in compressed)

    print(f"""\
    TEST_CASE(gzip_decompress_repeat_around_buffer)
    {{
        const u8 compressed[] = {{
            {compressed}
        }};

        u8 uncompressed[0x8011];
        Bytes{{ uncompressed, sizeof(uncompressed) }}.fill(0);
        uncompressed[0x8000] = 1;

        const auto decompressed = Compress::GzipDecompressor::decompress_all({{ compressed, sizeof(compressed) }});

        EXPECT(compare({{ uncompressed, sizeof(uncompressed) }}, decompressed.bytes()));
    }}
    """, end="")
2020-09-06 12:54:45 +02:00
asynts
e2e2e782d4 Deflate: Fix deadly typo. 2020-09-06 12:54:45 +02:00
asynts
b9a6c07bb7 LibCore: FileStream.h: Fix infinite loop when trying to read past end-of-file. 2020-09-06 12:54:45 +02:00
asynts
612c1bc84d Userland: Use Buffered<T> in gunzip. 2020-09-06 12:54:45 +02:00
asynts
359fcf348f AK: Add Buffered<T> which wraps a stream, adding input buffering. 2020-09-06 12:54:45 +02:00
asynts
b011f87d34 AK: Add log stream operator overload for Span. 2020-09-06 12:54:45 +02:00
asynts
f9ba037674 LibCompress: Replace ASSERT_NOT_REACHED with set_fatal_error.
We shouldn't assert that the input file is valid.
2020-09-06 12:54:45 +02:00