Commit Graph

688 Commits

Author SHA1 Message Date
howar6hill
a78ae917d8 mv: Use ArgsParser, and check lstat for failure 2020-02-21 15:16:28 +01:00
howar6hill
e352ee23e5 Userland: Fix nullptr dereference if we fail to open the PCIDB
In the code below, db could be null, and would cause UB.
Instead of crashing, let's simply skip symbolicating names.

Fixes #1247
2020-02-20 15:13:42 +01:00
howar6hill
83668299a6
host: Use ArgsParser to parse arguments, and add man page (#1252)
Fixes #1246.
2020-02-20 15:12:55 +01:00
Andreas Kling
88b9fcb976 AK: Use size_t for ByteBuffer sizes
This matches what we already do for string types.
2020-02-20 13:20:34 +01:00
howar6hill
940de40f28
Userland: Add userdel program (#1217) 2020-02-19 12:59:09 +01:00
Andreas Kling
315538245f realpath: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
f67f70302b uname: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
feb4c683eb touch: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
b58728ed99 rm: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
a5f0b2aef0 ln: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
03aea11589 date: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
4b0e0bd9b8 env: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
b2f9a60bdb uptime: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
3b3b4b0e04 hostname: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
60c8d2379a kill: Use pledge() 2020-02-18 13:29:54 +01:00
Andreas Kling
0bef6c9d78 basename: Use pledge() 2020-02-18 13:29:54 +01:00
howar6hill
94ed183774 Man: Use ArgsParser to parse arguments 2020-02-18 12:23:15 +01:00
Andreas Kling
7ce3f218af wc: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
257e7f022a sort: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
4f7081289c whoami: Use pledge() and unveil() 2020-02-18 11:35:47 +01:00
Andreas Kling
0b44f9d600 which: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
7266cee590 clear: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
1612a1d489 echo: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
d6a1237cfe yes: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
00fa2aa0ec rmdir: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
7281214af2 mkdir: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
53e7490b81 stat: Use pledge() 2020-02-18 11:35:47 +01:00
Andreas Kling
ffb6056675 ps: Use pledge() and unveil() 2020-02-18 11:35:47 +01:00
Andreas Kling
16d5b1d4ca top: Use pledge() and unveil() 2020-02-18 11:35:47 +01:00
Andreas Kling
9f54ea9bcd NotificationServer: Add a system service for desktop notifications
This patch adds NotificationServer, which runs as the "notify" user
and provides an IPC API for desktop notifications.

LibGUI gains the GUI::Notification class for showing notifications.

NotificationServer is spawned on demand and will unspawn after
dimissing all visible notifications. :^)

Finally, this also comes with a small /bin/notify utility.
2020-02-16 21:58:17 +01:00
Andreas Kling
4ba153668b chmod: Tweak usage string
Fixes #1223.
2020-02-16 09:51:49 +01:00
Andreas Kling
2143da6434 LibGUI: Add forwarding header
This patch adds <LibGUI/Forward.h> and uses it a bunch.
It also dragged various header dependency reduction changes into it.
2020-02-16 09:41:56 +01:00
Shannon Booth
4d8547d112 Userland: Use DirIterator in rm 2020-02-16 02:19:22 +01:00
Andreas Kling
3866e0d4d4 LibCore: Move LogStream::operator<< overloads into cpp files 2020-02-15 00:58:52 +01:00
Andreas Kling
8f7333f080 LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to
shrink the header dependency graph.
2020-02-14 23:31:18 +01:00
Andreas Kling
3bbf4610d2 AK: Add a forward declaration header
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.

Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Shannon Booth
8249e666fc Userland: Fix typos in setting user id
Fixes: #1219
2020-02-14 23:30:22 +01:00
Shannon Booth
1f75dfd95d Userland: Fix error handling in rm program
Fixes: #1218
2020-02-14 23:30:22 +01:00
Andreas Kling
e22283e5e6 Userland: Use Core::DateTime 2020-02-11 20:43:29 +01:00
Andreas Kling
a1e7064937 gron: Use pledge() 2020-02-11 12:42:06 +01:00
Andreas Kling
05e772d276 jp: Use pledge() 2020-02-11 12:16:07 +01:00
William McPherson
d55d2b2794 LibAudio/aplay: Handle WAV header errors properly
We shouldn't just ASSERT() if the header parse fails. This was crashing
Piano completely.
2020-02-10 14:04:27 +01:00
William McPherson
c8eaae3eaf Userland: Fix segfault in chown
chown takes 2 arguments, not 1.
2020-02-10 11:11:29 +01:00
Liav A
88cf46dc98 Userland: Use IO helpers from LibBareMetal 2020-02-09 19:38:17 +01:00
Andreas Kling
8325662186 more: Read keystrokes from stdout instead of trying to re-open it
If we're running more on a TTY that we don't have filesystem access to,
we can't rely on open(ttyname(STDOUT_FILENO)). Since all the stdio fd's
are opened read/write anyway, we can just read from stdout, even if it
feels a bit weird. :^)
2020-02-08 15:50:00 +01:00
Andreas Kling
6a9cc66b97 LibGUI: Remove leading G from filenames 2020-02-06 20:33:02 +01:00
Andreas Kling
97edc82a26 LibAudio: Remove leading A from filenames 2020-02-06 15:18:03 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Andreas Kling
9ac94d393e LibGfx: Rename from LibDraw :^) 2020-02-06 12:04:00 +01:00
Andreas Kling
11580babbf LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really
wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename
the library to LibGfx. :^)
2020-02-06 11:56:38 +01:00
Andreas Kling
92f77864de LibAudio: Put all classes in the Audio namespace and remove leading A 2020-02-06 10:40:02 +01:00
Andreas Kling
5b7924b9e7 LibProtocol: Rename namespace LibProtocol => Protocol 2020-02-05 19:13:44 +01:00
Andreas Kling
c5bd9d4ed1 LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
2020-02-02 15:15:33 +01:00
Andreas Kling
2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Jesse Buhagiar
f9609fe08a Userland: useradd utility
This commit implements the `useradd` utility that is found on most,
if not all *NIX systems. It allows the root user to add new users
to the password file found in `/etc/passwd`, thereby making
it easier to manipulate the file.
2020-02-02 10:58:45 +01:00
Andreas Kling
a27c5d2fb7 Kernel: Fail with EFAULT for any address+size that would wrap around
Previously we were only checking that each of the virtual pages in the
specified range were valid.

This made it possible to pass in negative buffer sizes to some syscalls
as long as (address) and (address+size) were on the same page.
2020-01-29 12:56:07 +01:00
Sergey Bugaev
f983dfe319 Userland+Terminal: Port to new CArgsParser API
While at it, also add some niceties and fix some things.
2020-01-28 13:50:18 +01:00
Andreas Kling
c64904a483 Kernel: sys$readlink() should return the number of bytes written out 2020-01-27 21:50:51 +01:00
Andreas Kling
a7b984ec49 sleep: Use pledge() 2020-01-27 21:39:35 +01:00
Andreas Kling
8f6dc3e9a0 mknod: Use pledge() 2020-01-27 21:38:36 +01:00
Andreas Kling
23ffd6c319 Kernel+LibC+Userland: Switch to 64-bit time_t
Let's not have that 2038 problem people are talking about. :^)
2020-01-27 10:59:29 +01:00
Andreas Kling
b011857e4f Kernel: Make writev() work again
Vector::ensure_capacity() makes sure the underlying vector buffer can
contain all the data, but it doesn't update the Vector::size().

As a result, writev() would simply collect all the buffers to write,
and then do nothing.
2020-01-26 10:10:15 +01:00
Sergey Bugaev
c0b32f7b76 Meta: Claim copyright for files created by me
This changes copyright holder to myself for the source code files that I've
created or have (almost) completely rewritten. Not included are the files
that were significantly changed by others even though it was me who originally
created them (think HtmlView), or the many other files I've contributed code to.
2020-01-24 15:15:16 +01:00
Brian Gianforcaro
cf151fa0e1 rpcdump: Use pledge() and unveil() 2020-01-23 10:22:54 +01:00
Brian Gianforcaro
e3e22cd42e lspci: Use pledge() and unveil() 2020-01-23 09:51:45 +01:00
Brian Gianforcaro
ce6864dd79 man: Use unveil() 2020-01-22 11:40:41 +01:00
Brian Gianforcaro
319cb28452 dmesg: Use pledge() and unveil() 2020-01-22 11:40:22 +01:00
Andreas Kling
cec0268ffa id: Use unveil()
And so "id" becomes our first user of unveil(), giving himself access
to read /etc/passwd and /etc/group :^)
2020-01-20 22:21:41 +01:00
Andreas Kling
e711936c78 Userland: Add a dummy passthrough "flock" program
This allows you to run our build system's Makefiles inside SerenityOS
itself (since they rely on "flock")

Obviously it doesn't do any locking as we don't support that yet.
2020-01-20 20:44:29 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Sergey Bugaev
cf04de188e Userland: Print which path we failed to ls 2020-01-17 21:49:58 +01:00
rhin123
0f3880ec4a Userland: Stop id command accepting -n in default format 2020-01-17 09:39:11 +01:00
joshua stein
d7e8431cdb Userland/ls: escape non-printable characters
Fixes #1044
2020-01-15 23:13:15 +01:00
Andreas Kling
d4d17ce423 Kernel: Trying to sys$link() a directory should fail with EPERM 2020-01-15 22:11:44 +01:00
Andreas Kling
9e54c7c17f Ext2FS: Don't allow creating new files in removed directories
Also don't uncache inodes when they reach i_links_count==0 unless they
also have no ref counts other than the +1 from the inode cache.
This prevents the FS from deleting the on-disk inode too soon.
2020-01-15 22:11:44 +01:00
Andreas Kling
ad5ee27ea9 mv: Use pledge() 2020-01-13 14:51:35 +01:00
Andreas Kling
8ccc2b25c2 cp: Use pledge() 2020-01-13 14:51:18 +01:00
Brian Gianforcaro
1915151116 man: Use pledge() 2020-01-13 11:04:35 +01:00
Brian Gianforcaro
f7148c766a more: Use pledge() 2020-01-13 11:04:35 +01:00
Brian Gianforcaro
e45a4b0931 md: Use pledge() 2020-01-13 11:04:35 +01:00
Brian Gianforcaro
a77da7f245 ls: Use pledge() 2020-01-13 11:04:35 +01:00
Brian Gianforcaro
70defb34e6 tail: Use pledge() 2020-01-13 11:04:35 +01:00
Andreas Kling
0c44a12247 Kernel: read() and write() should EOVERFLOW if (offset+size) overflows 2020-01-12 20:20:17 +01:00
Sergey Bugaev
8ca6e63119 Userland: Support custom programs and mount options in chroot 2020-01-12 20:02:11 +01:00
Sergey Bugaev
1a55264fe6 Userland: Support comments and blank lines in /etc/fstab 2020-01-12 20:02:11 +01:00
Andreas Kling
a27d2b7b32 chmod: Use pledge() 2020-01-12 13:25:02 +01:00
0xtechnobabble
e12798c0a9 chown: Use pledge() 2020-01-12 12:55:20 +01:00
0xtechnobabble
f501014fae Userland: Add the chgrp command
The chgrp command allows the user to easily modify a file's group while
leaving its owner unchanged.
2020-01-12 12:55:20 +01:00
0xtechnobabble
954daaa916 Userland: Add named gid/uid args parsing
This patch makes it so that if a user provides a groupname/username
instead of an id, chown will automatically convert it to a gid/uid
using getgrnam() or getpwnam() respectively.
2020-01-12 12:55:20 +01:00
Andreas Kling
e131a401e8 cat: Use pledge() 2020-01-11 21:33:12 +01:00
Andreas Kling
8c2009c5be host: Use pledge() 2020-01-11 20:49:31 +01:00
Andreas Kling
d30d3fac6f id: Use pledge() 2020-01-11 20:49:25 +01:00
Andreas Kling
409a4f7756 ping: Use pledge() 2020-01-11 20:48:43 +01:00
Sergey Bugaev
a9e6f4a2cd Userland: Support mount flags 2020-01-11 18:57:53 +01:00
Sergey Bugaev
4566c2d811 Kernel+LibC: Add support for mount flags
At the moment, the actual flags are ignored, but we correctly propagate them all
the way from the original mount() syscall to each custody that resides on the
mounted FS.
2020-01-11 18:57:53 +01:00
Andreas Kling
73788d7305 ls: Cache the user and group names instead of looking up every time 2020-01-11 13:30:17 +01:00
Andreas Kling
3f9e4cd24e chroot: Add a little chroot program
This program changes the current filesystem root and spawns a shell.
2020-01-10 23:23:20 +01:00
Andreas Kling
b1ffde6199 Kernel: unlink() should not follow symlinks 2020-01-10 14:07:36 +01:00
Andreas Kling
f026f0f4bb rm: When invoked on a symlink, remove the symlink itself 2020-01-10 14:02:52 +01:00
Andreas Kling
41d5f5c3b5 ls: Widen the user and group fields a little bit
I didn't like looking at /tmp/portal now that lookup:lookup owns one
of the sockets there :^)
2020-01-09 21:43:21 +01:00
Andreas Kling
6c549959c6 disk_benchmark: Unbreak this utility now that read() of O_WRONLY fails 2020-01-08 21:12:40 +01:00
Andreas Kling
e1d4b19461 Kernel: open() and openat() should ignore non-permission bits in mode 2020-01-08 15:21:06 +01:00
Andreas Kling
1f6c624a1a truncate: Unbreak this utility after ftruncate() syscall fixes 2020-01-08 15:21:06 +01:00
Andreas Kling
fe1bf067b8 ProcFS: Reads past the end of a generated file should be zero-length 2020-01-08 12:59:06 +01:00
Andreas Kling
28ee5b0e98 TmpFS: Reads past the end of a file should be zero-length 2020-01-08 12:47:41 +01:00
Andreas Kling
50056d1d84 Kernel: mmap() should fail with ENODEV for directories 2020-01-08 12:47:37 +01:00
Andreas Kling
6a4b376021 Kernel: Validate ftruncate(fd, length) syscall inputs
- EINVAL if 'length' is negative
- EBADF if 'fd' is not open for writing
2020-01-07 14:48:43 +01:00
Andreas Kling
c9507e8cbe ls: Display SUID files with red background color 2020-01-05 12:49:25 +01:00
Tibor Nagy
cdeae8a6f3 Keymap: Fix map initialization
Correct the number of keymap entries and initialize them.

Fixes #1017
2020-01-05 12:25:26 +01:00
marprok
adff54879c Userland: Support multiple input files.
The user can now give more than one files to the cut command.
2020-01-05 09:00:47 +01:00
Andreas Kling
c663b1034a su: Use setgroups() to switch over to the target user's extra GIDs
Before this, su would leave the process's extra GIDs untouched,
simply inheriting them from whoever spawned su.

Now we grab the target user's groups from /etc/group and setgroups().
2020-01-04 13:48:55 +01:00
Andreas Kling
d4b4883d55 id: Remove weird commas from output 2020-01-04 13:26:51 +01:00
Andreas Kling
755938c650 ls: Show directories with the sticky bit in a special color
This makes /tmp show up with a green background in "ls" output.
2020-01-04 11:38:02 +01:00
Andreas Kling
bbedad1197 test_io: Test that seeking past EOF and then reading returns 0 2020-01-03 04:03:52 +01:00
Andreas Kling
93e9a42bf0 test_io: Verify that write() on an O_RDONLY fd fails with EBADF 2020-01-03 03:36:17 +01:00
Andreas Kling
c19f840f32 test_io: Verify that read() on an O_WRONLY fd fails with EBADF 2020-01-03 03:34:06 +01:00
Andreas Kling
2da3edb3d0 test_io: Add a simple test program that abuses some I/O syscalls
This exposes some very bad behaviors that will need fixing.
2020-01-03 03:18:49 +01:00
Tibor Nagy
790eaab6f5 Keymap+Base: Keycode fixes, remove workaround
Add missing keymap entries for the dollar sign and escape key and reformat
the Hungarian keymap.

Remove the workaround for "0x08", replace it with '\b'.

Fix the octal/hex mixup in the value of escape key. (033 != 0x33, 033 == 0x1B)
2020-01-03 01:20:47 +01:00
Andreas Kling
907b090ddf LibC+Userland: Add a proper syscall wrapper for purge() 2020-01-02 13:37:02 +01:00
joshua stein
9b516e3fb4 Userland: ifconfig: include netinet/in.h 2020-01-02 04:09:56 +01:00
Andreas Kling
3dcec260ed Kernel: Validate the full range of user memory passed to syscalls
We now validate the full range of userspace memory passed into syscalls
instead of just checking that the first and last byte of the memory are
in process-owned regions.

This fixes an issue where it was possible to avoid rejection of invalid
addresses that sat between two valid ones, simply by passing a valid
address and a size large enough to put the end of the range at another
valid address.

I added a little test utility that tries to provoke EFAULT in various
ways to help verify this. I'm sure we can think of more ways to test
this but it's at least a start. :^)

Thanks to mozjag for pointing out that this code was still lacking!

Incidentally this also makes backtraces work again.

Fixes #989.
2020-01-02 02:17:12 +01:00
Liav A
e5ffa960d7 Kernel: Create support for PCI ECAM
The new PCI subsystem is initialized during runtime.
PCI::Initializer is supposed to be called during early boot, to
perform a few tests, and initialize the proper configuration space
access mechanism. Kernel boot parameters can be specified by a user to
determine what tests will occur, to aid debugging on problematic
machines.
After that, PCI::Initializer should be dismissed.

PCI::IOAccess is a class that is derived from PCI::Access
class and implements PCI configuration space access mechanism via x86
IO ports.
PCI::MMIOAccess is a class that is derived from PCI::Access
and implements PCI configurtaion space access mechanism via memory
access.

The new PCI subsystem also supports determination of IO/MMIO space
needed by a device by checking a given BAR.
In addition, Every device or component that use the PCI subsystem has
changed to match the last changes.
2020-01-02 00:50:09 +01:00
joshua stein
a1fd2eb237 Build: Userland: no need for duplicate .cpp->.o rule 2020-01-01 22:21:50 +01:00
Andreas Kling
fc86460134 AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
2020-01-01 18:53:34 +01:00
Andreas Kling
38f93ef13b Kernel: Disable x86 RDTSC instruction in userspace
It's still possible to read the TSC via the read_tsc() syscall, but we
will now clear some of the bottom bits for unprivileged users.
2020-01-01 18:22:20 +01:00
Andreas Kling
f598bbbb1d Kernel: Prevent executing I/O instructions in userspace
All threads were running with iomapbase=0 in their TSS, which the CPU
interprets as "there's an I/O permission bitmap starting at offset 0
into my TSS".

Because of that, any bits that were 1 inside the TSS would allow the
thread to execute I/O instructions on the port with that bit index.

Fix this by always setting the iomapbase to sizeof(TSS32), and also
setting the TSS descriptor's limit to sizeof(TSS32), effectively making
the I/O permissions bitmap zero-length.

This should make it no longer possible to do I/O from userspace. :^)
2020-01-01 17:31:41 +01:00
Andreas Kling
9c0836ce97 Kernel: Enable x86 UMIP (User Mode Instruction Prevention) if supported
This prevents code running outside of kernel mode from using the
following instructions:

* SGDT - Store Global Descriptor Table
* SIDT - Store Interrupt Descriptor Table
* SLDT - Store Local Descriptor Table
* SMSW - Store Machine Status Word
* STR - Store Task Register

There's no need for userspace to be able to use these instructions so
let's just disable them to prevent information leakage.
2020-01-01 13:21:15 +01:00
Tibor Nagy
c431979aef Keymap: Add AltGr support 2019-12-31 19:31:42 +01:00
Shannon Booth
8a0ef92100 Crash: Woops! Remove a misplaced if (true)
I was testing with this and must have forgotten to remove it :(
2019-12-31 02:43:43 +01:00
Shannon Booth
d0f9906c17 Crash: Add a "Test All Crash Types" option
Add an option "-A", that will run all of the crash types in the crash
program. In this mode, all crash tests are run in a child process so
that the crash program does not crash.

Crash uses the return status of the child process to ascertain whether
the crash happened as expected.
2019-12-31 02:14:36 +01:00
Andreas Kling
3f254bfbc8 Kernel+ping: Only allow superuser to create SOCK_RAW sockets
/bin/ping is now setuid-root, and will drop privileges immediately
after opening a raw socket.
2019-12-31 01:42:34 +01:00
Andreas Kling
5c918d0e71 dmesg: Add missing newline to error message 2019-12-31 01:32:57 +01:00
Andreas Kling
50677bf806 Kernel: Refactor scheduler to use dynamic thread priorities
Threads now have numeric priorities with a base priority in the 1-99
range.

Whenever a runnable thread is *not* scheduled, its effective priority
is incremented by 1. This is tracked in Thread::m_extra_priority.
The effective priority of a thread is m_priority + m_extra_priority.

When a runnable thread *is* scheduled, its m_extra_priority is reset to
zero and the effective priority returns to base.

This means that lower-priority threads will always eventually get
scheduled to run, once its effective priority becomes high enough to
exceed the base priority of threads "above" it.

The previous values for ThreadPriority (Low, Normal and High) are now
replaced as follows:

    Low -> 10
    Normal -> 30
    High -> 50

In other words, it will take 20 ticks for a "Low" priority thread to
get to "Normal" effective priority, and another 20 to reach "High".

This is not perfect, and I've used some quite naive data structures,
but I think the mechanism will allow us to build various new and
interesting optimizations, and we can figure out better data structures
later on. :^)
2019-12-30 18:46:17 +01:00
Jami Kettunen
76f0a74b0c Keymap: Add ability to load keymap files by name 2019-12-30 14:02:00 +01:00
Jami Kettunen
0b3f1e70ca Keymap: Clean up source a bit 2019-12-30 14:02:00 +01:00
Andreas Kling
1f31156173 Kernel: Add a mode flag to sys$purge and allow purging clean inodes 2019-12-29 13:16:53 +01:00
joshua stein
d622e4d224 Build: build Userland binaries separately
Touching one source file shouldn't require relinking all binaries,
consider each one separate.  Also fix building library dependencies.
2019-12-28 21:09:33 +01:00
Andreas Kling
2cbc3c6ee5 LibC+ping: Let's use the traditional timersub() et al prototypes
This also fixes the build, since ping.cpp already had a timersub().
2019-12-27 23:07:28 +01:00
Andreas Kling
d1c16944ce gron: Implement a simplified variant of @tomnomnom's "gron"
This program takes JSON input and turns it into JavaScript statements
that construct the same data step by step. This format is much more
greppable than what "jp" gives us. :^)
2019-12-27 03:27:37 +01:00
Andreas Kling
23591f2a95 munch: Add a simple userland program for chewing up lots of memory 2019-12-26 11:48:34 +01:00
Andreas Kling
33efeaf71a crash: Add "-X" option for attempting to execute non-executable memory 2019-12-25 13:35:57 +01:00
joshua stein
c127d16326 Build: support library and generator dependencies
Instead of directly manipulating LDFLAGS, set LIB_DEPS in each
subdirectory Makefile listing the libraries needed for
building/linking such as "LIB_DEPS = Core GUI Draw IPC Core".

This adds each library as an -L and -l argument in LDFLAGS, but
also adds the library.a file as a link dependency on the current
$(PROGRAM).  This causes the given library to be (re)built before
linking the current $(PROGRAM), but will also re-link any binaries
depending on that library when it is modified, when running make
from the root directory.

Also turn generator tools like IPCCompiler into dependencies on the
files they generate, so they are built on-demand when a particular
directory needs them.

This all allows the root Makefile to just list directories and not
care about the order, as all of the dependency tracking will figure
it out.
2019-12-25 10:11:09 +01:00
Mauri de Souza Nunes
cb4e51a7a5 Userland: Add syscall -l option and man page 2019-12-24 20:23:37 +01:00
Andrés Vieira
5f9c408a08 Userland: Add support for printing multiple columns to the cal command
Now cal is able to print the entire year when only that is passed
as an argument. For example: `cal 1992`.

However this meant breaking the highlighted day escape sequence
as it messed up the layout and the character count for each of the
rows :(

Now the current day is specified like 17* (for example for day 17).
2019-12-24 11:48:16 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Andreas Kling
b32e961a84 Kernel: Implement a simple process time profiler
The kernel now supports basic profiling of all the threads in a process
by calling profiling_enable(pid_t). You finish the profiling by calling
profiling_disable(pid_t).

This all works by recording thread stacks when the timer interrupt
fires and the current thread is in a process being profiled.
Note that symbolication is deferred until profiling_disable() to avoid
adding more noise than necessary to the profile.

A simple "/bin/profile" command is included here that can be used to
start/stop profiling like so:

    $ profile 10 on
    ... wait ...
    $ profile 10 off

After a profile has been recorded, it can be fetched in /proc/profile

There are various limits (or "bugs") on this mechanism at the moment:

- Only one process can be profiled at a time.
- We allocate 8MB for the samples, if you use more space, things will
  not work, and probably break a bit.
- Things will probably fall apart if the profiled process dies during
  profiling, or while extracing /proc/profile
2019-12-11 20:36:56 +01:00
Andreas Kling
fd5eb79d19 LibGUI: Make GMenu inherit from CObject
This is primarily to make it possible to pass a GMenu* where a CObject*
is expected.
2019-12-09 21:05:44 +01:00
Andreas Kling
dfc5eb2b6d purge: Add a small command-line utility for purging all volatile memory 2019-12-09 19:16:45 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Andreas Kling
f41ae755ec Kernel: Crash on memory access in non-readable regions
This patch makes it possible to make memory regions non-readable.
This is enforced using the "present" bit in the page tables.
A process that hits an not-present page fault in a non-readable
region will be crashed.
2019-12-02 19:18:52 +01:00