Commit Graph

49 Commits

Author SHA1 Message Date
Andreas Kling
eced5f11e3 Add CoreInode::reverse_lookup().
Getting the absolute path of an ext2fs inode now uses the lookup cache
which makes it a lot faster.
2018-11-15 17:04:55 +01:00
Andreas Kling
5f434bc00b Add CoreInode::lookup() for directory lookups.
Also add a name-to-inode lookup cache to Ext2Inode. This seems like a great
speedup for filesystem traversal.
2018-11-15 16:38:43 +01:00
Andreas Kling
8fa2d7104a More VFS cleanup. 2018-11-15 16:04:25 +01:00
Andreas Kling
396a32835b A pass of style/naming cleanup in VFS. 2018-11-15 15:10:30 +01:00
Andreas Kling
457a5df7d5 Rename:
VirtualFileSystem -> VFS
VirtualFileSystem::Node -> Vnode
2018-11-15 14:43:10 +01:00
Andreas Kling
c735c56e4c More work on CoreInode. 2018-11-13 23:44:54 +01:00
Andreas Kling
26852a8363 Add metadata to CoreInode. 2018-11-13 13:32:16 +01:00
Andreas Kling
10c470e95f Make page_in_from_vnode 2x faster.
...by adding a new class called Ext2Inode that inherits CoreInode.
The idea is that a vnode will wrap a CoreInode rather than InodeIdentifier.
Each CoreInode subclass can keep whatever caches they like.

Right now, Ext2Inode caches the list of block indices since it can be very
expensive to retrieve.
2018-11-13 13:02:39 +01:00
Andreas Kling
19b9401487 Reduce kmalloc() traffic in directory iteration.
Pass the file name in a stack-allocated buffer instead of using an AK::String
when iterating directories. This dramatically reduces the amount of cycles
spent traversing the filesystem.
2018-11-13 00:17:30 +01:00
Andreas Kling
39d6b96d21 Make chdir("/") work.
It surprisingly wasn't possible to resolve the path "/".
2018-11-10 15:40:24 +01:00
Andreas Kling
47b7eeda44 Fix all current build warnings in the kernel. 2018-11-09 10:03:21 +01:00
Andreas Kling
3b2dcd5929 Add a VMO pointer to VNode.
This way, if anyone tries to map an already mapped file, we share the VMO.
2018-11-08 15:39:26 +01:00
Andreas Kling
03a8357e84 Implement sending signals to blocked-in-kernel processes.
This is dirty but pretty cool! If we have a pending, unmasked signal for
a process that's blocked inside the kernel, we set up alternate stacks
for that process and unblock it to execute the signal handler.

A slightly different return trampoline is used here: since we need to
get back into the kernel, a dedicated syscall is used (sys$sigreturn.)

This restores the TSS contents of the process to the state it was in
while we were originally blocking in the kernel.

NOTE: There's currently only one "kernel resume TSS" so signal nesting
definitely won't work.
2018-11-07 21:19:47 +01:00
Andreas Kling
61a84193d7 Fix some broken stuff in VFS test environment.
It's still lagging behind the metal environment but here's some work towards
fixing it at least.
2018-11-07 15:51:39 +01:00
Andreas Kling
981a3ae4b3 Make VFS test environment build again. 2018-11-07 12:05:51 +01:00
Andreas Kling
83172e6a4b Rename FileHandle to FileDescriptor. 2018-11-07 11:37:54 +01:00
Andreas Kling
9f2b9c82bf More work towards getting bash to build.
Implemented some syscalls: dup(), dup2(), getdtablesize().
FileHandle is now a retainable, since that's needed for dup()'ed fd's.
I didn't really test any of this beyond a basic smoke check.
2018-11-05 19:01:59 +01:00
Andreas Kling
a685809e75 Waiters should be notified when a waitee is killed.
Ran into a horrendous bug where VirtualConsole would overrun its buffer
and scribble right into some other object if we were interrupted while
processing a character. Slapped an InterruptDisabler onto onChar for now.

This provokes an interesting question though.. if a process is killed
while its in kernel space, how the heck do we release any locks it held?
I'm sure there are many different solutions to this problem, but I'll
have to think about it.
2018-11-01 01:05:59 +01:00
Andreas Kling
8f6998c902 Add SpinLock to IDE disk access.
This forces serialization of accesses. This driver needs to be redesigned.
2018-10-31 21:33:27 +01:00
Andreas Kling
dec5683e9c Snazz up the kprintf() output a bit by giving it its own color. 2018-10-31 20:14:23 +01:00
Andreas Kling
7a7956a595 Virtual consoles kinda work!
We now make three VirtualConsoles at boot: tty0, tty1, and tty2.
We launch an instance of /bin/sh in each one.
You switch between them with Alt+1/2/3

How very very cool :^)
2018-10-30 15:33:37 +01:00
Andreas Kling
68739dc43e Start working on virtual consoles/TTYs.
This is a mess right now, but I'd rather commit as I go.
2018-10-30 13:59:29 +01:00
Andreas Kling
b1ff62f605 Okay let's just not have this broken locking at all right now.
I think I should just protect access to shared data structures
and eventually do read/write atomicity locks at the inode level.
2018-10-29 22:43:39 +01:00
Andreas Kling
e6284a8774 Fix broken SpinLock.
The SpinLock was all backwards and didn't actually work. Fixing it exposed
how wrong most of the locking here is.

I need to come up with a better granularity here.
2018-10-29 22:04:26 +01:00
Andreas Kling
bea106fdb2 Fix up VFS::resolveSymbolicLink() to use a base inode instead of a base path.
Also more VFS error plumbing.
2018-10-28 14:25:51 +01:00
Andreas Kling
97726862dd Add basic symlink support.
- sys$readlink + readlink()
- Add a /proc/PID/exe symlink to the process's executable.
- Print symlink contents in ls output.
- Some work on plumbing options into VFS::open().
2018-10-28 14:11:51 +01:00
Andreas Kling
1d4af51250 Add a VFS::absolutePath(InodeIdentifier).
This is pretty inefficient for ext2fs. We walk the entire block group
containing the inode, searching through every directory for an entry
referencing this inode.

It might be a good idea to cache this information somehow. I'm not sure
how often we'll be searching for it.

Obviously there are multiple caching layers missing in the file system.
2018-10-28 12:20:25 +01:00
Andreas Kling
81627cf7d5 Add a simple /proc/mounts that enumerates the current VFS mounts. 2018-10-26 18:43:25 +02:00
Andreas Kling
edb81a635c Fix bug where you couldn't "cd .." into the root of a mounted fs. 2018-10-26 18:19:31 +02:00
Andreas Kling
a32b3a3ddf Implement /proc/PID/vm.
Refactored SyntheticFileSystem to maintain an arbitrary directory structure.
ProcFileSystem creates a directory entry in /proc for each new process.
2018-10-26 17:44:19 +02:00
Andreas Kling
2749e7f1c2 Implement sys$chdir() and teach sh+ls to cd around and browse different dirs. 2018-10-26 14:24:11 +02:00
Andreas Kling
bca4b71bfa Lots of hacking to make a very simple "ls" utility.
I added a dead-simple malloc that only allows allocations < 4096 bytes.
It just forwards the request to mmap() every time.

I also added simplified versions of opendir() and readdir().
2018-10-24 12:50:07 +02:00
Andreas Kling
018da1be11 Generalize the SpinLock and move it to AK.
Add a separate lock to protect the VFS. I think this might be a good idea.
I'm not sure it's a good approach though. I'll fiddle with it as I go along.

It's really fun to figure out all these things on my own.
2018-10-23 23:34:05 +02:00
Andreas Kling
ba185e3eba Zero out VirtualFileSystem::s_the in initializeGlobals().
This catches attempts to access the vfs before it's been constructed.
2018-10-22 12:54:19 +02:00
Andreas Kling
79ffdb7205 A lot of hacking:
- More work on funneling console output through Console.
- init() now breaks off into a separate task ASAP.
- ..this leaves the "colonel" task as a simple hlt idle loop.
- Mask all IRQs on startup (except IRQ2 for slave passthru)
- Fix underallocation bug in Task::allocateRegion().
- Remember how many times each Task has been scheduled.

The panel and scheduling banner are disabled until I get things
working nicely in the (brave) new Console world.
2018-10-22 11:15:16 +02:00
Andreas Kling
2d1d01661b Add a way to initialize VFS globals.
This is needed since the kernel loader doesn't even zero out bss,
much less call any static constructors.
2018-10-19 11:20:49 +02:00
Andreas Kling
e86cadc7af Add an fd field to FileHandle in Kernel builds. 2018-10-18 10:27:07 +02:00
Andreas Kling
f82b25d4f9 Fix some minor build warnings. 2018-10-17 16:48:43 +02:00
Andreas Kling
7580ac576f Make VFS host build work again. 2018-10-17 12:23:19 +02:00
Andreas Kling
d2425495ca VirtualFileSystem class builds inside Kernel. 2018-10-17 11:40:58 +02:00
Andreas Kling
9171521752 Integrate ext2 from VFS into Kernel. 2018-10-17 10:57:23 +02:00
Andreas Kling
f608629704 Implement creating a new directory. 2018-10-16 00:35:03 +02:00
Andreas Kling
9528edab92 Move readEntireInode() up to FileSystem (from ext2.)
It's just a wrapper around multiple calls to readInodeBytes() now.
2018-10-15 00:16:14 +02:00
Andreas Kling
0286b5ea48 Add a "stat" command to test FileHandle::stat(). 2018-10-14 23:39:11 +02:00
Andreas Kling
93556d6743 Add basic character device support. Start with null and zero. 2018-10-14 03:01:32 +02:00
Andreas Kling
fa3b11ac64 Parse out major/minor device from character and block device inodes. 2018-10-14 02:24:12 +02:00
Andreas Kling
6ea8ce500c Use HashMap::remove() in some places that I wanted it. 2018-10-13 14:26:37 +02:00
Andreas Kling
c2d42710bb Fix build. 2018-10-13 00:44:54 +02:00
Andreas Kling
5a30055157 Import all this stuff into a single repo called Serenity. 2018-10-10 11:53:07 +02:00