Commit graph

471 commits

Author SHA1 Message Date
Andreas Kling 34e745b0b4 Add uid and gid to CharacterDevices.
The vast majority of them will be owned by 0:0 (the default.)
However, PTY pairs will now be owned by the uid:gid of the opening process.
2019-01-31 05:55:30 +01:00
Andreas Kling c4fce9b3f9 Make stat() work on device files again.
FileDescriptor will now keep a pointer to the original inode even after
opening it resolves to a character device.

Fixed up /bin/ls to display major and minor device numbers instead of size
for device files.
2019-01-31 05:05:57 +01:00
Andreas Kling c3cc318028 Ext2FS: Remove an unnecessary heap allocation in create_inode(). 2019-01-31 04:17:16 +01:00
Andreas Kling 0932efe72e Kernel: Actually zero-fill eagerly committed regions.
Previously, calling Region::commit() would make sure to allocate any missing
physical pages, but they would contain uninitialized data. This was very
obvious when allocating GraphicsBitmaps as they would have garbage pixels
rather than being filled with black.

The MM quickmap mechanism didn't work when operating on a non-active page
directory (which happens when we're in the middle of exec, for example.)
This patch changes quickmap to reside in the shared kernel page directory.

Also added some missing clobber lists to inline asm that I stumbled on.
2019-01-31 04:03:05 +01:00
Andreas Kling 6b88025dda Remove the last remaining #ifndef SERENITY blocks. 2019-01-31 02:56:54 +01:00
Andreas Kling 56b6fb198a Add support for keyboard arrow keys.
Also have them send the appropriate escape sequences in Terminal.
Basic history browsing now works in bash. How nice! :^)
2019-01-30 21:18:13 +01:00
Andreas Kling d1b805172d Rename the default user to "anon" and give him a home directory. 2019-01-30 20:40:41 +01:00
Andreas Kling 2a7af0eacf Kernel: Don't try to dump invalid code memory in page fault handler. 2019-01-30 20:18:50 +01:00
Andreas Kling 37ab7b7a8c LibGUI: Implement destroying individual windows without exiting the process. 2019-01-30 20:03:52 +01:00
Andreas Kling 5c25f0c4db Destroy all remaining windows in a process when it dies. 2019-01-30 19:35:38 +01:00
Andreas Kling 3a4207b863 Fix dumb bug in HashTable::clear().
We forgot to clear the m_buckets pointer. This meant that multiple calls to
clear() would cause trouble.
2019-01-30 19:32:54 +01:00
Andreas Kling 2b4374d08e Let the slave PTY keep the master PTY alive.
This ownership model is a bit confusing. There's a retain cycle between
MasterPTY and SlavePTY, but it's broken when the SlavePTY is closed, meaning
that there are no more FileDescriptors referring to it.
2019-01-30 19:05:59 +01:00
Andreas Kling 45fba60ab5 Kernel: select() should fail with EBADF if any set contains an invalid fd. 2019-01-30 19:01:31 +01:00
Andreas Kling b4e478aa50 Deallocate PTY's when they close.
This required a fair bit of plumbing. The CharacterDevice::close() virtual
will now be closed by ~FileDescriptor(), allowing device implementations to
do custom cleanup at that point.

One big problem remains: if the master PTY is closed before the slave PTY,
we go into crashy land.
2019-01-30 18:47:18 +01:00
Andreas Kling 027d26cd5d Add a String::format() and use that in place of ksprintf() in the Kernel.
You're never gonna be right 100% of the time when guessing how much buffer
space you need. This avoids having to make that type of decision in a bunch
of cases. :^)
2019-01-30 16:28:51 +01:00
Andreas Kling e9b948103d Add a /dev/pts filesystem and make PTY allocation dynamic.
You can now open as many PTY pairs as you like. Well, it's actually capped
at 8 for now, but it's just a constant and trivial to change.

Unregistering a PTY pair is untested because I didn't want to start
mucking with that in Terminal right now.
2019-01-30 00:49:20 +01:00
Andreas Kling c30e2c8d44 Implement basic chmod() syscall and /bin/chmod helper.
Only raw octal modes are supported right now.
This patch also changes mode_t from 32-bit to 16-bit to match the on-disk
type used by Ext2FS.

I also ran into EPERM being errno=0 which was confusing, so I inserted an
ESUCCESS in its place.
2019-01-29 04:55:08 +01:00
Andreas Kling cc906a2897 VFS: Resolve FIXME in Inode::read_entire() about using dynamic allocation. 2019-01-28 22:55:55 +01:00
Andreas Kling f83a94ca39 Kernel: Remove outdated FIXME. 2019-01-28 22:53:31 +01:00
Andreas Kling 7455f5ea42 Expose the kernel log buffer through /proc/dmesg.
Also add a /bin/dmesg program for convenience.
2019-01-28 22:40:55 +01:00
Andreas Kling c95228b128 Add support for removing directories.
It's really only supported in Ext2FS since SynthFS doesn't really want you
mucking around with its files. This is pretty neat though :^)

I ran into some trouble with HashMap while working on this but opted to work
around it and leave that for a separate investigation.
2019-01-28 04:16:01 +01:00
Andreas Kling 031c62a21e .bochsrc: Toggle mouse grab with ctrl-alt (works nicer on 1-button mice.) 2019-01-28 02:34:09 +01:00
Andreas Kling 0e73aa36c8 Kernel: Unbreak symbolication yet another time. 2019-01-27 10:17:56 +01:00
Andreas Kling 6d351bb326 Kernel: Move RAM size detection to MemoryManager and use what we learn. 2019-01-27 10:17:27 +01:00
Andreas Kling 069d21ed7f Make buttons unpress when the cursor leaves the button rect.
Implement this functionality by adding global cursor tracking.
It's currently only possible for one GWidget per GWindow to track the cursor.
2019-01-27 08:48:34 +01:00
Andreas Kling 15fad649ea Userland: Make a simple /bin/cp for copying files. 2019-01-27 07:18:26 +01:00
Andreas Kling a34bb07abb Make .bochsrc work with the stock Bochs on Ubuntu. 2019-01-27 07:17:24 +01:00
Andreas Kling d72575d196 LibGUI: Start bringing up GTextBox in the standalone world. 2019-01-26 06:39:13 +01:00
Andreas Kling 9fa8d4e22f WindowServer: Rename the two painting phases.
Work now happens in terms of two messages:

    - WM_ClientWantsToPaint
    - WM_ClientFinishedPaint

This feels fairly obvious compared to the old Paint/Invalidate.
2019-01-26 05:45:47 +01:00
Andreas Kling 244d5bcce1 WindowServer: More event -> message renaming. 2019-01-26 05:35:45 +01:00
Andreas Kling bba21adae3 WindowServer: Rename WSEvent to WSMessage.
Also do the same for WSMessageLoop and WSMessageReceiver. More to come.
2019-01-26 05:28:02 +01:00
Andreas Kling 7cf3c7461c Refactor GUI rendering model to be two-phased.
Instead of clients painting whenever they feel like it, we now ask that they
paint in response to a paint message.

After finishing painting, clients notify the WindowServer about the rect(s)
they painted into and then flush eventually happens, etc.

This stuff leaves us with a lot of badly named things. Need to fix that.
2019-01-26 05:20:32 +01:00
Andreas Kling a54848f451 Let's not auto-start guitest. guitest2 is so much more useful. 2019-01-25 15:52:55 +01:00
Andreas Kling d059e684a2 Keyboard: Shift+backspace should generate backspace character. 2019-01-25 15:34:02 +01:00
Andreas Kling dfdca9d2a7 Kernel: Implement lazy FPU state restore. 2019-01-25 07:52:44 +01:00
Andreas Kling d39f585f35 Kernel: Fix Syscall.h build when out of context. 2019-01-25 05:19:29 +01:00
Andreas Kling 0db72786cf Snazz up the windows with some title bar gradients. :^) 2019-01-25 05:02:32 +01:00
Andreas Kling 267a903dd0 Terminal: Redraw entire line if any of its characters are dirty.
This means we only have to do one fill_rect() per line and the whole process
ends up being ~10% faster than before.

Also added a read_tsc() syscall to give userspace access to the TSC.
2019-01-25 02:09:29 +01:00
Andreas Kling 11b73c38d8 Kernel: Fix incorrect EFAULTs when syscall would write into COW pages. 2019-01-25 01:39:15 +01:00
Andreas Kling e28de4ad5e Kernel: Dump registers and code on ring0 page fault. 2019-01-25 00:32:50 +01:00
Andreas Kling b896d4b237 PTY: Disallow infinite writing to slaves.
This way we don't buffer ungodly amounts of output in the kernel when doing
e.g "cat /dev/random" on a PTY.
2019-01-25 00:13:54 +01:00
Andreas Kling d7d78670c9 Kernel: Add some logging for backing store get/release syscalls. 2019-01-25 00:13:37 +01:00
Andreas Kling 86eae0f8df Let userland retain the window backing store while drawing into it.
To start painting, call:
gui$get_window_backing_store()

Then finish up with:
gui$release_window_backing_store()

Process will retain the underlying GraphicsBitmap behind the scenes.
This fixes racing between the WindowServer and GUI clients.

This patch also adds a WSWindowLocker that is exactly what it sounds like.
2019-01-24 23:44:19 +01:00
Andreas Kling ccf3fc4618 TTY: MasterPTY's are always writable when open.
This should probably have some limitations eventually, but for now let's just
say we always accept data for shoveling over to SlavePTY.
2019-01-24 21:23:46 +01:00
Andreas Kling 2159d6bf76 Kernel: Fix bug in process termination on missing signal handler. 2019-01-24 21:22:13 +01:00
Andreas Kling aa24547e12 Kernel: Finally stop exposing Region members to the public. 2019-01-24 18:09:46 +01:00
Andreas Kling 1ee8597ce4 Ext2FS: Include meta blocks in an inode's i_blocks count. 2019-01-23 15:43:29 +01:00
Andreas Kling 84c4110a50 Keyboard: Support the escape key. 2019-01-23 08:30:48 +01:00
Andreas Kling af06d5edc1 Kernel: Implement a limited version of POSIX poll(). 2019-01-23 08:03:31 +01:00
Andreas Kling 0ebaa35aa1 Kernel: Let the process argv arrays be null-terminated.
Seems like this is expected. I don't know why I thought it wasn't.
2019-01-23 07:29:10 +01:00