Andreas Kling
07f4c8b01b
VFS: Get rid of the deprecated Inode::write(const ByteBuffer&).
...
Fix the only remaining call site to use Inode::write_bytes().
2019-01-23 04:59:47 +01:00
Andreas Kling
906685e238
Ext2FS: Implement writing into inodes with arbitrary offset and length.
...
Okay, this is pretty cool. :^) There are some issues and limitations for
sure but the basic functionality is there.
2019-01-23 04:29:56 +01:00
Andreas Kling
29dfb4ae13
Ext2FS: Factor out block list generation and writing into functions.
2019-01-23 03:03:44 +01:00
Andreas Kling
6fb4033709
Ext2FS: Move inode freeing logic from ~Ext2FSInode() to Ext2FS::free_inode().
2019-01-22 20:49:23 +01:00
Andreas Kling
05f18febb6
Ext2FS: Delete inodes when their link count goes to zero.
2019-01-22 16:34:24 +01:00
Andreas Kling
bda0c935c2
Add unlink() syscall and /bin/rm.
...
This patch adds most of the plumbing for working file deletion in Ext2FS.
Directory entries are removed and inode link counts updated.
We don't yet update the inode or block bitmaps, I will do that separately.
2019-01-22 07:03:44 +01:00
Andreas Kling
afccbe51a4
VFS: Place new files in the correct subdirectory.
...
Oops, every new file was ending up in the root directory.
Also make sure we create the inode in the same FS as the parent directory.
2019-01-22 03:56:34 +01:00
Andreas Kling
4d1d875ca7
Remove some unused errno.h duplicates.
2019-01-22 01:12:53 +01:00
Andreas Kling
f70136a324
Kernel: Support open() with O_CREAT.
...
It's now possible to create zero-length files! :^)
Also hook up the new functionality in /bin/touch.
2019-01-22 00:58:56 +01:00
Andreas Kling
e6fc84e234
Kernel: Make /proc/PID/fds display something useful for character devices.
2019-01-21 02:33:01 +01:00
Andreas Kling
b75ee4aacb
Coding style fixes in AK.
2019-01-19 22:53:05 +01:00
Andreas Kling
f7cc454162
Add mechanism to expose kernel variables to userspace via ProcFS.
...
Only booleans are supported at first. More types can be added easily.
Use this to add /proc/sys/wm_flash_flush which when enabled flashes pending
screen flush rects in yellow before they happen.
2019-01-18 15:01:40 +01:00
Andreas Kling
e9e57c5f65
Rename SpinLock to Lock. It hasn't been a SpinLock for some time.
...
I'm pretty happy with the mechanism of AK::Lock for now.
2019-01-17 16:25:02 +01:00
Andreas Kling
b5c76d7559
Get rid of #ifdef SERENITY. We're past that phase of bootstrapping.
2019-01-17 01:41:36 +01:00
Andreas Kling
9dd29f9aa9
Add a PTY multiplexer (/dev/ptmx) device.
...
When you open /dev/ptmx, you get a file descriptor pointing to one of the
available MasterPTY's. If none are available, you get an EBUSY.
This makes it possible to open multiple (up to 4) Terminals. :^)
To support this, I also added a CharacterDevice::open() that gets control
when VFS is opening a CharacterDevice. This is useful when we want to return
a custom FileDescriptor like we do here.
2019-01-16 13:39:32 +01:00
Andreas Kling
b46ae2bf09
Get rid of Vnode concept.
...
We already have an abstraction between Process and Inode/CharacterDevice/FIFO
and it's called FileDescriptor. :^)
2019-01-16 12:57:07 +01:00
Andreas Kling
8ad2dfb6e1
Rename FileDescriptor::has_data_available_for_reading() -> can_read().
2019-01-16 00:47:00 +01:00
Andreas Kling
bd3e77cc16
Pass the process to CharacterDevice::read/write.
...
This is much nicer than grabbing directly at 'current' inside a read().
2019-01-16 00:20:38 +01:00
Andreas Kling
08bfe518f9
Rename CharacterDevice::has_data_available_for_reading() -> can_read().
2019-01-16 00:10:13 +01:00
Andreas Kling
10387beda7
Implement basic support for POSIX-style select().
...
Now we can block on both the PTY *and* the GUI event stream in Terminal.
2019-01-16 00:09:58 +01:00
Andreas Kling
e452303c66
Allow character devices to block write attempts until there is more space.
2019-01-15 09:17:22 +01:00
Andreas Kling
2f74c2f430
Add basic PTY support.
...
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
2019-01-15 06:30:19 +01:00
Andreas Kling
b0e3f73375
Start refactoring the windowing system to use an event loop.
...
Userspace programs can now open /dev/gui_events and read a stream of GUI_Event
structs one at a time.
I was stuck on a stupid problem where we'd reenter Scheduler::yield() due to
having one of the has_data_available_for_reading() implementations using locks.
2019-01-14 14:42:49 +01:00
Andreas Kling
0d36281162
Refactor FS::find_parent_of_inode() into Inode::parent().
...
This way, Ext2FSInode can cache its parent inode index. This makes absolute
path lookups dramatically faster.
SynthFSInode is also simplified greatly.
2019-01-04 18:37:58 +01:00
Andreas Kling
eb78238032
Ext2FS: Don't worry about updating lookup caches in write_ext2_inode().
...
Instead, have Ext2FSInode worry about that when flushing.
Also tidy up in the inode bitmap accessors at the same time for some reason.
2019-01-01 03:55:43 +01:00
Andreas Kling
8f9542174f
Ext2FS: Don't cache a full Ext2FSInode object for non-existent inodes.
...
This was a bit silly. We were always creating Ext2FSInode objects when
Ext2FSInode::get_inode() was called. They'd then sit and fatten up the
inode cache forever, despite not representing allocated inodes.
This patch consults the inode bitmap and if get_inode() is called with
an unallocated inode index, we simply cache a nullptr to represent the
fact that this index is unused.
This could be a lot better optimized, it will currently hit the disk for
every new inode index encountered.
2019-01-01 03:37:27 +01:00
Andreas Kling
d07b08a287
FS: Don't default to having a full InodeMetadata in every Inode.
...
This allows Ext2FS to keep its own ext2_inode around instead.
2019-01-01 03:16:36 +01:00
Andreas Kling
0cb074dc73
Ext2FS: On second thought, let's not uncache the Ext2FSInodes today..
2019-01-01 02:52:21 +01:00
Andreas Kling
741349502f
Ext2FS: Free Ext2FSInodes when the last user releases them.
...
The inode cache was keeping these alive forever. Added a cute little magic
trick to Retainable that calls T::one_retain_left() when the retain count
is decremented to 1.
2019-01-01 02:38:09 +01:00
Andreas Kling
42d9f18cae
Remove the cheesy block cache from DiskBackedFS.
...
This should be reimplemented with proper paging support. This approach was
mostly just chewing kmalloc memory.
2019-01-01 02:27:05 +01:00
Andreas Kling
cc30407b8c
Oops, errno codes need to be negative in the kernel.
2018-12-31 20:38:25 +01:00
Andreas Kling
eed6031064
Fix EXT2_DEBUG build.
2018-12-29 03:36:22 +01:00
Andreas Kling
ab72666f48
Plug leaks in SynthFS::remove_file().
...
The process spawn stress test can now run forever. :^)
2018-12-28 03:09:45 +01:00
Andreas Kling
079889050e
Merge lookup_ext2_inode() into Ext2FS::get_inode().
2018-12-25 00:32:57 +01:00
Andreas Kling
6451b98ad4
Refactor FS::add_inode_to_directory() into Inode::add_child().
2018-12-25 00:27:39 +01:00
Andreas Kling
4f142b86ec
Refactor FS::write_inode() into Inode::write().
2018-12-25 00:10:32 +01:00
Andreas Kling
b0db0e5de0
Get rid of Ext2FS::modify_link_count() in favor of Inode accessors.
2018-12-24 23:58:00 +01:00
Andreas Kling
673870563d
Convert some FS methods to return RetainPtr<Inode>.
2018-12-24 23:45:09 +01:00
Andreas Kling
1e07ead119
Get rid of Ext2FS::is_directory_inode().
...
This was only used for assertions and will be factored out in favor of
Inode metadata checks eventually.
2018-12-24 23:38:15 +01:00
Andreas Kling
12a6963a5d
Fix bug where Vnode kept its Inode alive indefinitely.
2018-12-24 23:24:49 +01:00
Andreas Kling
7bc41532be
Remove FS::read_entire_inode() in favor of Inode::read_entire().
2018-12-21 17:45:42 +01:00
Andreas Kling
04ee693925
Get rid of FS::inode_metadata() since we use Inode::metadata() everywhere.
2018-12-21 17:32:18 +01:00
Andreas Kling
8a71303827
Get rid of FS::read_inode_bytes() and use Inode::read_bytes() everywhere.
2018-12-21 17:28:16 +01:00
Andreas Kling
951ed6692b
Remove InodeIdentifier::metadata().
2018-12-21 17:16:53 +01:00
Andreas Kling
ec1c487dcd
Yet another pass of style fixes.
2018-12-21 02:10:45 +01:00
Andreas Kling
ed7ae6c02c
Add sync() syscall and a /bin/sync.
...
It walks all the live Inode objects and flushes pending metadata changes
wherever needed.
This could be optimized by keeping a separate list of dirty Inodes,
but let's not get ahead of ourselves.
2018-12-20 00:39:29 +01:00
Andreas Kling
d0f06e5f3f
Automatically call Inode::flush_metadata() before an Inode is destroyed.
...
Use a little template magic to have Retainable::release() call out to
T::will_be_destroyed() if such a function exists before actually calling
the destructor. This gives us full access to virtual functions in the
pre-destruction code.
2018-12-19 22:28:09 +01:00
Andreas Kling
1f44cd9dd9
Reworked Inode to have a dirty bit and subclass-implemented flush_metadata().
...
This way we can defer disk writes as long as we like. There's no automatic
flushing happening just yet.
2018-12-19 21:56:45 +01:00
Andreas Kling
d506c857ab
Rename CoreInode to Inode.
...
I don't know what I was thinking here. Clearly Inode is the right name.
2018-12-19 21:18:28 +01:00
Andreas Kling
038d8641f9
Implement utime() along with a naive /bin/touch.
...
This synchronous approach to inodes is silly, obviously. I need to rework
it so that the in-memory CoreInode object is the canonical inode, and then
we just need a sync() that flushes pending changes to disk.
2018-12-19 21:14:55 +01:00