Commit Graph

2652 Commits

Author SHA1 Message Date
Andreas Kling
00de8b9fc4 FileSystem: Don't create a temporary FileDescriptor every time we stat().
Instead, move the stat buffer population into InodeMetadata so we can call
it directly from VFS::stat() once we have an Inode.
2019-06-01 18:46:39 +02:00
Andreas Kling
bba2c062fe FileSystem: Make Inode::lookup() take a StringView.
This avoids a lot of String allocation during path resolution.
2019-06-01 18:01:28 +02:00
Andreas Kling
49768524d4 VM: Get rid of KernelPagingScope.
Every page directory inherits the kernel page directory, so there's no need
to explicitly enter the kernel's paging scope anymore.
2019-06-01 17:51:48 +02:00
Andreas Kling
00f291b090 Kernel: Set the absolute path as name for executable regions. 2019-06-01 17:50:43 +02:00
Andreas Kling
2e14e5891c FileSystem: Remove now-unused Inode::parent() and Inode::reverse_lookup().
These were only used to implement the old path resolution algorithm.
2019-06-01 17:46:37 +02:00
Andreas Kling
02e21de20a VM: Always flush TLB for kernel page directory changes.
Since the kernel page directory is inherited by all other page directories,
we should always flush the TLB when it's updated.
2019-06-01 17:25:36 +02:00
Andreas Kling
6956d161c4 PNGLoader: Annotate the decompression buffer mmap with a name. 2019-06-01 17:06:35 +02:00
Andreas Kling
ba58b4617d VM: Don't remap each Region page twice in page_in().
page_in_from_inode() will map the page after reading it from disk, so we
don't need to remap it once again.
2019-06-01 15:45:50 +02:00
Conrad Pankoff
6cabd34b93 Userland: Improve head program
* allow specifying files as arguments, e.g. `head a b c`
* support multiple files
* print a filename header when multiple files are being printed
* allow suppression or forcing of filename header via flags

This change drops support for the legacy `-123` syntax in favour of the
more widely-supported `-n 123` form.

fixes #105
2019-06-01 14:48:03 +02:00
Andreas Kling
b8e705da0e LibCore: CObjects without is<T> specialization shouldn't LARP as others. 2019-06-01 14:11:31 +02:00
Mustafa
a4726b846c ls: Show user name and group name if available. (#151)
Fixes #150
2019-06-01 13:23:35 +02:00
Conrad Pankoff
51a74fb3bb Userland: Add a /bin/yes program (fixes #110) 2019-06-01 12:16:55 +02:00
Andreas Kling
473d0e83ad Terminal: Fix insufficient repaint after visual bell clears.
Also make the bell time a little shorter, 500ms kinda wears on you. :^)
2019-06-01 00:36:56 +02:00
Andreas Kling
40ca3b019f VisualBuilder: Add GRadioButton to the widget repertoire. 2019-06-01 00:23:31 +02:00
Christopher Dumas
b0d8dba16d Terminal: Single settings window & consistant visual bell timing 2019-06-01 00:07:45 +02:00
Christopher Dumas
6a4cb25557 Terminal: Settings windows can be opened multiple times 2019-06-01 00:07:45 +02:00
Christopher Dumas
f8a02d4733 Terminal: Audible vs Visible beep option 2019-06-01 00:07:45 +02:00
Andreas Kling
9ac95d1867 FileSystem: Pass mode_t to Inode::add_child().
This way the Ext2FS code can update its directory entry "file type" fields
correctly based on the file mode. This fixes some e2fsck whining.
2019-05-31 17:41:33 +02:00
Andreas Kling
fdf3608c8a Update Badge<T> instantiations to simply be {}. 2019-05-31 15:44:04 +02:00
Andreas Kling
fa6446fc0d FileSystem: VFS should require Badge<Device> for device registration. 2019-05-31 15:36:49 +02:00
Andreas Kling
a1fdda3e20 FileSystem: Don't expose VFS::root_inode().
It seems like we don't need to expose this anymore, it's only used by VFS
internally to construct the root custody.
2019-05-31 15:32:19 +02:00
Andreas Kling
056a7fea08 FileSystem: Rename VFS::resolve_path_to_custody() => resolve_path(). 2019-05-31 15:30:09 +02:00
Andreas Kling
8adadf8a46 FileSystem: Reuse existing custodies when possible, and keep them updated.
Walk the custody cache and try to reuse an existing one when possible.
The VFS is responsible for updating them when something happens that would
cause the described relationship to change.

This is definitely not perfect but it does work for the basic scenarios like
renaming and removing directory entries.
2019-05-31 15:22:52 +02:00
Andreas Kling
3fbddcecd2 Kernel: Discard a process's ELFLoader on finalization.
We don't need after that point, and throwing it out might free up some
cached data used for backtraces.
2019-05-31 08:03:58 +02:00
Andreas Kling
d58eb3bf21 Kernel: Process finalization should release cwd and executable custodies.
Since Process destruction happens with interrupts disabled, it's not safe to
still hold custodies at that point. Drop them in finalization.
2019-05-31 07:19:54 +02:00
Andreas Kling
e33dadbdd6 Kernel: Do a bit more of do_exec() before disabling interrupts.
We definitely need to replace m_executable before clearing interrupts, since
otherwise we might call ~Custody() which would make it assert in locking.
Also avoid calling FileDescriptor::metadata() repeatedly and just cache the
result from the first call.

I also added a comment at the point where we've decided to commit to the new
executable and follow through with the swap.
2019-05-31 07:19:50 +02:00
Andreas Kling
e6a8133b0c FileSystem: Merge symlink following logic into path resolution.
When encountering a symlink, we abandon the custody chain we've been working
on and start over with a new one (by recursing into a new resolution call.)
Caching symlinks in the custody model would be incredibly difficult to get
right with all the extra invalidation it would require, so let's just not.
2019-05-31 06:42:49 +02:00
Andreas Kling
6b585f9dd7 Shell: Fix an error message incorrectly complaining about lstat() failure.
The syscall used is actually stat(), so let's be correct about that.
2019-05-31 06:07:09 +02:00
Andreas Kling
0f3b5e1f02 Kernel: The stat() syscall should follow symlinks. 2019-05-30 23:21:01 +02:00
Andreas Kling
709d168807 FileSystem: Get rid of VFS::resolve_path().
The only remaining client was resolve_symbolic_link() which now deals in
custodies instead.
2019-05-30 22:30:29 +02:00
Andreas Kling
874bffc729 FileSystem: Get rid of VFS::absolute_path() and teach Mount about custodies. 2019-05-30 22:30:29 +02:00
Andreas Kling
8e83aac8a3 FileSystem: Get rid of VFS::resolve_path_to_inode() and old_resolve_path(). 2019-05-30 22:30:29 +02:00
Andreas Kling
55821c91f8 Kernel: Rename Process::cwd_custody() to Process::current_directory().
...and executable_custody() to just executable().
2019-05-30 22:30:25 +02:00
Andreas Kling
393851418b FileSystem: Port most of the code over to using custodies.
The current working directory is now stored as a custody. Likewise for a
process executable file. This unbreaks /proc/PID/fd which has not been
working since we made the filesystem bigger.

This still needs a bunch of work, for instance when renaming or removing
a file somewhere, we have to update the relevant custody links.
2019-05-30 18:58:59 +02:00
Andreas Kling
4cb87b1753 FileSystem: Add a Custody class that represents a parent/child guardianship.
A custody is kind of a directory entry abstraction that represents a single
entry in a parent directory that tells us the name of a child inode.

The idea here is for path resolution to produce a chain of custody objects.
2019-05-30 17:46:08 +02:00
Andreas Kling
3a1d5fa112 ELFLoader: Fix typo in segment naming.
Executable segments now get an "x" character in their region name.
2019-05-30 16:23:48 +02:00
Andreas Kling
baaede1bf9 Kernel: Make the Process allocate_region* API's understand "int prot".
Instead of having to inspect 'prot' at every call site, make the Process
API's take care of that so we can just pass it through.
2019-05-30 16:14:37 +02:00
Andreas Kling
8fe72d7b3c Kernel: Make fcntl(F_SETFL) actually update the append/blocking flags. 2019-05-30 15:37:51 +02:00
Andreas Kling
7710863e3c Ports: Add gcc-8.3.0 port :^) 2019-05-30 15:27:56 +02:00
Andreas Kling
07c3cc01ec LibC: Move wait-related stuff to <sys/wait.h>. #POSIX 2019-05-30 15:12:09 +02:00
Andreas Kling
ed58abb911 Ports: Build binutils from tarball instead of git. 2019-05-30 13:59:24 +02:00
Andreas Kling
08926e59b3 Kernel: Add InodeFile, a File subclass for regular files.
Finally everything that can be held by a FileDescriptor actually inherits
from the File class.
2019-05-30 13:39:17 +02:00
Andreas Kling
66c1a9be3b Kernel: Pass 'prot' argument to File::mmap() and act on it.
Nothing crazy, this just means that PROT_READ allocates readable regions,
and that PROT_WRITE allocates writable ones.
2019-05-30 12:38:35 +02:00
Robin Burchell
004a630bfe Terminal: Fix some missing text attributes
Probably doesn't actually change much yet since we don't support many
text rendering options, but it's at least good to have the options, and
to record things we don't yet support too.
2019-05-30 10:35:36 +02:00
Andreas Kling
96db775ac1 LibC: Add setenv().
If I'm understanding the standard C library correctly, setenv() copies while
putenv() does not. That's really confusing and putenv() basically sucks.
To know which environment variables to free on replacement and which ones to
leave alone, we keep track of the ones malloced by setenv in a side table.

This patch also moves Shell to using setenv() instead of putenv().

Fixes #29.
2019-05-30 03:22:18 +02:00
Robin Burchell
d31ce9eccd Misc: Add a simple init process
This doesn't do much right now, just fork off a bunch of stuff and set priorities.
2019-05-30 02:57:15 +02:00
Robin Burchell
9cd0f6ffac Kernel/LibC: Implement sched_* functionality to set/get process priority
Right now, we allow anything inside a user to raise or lower any other process's
priority. This feels simple enough to me. Linux disallows raising, but
that's annoying in practice.
2019-05-30 02:57:15 +02:00
Andreas Kling
b160677e9e LibC: Add malloc_size() to tell you how big an allocation might be.
It can't be 100% precise but it doesn't really matter. Use this to implement
realloc() nicely. This also fixes a bug in realloc() where we didn't take
the size of the allocation metadata into account when computing the size of
an allocation backed by a BigAllocationBlock.
2019-05-30 02:37:40 +02:00
Robin Burchell
a906098579 Kernel: Fix a bad printf, and stub out SO_ERROR a bit more fully
links requests SO_ERROR, so in not supporting it, things were unhappy.
Supporting this properly looks a little messy. I guess Socket will need
an m_error member it sets everywhere it returns an error. Or Syscall
could set it, perhaps, but I don't know if that's the right thing to
do, so let's just stub this for now and file a bug.
2019-05-30 02:02:30 +02:00
Mustafa Ali CAN
3ffb2ad4e0 LibM LibC: add fixes for Lua port. 2019-05-29 16:03:51 +02:00