Andreas Kling
2dd9ef6863
Kernel: Make File::absolute_path() const.
2019-06-01 18:56:56 +02:00
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
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
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
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
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
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
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
0dc9af5f7e
Add clang-format file
...
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00
Robin Burchell
c6e79bd53a
Kernel: Support O_APPEND
...
As per the manpage, this acts as a transparent lseek() before write.
2019-05-26 01:32:05 +02:00
Andreas Kling
75b0e5cce5
Ext2FS: Block #0 can terminate an inode block list early.
...
We were already handling this for the indirect blocks, but the direct ones
would happily consider #0 to be a valid block list entry.
2019-05-25 19:19:43 +02:00
Andreas Kling
728327df8a
Ext2FS: Fix build with EXT2_DEBUG enabled, and tweak some variable names.
2019-05-25 17:23:17 +02:00
Andreas Kling
75866438b5
Kernel: Don't page in entire file immediately on mmap().
...
If we just don't do anything, the page fault handler will load the file
incrementally as-needed instead. :^)
2019-05-18 22:30:55 +02:00
Andreas Kling
959c8f287c
FileDescriptor: It's actually okay to seek past the end of a file. :^)
2019-05-18 21:54:31 +02:00
Andreas Kling
a4e48dce77
Kernel: SharedMemory should implement mmap().
2019-05-18 04:17:53 +02:00
Andreas Kling
237628a7a6
Kernel: Tidy up FileDescriptor members a bit.
2019-05-18 04:14:22 +02:00
Andreas Kling
6957825444
Kernel: Factor out range allocation from Process::allocate_region*().
...
These functions were doing exactly the same thing for range allocation, so
share that code in an allocate_range() helper.
Region allocation will now also fail if range allocation fails, which means
that mmap() can actually fail without falling apart. Exciting times!
2019-05-17 04:39:22 +02:00
Robin Burchell
f1f3cd58b0
FileSystem: fix errno on lseek() beyond the bounds of a file
...
These are all EINVAL. Also remove bogus assert on metadata.size.
2019-05-16 16:05:08 +02:00
Andreas Kling
176f683f66
Kernel: Move Inode to its own files.
2019-05-16 03:02:37 +02:00
Andreas Kling
01ffcdfa31
Kernel: Encapsulate the Region's COW map a bit better.
2019-05-14 17:31:57 +02:00
Andreas Kling
8b249bd09b
Kernel+Userland: Implement mknod() syscall and add a /bin/mknod program.
2019-05-03 22:59:58 +02:00
Andreas Kling
2470fdcd9b
Kernel: Make Socket inherit from File.
2019-05-03 20:42:43 +02:00
Andreas Kling
03da7046bd
Kernel: Prepare Socket for becoming a File.
...
Make the Socket functions take a FileDescriptor& rather than a socket role
throughout the code. Also change threads to block on a FileDescriptor,
rather than either an fd index or a Socket.
2019-05-03 20:15:54 +02:00
Andreas Kling
b8e60b6652
Kernel: Remove unused Region::is_bitmap().
2019-05-02 23:31:11 +02:00
Andreas Kling
c3b7ace3e0
Kernel: Assign Lock names in class member initializers.
2019-05-02 03:28:20 +02:00
Andreas Kling
28244039a5
Kernel: Don't symbolicate symbol+offset for obvious non-kernel addresses.
2019-04-30 14:47:22 +02:00
Andreas Kling
8cbb7f101f
Kernel: Have File virtuals take a FileDescriptor& rather than a Process&.
...
This will allow us to implement different behaviors depending on the role
of the descriptor a File is being accessed through.
2019-04-29 13:58:40 +02:00
Andreas Kling
0a0d739e98
Kernel: Make FIFO inherit from File.
2019-04-29 04:55:54 +02:00
Andreas Kling
475a17fa4b
VFS: Also respect the sticky bit of the new parent in rename().
...
Obviously we should not allow overwriting someone else's files in a sticky
directory either.
2019-04-28 23:34:33 +02:00
Andreas Kling
e4eca17848
VFS: Implement sticky bit behavior for rename() and unlink().
...
Removing entries from a sticky directory is only allowed when you are either
the owner of the entry, or the superuser. :^)
2019-04-28 22:54:30 +02:00
Andreas Kling
a104d7cc93
Kernel: Make SharedMemory inherit from File.
2019-04-28 22:31:31 +02:00
Andreas Kling
a6d407fec5
Ext2FS: Put some debug spam behind EXT2_DEBUG.
2019-04-28 22:14:37 +02:00
Andreas Kling
899f6a5de2
Ext2FS: Support shrinking inode to a smaller size.
...
Factor out inode resizing into a separate Ext2FSInode::resize() function.
This is then called both from write_bytes() and truncate().
This patch finally implements freeing of blocks when an inode shrinks.
2019-04-28 22:07:25 +02:00
Andreas Kling
c91b0d6b5f
FileDescriptor: Let TTY handle its own absolute_path().
2019-04-28 15:09:23 +02:00
Andreas Kling
e886337a67
Kernel: Make ProcessTracer inherit from File.
2019-04-28 15:02:55 +02:00
Andreas Kling
d32d85e133
Kernel: Fix rename() sometimes failing to move within the same directory.
...
It was wrong to do a reverse name lookup on the old inode after adding
a new name for it, since we might very well get the new inode instead of
the old one, depending on hash table layouts.
2019-04-27 22:38:51 +02:00
Andreas Kling
52139a2392
DiskBackedFS: Flush write cache if it reaches 32 entries before sync.
...
This is just to avoid chewing through all of the kernel memory. There is a
lot of room for improvement here, and 32 is just a number from the place
where numbers come from.
2019-04-27 17:30:32 +02:00