Commit Graph

377 Commits

Author SHA1 Message Date
Aaron Malpas
86415acd6a cp: Refactor copying into copy_file function 2019-09-07 16:54:49 +02:00
Aaron Malpas
4bc6c20091 cp: Use LibCore/CArgsParser for command-line arg parsing 2019-09-07 16:54:49 +02:00
Andreas Kling
73fdbba59c AK: Rename <AK/AKString.h> to <AK/String.h>
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.

Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
2019-09-06 15:36:54 +02:00
Andreas Kling
127e1e0077 wc: Add missing newlines to some error messages 2019-09-01 15:32:09 +02:00
Brandon Scott
23e8715022 Userland: Add 'which' command (#497)
This mimics the shell's path resolution to locate the executable that
would execute if typing it as a command.
2019-08-29 06:23:22 +02:00
Sergey Bugaev
e1a6f8a27d LibThread: Introduce a new threading library
This library is meant to provide C++-style wrappers over lower
level APIs such as syscalls and pthread_* functions, as well as
utilities for easily running pieces of logic on different
threads.
2019-08-26 11:31:14 +02:00
Rok Povsic
e36b9635df Userland: Add realpath 2019-08-25 19:47:37 +02:00
Andreas Kling
11f88a78ad Userland: Remove unnecessary output from "rm" 2019-08-24 13:34:52 +02:00
Conrad Pankoff
bcd214c29d Userland: Fix ifconfig use of /proc/net/adapters 2019-08-21 16:57:31 +02:00
Andreas Kling
de87258b4f Userland: Remove immature "tc" and "uc" programs in favor of "nc"
The netcat-lite "nc" utility is where we should put all of the various
"lightweight" TCP/UDP client features.
2019-08-21 16:49:11 +02:00
Andreas Kling
9731bff44c ls: Sort the output alphabetically
Also use StringBuilder to construct the full relative paths, to get rid
of an unnecessary and suspicious-looking buffer.
2019-08-20 21:39:01 +02:00
Andreas Kling
029786e6b5 ls: Don't layout or colorize output if stdout is not a TTY 2019-08-20 21:06:44 +02:00
marprok
d4b7b92492 Userland: ls division by zero.
When the terminal app window became smaller than the longest filename,
a division by zero occured while calculating the offset.
2019-08-20 20:17:10 +02:00
Marios Prokopakis
91c79440a1 Userland: Improved the printing of the ls command. (#468)
The ls command takes into consideration the length of the largest
filename when it prints a line.

Fixes #432.
2019-08-19 16:37:21 +02:00
marprok
338ba238ca Userland: Implemented a simple cut command.
The current version supports only the -b list option for a single file.
Ranges are also supported.
2019-08-18 17:17:06 +02:00
Sergey Bugaev
9dfcbc58ec Userland: Reimplement the mount command
This new version can do three things:

* When invoked as `mount`, it will print out a list of mounted filesystem,
* When invoked as `mount -a`, it will try to mount filesystems
  listed in /etc/fstab,
* When invoked as `mount device mountpoint -t fstype`, it will mount that
  device on that mountpoint. If not specified, fstype defaults to ext2.
2019-08-17 12:07:55 +02:00
Sergey Bugaev
425c356288 Kernel+LibC+Userland: Support mounting other kinds of filesystems 2019-08-17 12:07:55 +02:00
Andreas Kling
1febd59f83 LibCore+rpcdump: Publish CObject graph to on-demand RPC socket
All programs that have a CEventLoop now allow local socket connections
via /tmp/rpc.PID and will dump a serialized JSON array of all the live
CObjects in the program onto connecting sockets.

Also added a small /bin/rpcdump tool that connects to an RPC socket and
produces a raw dump of the JSON that comes out.
2019-08-17 11:39:26 +02:00
Jesse Buhagiar
bc22456f89 Kernel: Added unmount ability to VFS
It is now possible to unmount file systems from the VFS via `umount`.
It works via looking up the `fsid` of the filesystem from the `Inode`'s
metatdata so I'm not sure how fragile it is. It seems to work for now
though as something to get us going.
2019-08-17 09:29:54 +02:00
Conrad Pankoff
c7040cee62 Userland: Use LibPCIDB in lspci to print device names 2019-08-14 13:12:54 +02:00
Conrad Pankoff
ecde025375 Libraries: Add LibPCIDB for reading PCI device information from pci.ids 2019-08-14 13:12:54 +02:00
Conrad Pankoff
99ed4ce30c Userland: Implement simple lspci command 2019-08-14 06:28:53 +02:00
Andreas Kling
7d6689055f Kernel+LibC+crash: Add mprotect() syscall
This patch adds the mprotect() syscall to allow changing the protection
flags for memory regions. We don't do any region splitting/merging yet,
so this only works on whole mmap() regions.

Added a "crash -r" flag to verify that we crash when you attempt to
write to read-only memory. :^)
2019-08-12 19:33:24 +02:00
Conrad Pankoff
e978e7543f Userland: Make sure sockaddr_len is initialised correctly in nc 2019-08-10 08:51:20 +02:00
Conrad Pankoff
fffd3a67ad Userland: Implement -l, -v, -N, -s, and -p for netcat 2019-08-08 10:32:01 +02:00
Conrad Pankoff
fbcf51f81b Userland: Implement nc command
This is a very simple version of the nc (netcat) command. It only
supports outgoing TCP connections, and has no options aside from the
target host and port.
2019-08-08 06:47:30 +02:00
Conrad Pankoff
7ed54d86d5 Kernel: Record network statistics and expose as JSON
This is comprised of five small changes:

* Keep a counter for tx/rx packets/bytes per TCP socket
* Keep a counter for tx/rx packets/bytes per network adapter
* Expose that data in /proc/net_tcp and /proc/netadapters
* Convert /proc/netadapters to JSON
* Fix up ifconfig to read the JSON from netadapters
2019-08-08 06:44:49 +02:00
Andreas Kling
f6998b1817 JSON: Templatize the JSON serialization code
This makes it possible to use something other than a StringBuilder for
serialization (and to produce something other than a String.) :^)
2019-08-07 21:29:32 +02:00
Conrad Pankoff
9111d3626a Userland: Implement truncate command
This has a known bug in that you can't specify a negative size value.
This bug stems from the argument parser, and once it's fixed there,
everything should work here.
2019-08-05 08:36:28 +02:00
Andreas Kling
8e684f0959 AudioServer: Port to the new generated IPC mechanism
Fork the IPC Connection classes into Server:: and Client::ConnectionNG.
The new IPC messages are serialized very snugly instead of using the
same generic data structure for all messages.

Remove ASAPI.h since we now generate all of it from AudioServer.ipc :^)
2019-08-03 19:49:19 +02:00
Jesse
401c87a0cc Kernel: mount system call (#396)
It is now possible to mount ext2 `DiskDevice` devices under Serenity on
any folder in the root filesystem. Currently any user can do this with
any permissions. There's a fair amount of assumptions made here too,
that might not be too good, but can be worked on in the future. This is
a good start to allow more dynamic operation under the OS itself.

It is also currently impossible to unmount and such, and devices will
fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on
getting `umount` done ASAP to rectify this (as well as working on less
assumption-making in the mount syscall. We don't want to just be able
to mount DiskDevices!). This could probably be fixed with some `-t`
flag or something similar.
2019-08-02 15:18:47 +02:00
Andreas Kling
4271bebbef more: Don't printf(string), printf("%s", string)!
Found by PVS-Studio.
2019-08-01 11:39:41 +02:00
Andreas Kling
488d57750d pidof: Remove redundant bool check.
Found by PVS-Studio.
2019-08-01 11:07:44 +02:00
Andreas Kling
15afc88ffe AudioServer: Add a "main mix volume" and a simple program to get/set it
Give the mixer a main volume value (percent) that we scale all the
outgoing samples by (before clipping.)

Also add a simple "avol" program for querying and setting the volume:

- "avol" prints the current volume.
- "avol 200" sets the main mix volume to 200%
2019-07-29 19:06:58 +02:00
Andreas Kling
7356fd389f aplay: s/Sample/Progress/ in the output. It's all in the details! 2019-07-28 21:56:19 +02:00
Andreas Kling
ae4a9e017a LibAudio+aplay: Make the aplay output look a little funner.
Show some information about the file we're playing, and display how many
samples we've played out of how many total.

This might be a bit buggy as I haven't tested it with many different files,
but it's a start. :^)
2019-07-28 21:52:30 +02:00
Andreas Kling
7cabe6433e AudioServer: Add a buffer queue so we can buffer some sound.
The idea here is to keep a small number of sample buffers queued in the
AudioServer so we don't get caught without something to play.
2019-07-28 18:27:32 +02:00
Andreas Kling
5e01dde7b1 Audio: Make ABuffer sit on top of a SharedBuffer.
This allows us to carry the same buffer all the way from the WAV loader
to the AudioServer mixer.

This alleviates some of the stutter, but there's still a noticeable
skip when switching buffers. We're gonna need to do better. :^)
2019-07-27 18:17:17 +02:00
Andreas Kling
426248098c Audio: Make basic streaming WAV playback work.
I had to solve a bunch of things simultaneously to make this work.
Refactor AWavLoader to be a streaming loader rather than a one-shot one.
The constructor parses the header, and if everything looks good, you can
repeatedly ask the AWavLoader for sample buffers until it runs out.

Also send a message from AudioServer when a buffer has finished playing.
That allows us to implement a blocking variant of play().

Use all of this in aplay to play WAV files chunk-at-a-time.
This is definitely not perfect and it's a little glitchy and skippy,
but I think it's a step in the right direction.
2019-07-27 17:27:05 +02:00
Andreas Kling
c8e2bb5605 Kernel: Add a mechanism for listening for changes to an inode.
The syscall is quite simple:

    int watch_file(const char* path, int path_length);

It returns a file descriptor referring to a "InodeWatcher" object in the
kernel. It becomes readable whenever something changes about the inode.

Currently this is implemented by hooking the "metadata dirty bit" in
Inode which isn't perfect, but it's a start. :^)
2019-07-22 20:01:11 +02:00
Andreas Kling
3965fcc484 ls: Don't print an empty line if there were no files to show.
Fixes #352.
2019-07-21 09:26:47 +02:00
Jesse
a5d80f7e3b Kernel: Only allow superuser to halt() the system (#342)
Following the discussion in #334, shutdown must also have root-only
run permissions.
2019-07-19 13:08:26 +02:00
Jesse
a27c9e3e01 Kernel+Userland: Addd reboot syscall (#334)
Rolling with the theme of adding a dialog to shutdown the machine, it is
probably nice to have a way to reboot the machine without performing a full
system powerdown.

A reboot program has been added to `/bin/` as well as a corresponding
`syscall` (SC_reboot). This syscall works by attempting to pulse the 8042
keyboard controller. Note that this is NOT supported on  new machines, and
should only be a fallback until we have proper ACPI support.

The implementation causes a triple fault in QEMU, which then restarts the
system. The filesystems are locked and synchronized before this occurs,
so there shouldn't be any corruption etctera.
2019-07-19 09:58:12 +02:00
Andreas Kling
1498a3be32 Userland: Remove some no-longer-needed test utilities. 2019-07-18 11:26:50 +02:00
Andreas Kling
1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00
Robin Burchell
b12d1fbb81 ps: Widen state field to fit "Condition" and other fields
Similar to ab20c91cfb.
2019-07-18 07:23:26 +02:00
Robin Burchell
57da716be0 ps: Port to using CProcessStatisticsReader and /proc/all
Drop /proc/summary in the process.
We only needed one new field here, thankfully, so this was quite straightforward.
2019-07-18 07:23:26 +02:00
Robin Burchell
a9d1a86e6e CProcessStatisticsReader: Be consistent about terminology from the kernel down 2019-07-18 07:23:26 +02:00
Robin Burchell
2177594c96 Port LibGUI to use CIPCClientSideConnection
As a consequence, move to use an explicit handshake() method rather than
calling virtuals from the constructor. This seemed to not bother
AClientConnection, but LibGUI crashes (rightfully) because of it.
2019-07-17 20:16:44 +02:00
Andreas Kling
ab20c91cfb top: Widen "state" field slightly to accomodate "Condition". 2019-07-17 11:23:31 +02:00