Commit Graph

12880 Commits

Author SHA1 Message Date
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
Andreas Kling
40e6a3dcc3 ClipboardHistory: Copy metadata when reusing a historical clipping 2020-09-05 17:06:34 +02:00
Andreas Kling
2e446b662b ClipboardHistory: Show bitmap width/height/bpp for bitmap clippings 2020-09-05 17:05:22 +02:00
Andreas Kling
0b051a5e15 ClipboardHistory: Show the size (in bytes) of each remembered clipping 2020-09-05 17:02:25 +02:00
Andreas Kling
b8d73e259c ClipboardHistory: Cap the history at 20 entries for now
Now that we can copy bitmaps, we need some kind of cap here or memory
usage quickly skyrockets.

This could probably be improved or made adaptive somehow, this is just
a simple hard cap for now.
2020-09-05 17:00:18 +02:00
Andreas Kling
f405cd3830 PixelPaint: Update "paste" action enabled state based on clipboard
This action should only be enabled when there's a pastable bitmap
on the system clipboard. :^)
2020-09-05 16:57:03 +02:00
Andreas Kling
6aa7f59608 PixelPaint: Allow pasting a copied bitmap as a new layer :^) 2020-09-05 16:53:51 +02:00
Andreas Kling
00bdb74c84 QuickShow: Allow copying the current bitmap to the clipboard :^) 2020-09-05 16:53:30 +02:00
Andreas Kling
158f3b9362 LibGUI: Add a Clipboard API for retrieving a copied Gfx::Bitmap
The returned bitmap is always going to be a 32-bit RGBA bitmap for now.
In the future we may want to support copy-pasting other formats.
2020-09-05 16:52:35 +02:00
Andreas Kling
2e6d59b7b2 Clipboard: Add a key-value map alongside the clipboard storage
A clipping now consists of three things:

- The raw clip data
- A MIME type
- A key-value map (String, String) for anything you like
2020-09-05 16:52:24 +02:00
Andreas Kling
51146e3075 LibGUI: Make the Clipboard API deal in raw byte buffers a bit more
To open up for putting not just text/plain content on the clipboard,
let's make the GUI::Clipboard API a bit more raw-data-friendly. :^)
2020-09-05 16:16:01 +02:00
Andreas Kling
802f541184 Kernel/USB: Disable autodetection of UHCI controllers for now
Until this thing becomes stable, let's not bother everyone with it.
2020-09-05 15:42:54 +02:00
Andreas Kling
3f36903201 Kernel/USB: Start the UHCI controller after resetting it 2020-09-05 15:42:54 +02:00
Ben Wiederhake
c8668e9b7c Meta: Fix wonky copyright headers in Tests 2020-09-05 14:19:38 +02:00
Muhammad Zahalqa
fad0c8e712
AK: Make all DoublyLinkedList search methods use Traits<T>::equals (#3404) 2020-09-05 14:17:14 +02:00