summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/Ext2FileSystem.h
AgeCommit message (Collapse)Author
2022-05-29Kernel/FileSystem: Simplify even more the mount syscallLiav A
As with the previous commit, we put a distinction between filesystems that require a file description and those which don't, but now in a much more readable mechanism - all initialization properties as well as the create static method are grouped to create the FileSystemInitializer structure. Then when we need to initialize an instance, we iterate over a table of these structures, checking for matching structure and then validating the given arguments from userspace against the requirements to ensure we can create a valid instance of the requested filesystem.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-23Kernel: Use ErrorOr in BlockBased and Ext2 filesystem raw read and writeDavid Briggs
These functions used to return booleans which withheld useful error information for callers. Internally they would suppress and convert Error objects. We now log or propagate these errors up the stack.
2022-01-21Kernel: Use KString instead of String in Ext2FSInode's lookup cacheIdan Horowitz
2022-01-11Kernel: Remove empty Ext2FSInode::one_ref_left()Andreas Kling
2021-12-22Kernel: Always initialize ext2_inode and ext_super_block structsBrian Gianforcaro
Found by PVS Studio Static Analysis
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10Kernel/Ext2FS: Propagate errors from block list computation functionsAndreas Kling
2021-11-10Kernel: Make Inode::traverse_as_directory() callback return ErrorOrAndreas Kling
This allows us to propagate errors from inside the callback with TRY().
2021-11-10AK+Kernel: Make BitmapView read-onlyBen Wiederhake
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-10-21Kernel: Make Ext2FS::free_inode() return KResult, and use TRY() moreAndreas Kling
While there's no clear propagation path for errors that happen in an inode destructor, using TRY() still makes the code a lot nicer.
2021-10-21Kernel: Make Ext2FS::write_ext2_inode() return KResultAndreas Kling
This allows us to use TRY() in more places.
2021-10-21Kernel: Make Inode::flush_metadata() return a KResultAndreas Kling
Even if this goes nowhere yet, we have to start building an error propagation path somewhere.
2021-09-07Kernel: Rename FileDescription => OpenFileDescriptionAndreas Kling
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
2021-09-06Kernel: Tidy up Ext2FS construction a bitAndreas Kling
2021-09-05Kernel: Make FileSystem::get_inode() return KResultOr<NRP<Inode>>Andreas Kling
This allows for natural error propagation in a bunch of new places.
2021-08-29Kernel/Ext2FS: Avoid temporary String allocation during inode creationAndreas Kling
Make sure we pass the StringView we get all the way through so it never turns into a heap-allocated String. :^)
2021-08-29Kernel: Strongly typed user & group ID'sAndreas Kling
Prior to this change, both uid_t and gid_t were typedef'ed to `u32`. This made it easy to use them interchangeably. Let's not allow that. This patch adds UserID and GroupID using the AK::DistinctNumeric mechanism we've already been employing for pid_t/ProcessID.
2021-08-14Kernel: Make FileSystem::initialize() return KResultAndreas Kling
This forced me to also come up with error codes for a bunch of situations where we'd previously just panic the kernel.
2021-08-14Kernel: Make Inode::lookup() return a KResultOr<NonnullRefPtr<Inode>>Andreas Kling
This allows file systems to return arbitrary error codes instead of just an Inode or not an Inode.
2021-08-03Kernel: Handle OOM from KBuffer usage in Ext2FS::get_bitmap_block()Brian Gianforcaro
Fixes up error handling on an OOM-able path, and removes one more usage of KBuffer::create_with_size.
2021-07-18Kernel: Make FileSystem::root_inode() return a plain Inode&Andreas Kling
All file system classes are expected to keep their root Inode object in memory, so this function can safely return an Inode&.
2021-07-18Kernel/Ext2FS: Cache the root inode in a member variableAndreas Kling
We often get queried for the root inode, and it will always be cached in memory anyway, so let's make Ext2FS::root_inode() fast by keeping the root inode in a dedicated member variable.
2021-07-17Kernel: Remove Inode::directory_entry_count()Andreas Kling
This was only used in one place: VirtualFileSystem::rmdir(), and that has now been converted to a simple directory traversal.
2021-07-17Kernel: Make Inode::create_child() take the name as a StringViewAndreas Kling
No sense in forcing callers to construct a String. One more small step towards not using String in the kernel.
2021-07-17Kernel: Make FileSystem::class_name() return a StringViewAndreas Kling
2021-07-11Kernel: Rename BlockBasedFS => BlockBasedFileSystemAndreas Kling
2021-07-11Kernel: Rename FS => FileSystemAndreas Kling
This matches our common naming style better.
2021-07-06Kernel: Promote various integers to 64 bits in storage layerJean-Baptiste Boric
2021-06-22Kernel: Ensure Ext2FSInode's lookup is populated before using itSam Atkins
This fixes #8133. Ext2FSInode::remove_child() searches the lookup cache, so if it's not initialized, removing the child fails. If the child was a directory, this led to it being corrupted and having 0 children. I also added populate_lookup_cache to add_child. I hadn't seen any bugs there, but if the cache wasn't populated before, adding that one entry would make it think it was populated, so that would cause bugs later.
2021-06-16Kernel: Remove various other uses of ssize_tGunnar Beutner
2021-05-08Kernel: Place ext2 dir entries so they don't span multiple blocksMart G
Ext2 dir entries spanning multiple blocks are not allowed. If they do occur they are flagged as corrupt by e2fsck for example.
2021-05-02Kernel: Change Inode::{read/write}_bytes interface to KResultOr<ssize_t>Brian Gianforcaro
The error handling in all these cases was still using the old style negative values to indicate errors. We have a nicer solution for this now with KResultOr<T>. This change switches the interface and then all implementers to use the new style.
2021-04-30Kernel: Make Inode::set_{a,c,m}time return KResultAndreas Kling
This exposed some missing error propagation, which this patch also takes care of.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-17Kernel: Add 64 bit file size support to Ext2FSJean-Baptiste Boric
2021-03-13Kernel: Implement triply indirect block support in Ext2FSInodeJean-Baptiste Boric
2021-03-04Kernel: Use BitmapView instead of Bitmap::wrap()Andreas Kling
2021-02-26Ext2FS: Move block list computation from Ext2FS to Ext2FSInodeAndreas Kling
Since the inode is the logical owner of its block list, let's move the code that computes the block list there, and also stop hogging the FS lock while we compute the block list, as there is no need for it.
2021-02-26Ext2FS: Don't hog FS lock while reading/writing inodesAndreas Kling
There are two locks in the Ext2FS implementation: * The FS lock (Ext2FS::m_lock) This governs access to the superblock, block group descriptors, and the block & inode bitmap blocks. It's held while allocating or freeing blocks/inodes. * The inode lock (Ext2FSInode::m_lock) This governs access to the inode metadata, including the block list, and to the content data as well. It's held while doing basically anything with the inode. Once an on-disk block/inode is allocated, it logically belongs to the in-memory Inode object, so there's no need for the FS lock to be taken while manipulating them, the inode lock is all you need. This dramatically reduces the impact of disk I/O on path resolution and various other things that look at individual inodes.
2021-02-26Ext2FS: Inode allocation improvementsAndreas Kling
This patch combines inode the scan for an available inode with the updating of the bit in the inode bitmap into a single operation. We also exit the scan immediately when we find an inode, instead of continuing until we've scanned all the eligible groups(!) Finally, we stop holding the filesystem lock throughout the entire operation, and instead only take it while actually necessary (during inode allocation, flush, and inode cache update.)
2021-02-26Ext2FS: Propagate errors from more placesAndreas Kling
Improve a bunch of situations where we'd previously panic the kernel on failure. We now propagate whatever error we had instead. Usually that'll be EIO.
2021-02-26Ext2FS: Share some bitmap code between inode and block allocationAndreas Kling
Both inode and block allocation operate on bitmap blocks and update counters in the superblock and group descriptor. Since we're here, also add some error propagation around this code.
2021-02-12Ext2FS: Make Ext2FS::GroupIndex a distinct integer typeAndreas Kling
2021-02-12Kernel: Make BlockBasedFS::BlockIndex a distinct integer typeAndreas Kling
2021-02-12Kernel: Add distinct InodeIndex typeAndreas Kling
Use the DistinctNumeric mechanism to make InodeIndex a strongly typed integer type.
2021-02-11Ext2FS: Shrink Ext2FSDirectoryEntry from 16 to 12 bytesAndreas Kling
The way we read/write directories is very inefficient, and this doesn't solve any of that. It does however reduce memory usage of directory entry vectors by 25% which has nice immediate benefits.
2021-02-02Ext2FS: Avoid unnecessary parent inode lookup during inode creationAndreas Kling
Creation of new inodes is always driven by the parent inode, so we can just refer directly to it instead of looking up the parent by ID.
2021-02-02Ext2FS: Simplify inode creation by always starting emptyAndreas Kling
We had two ways of creating a new Ext2FS inode. Either they were empty, or they started with some pre-allocated size. In practice, the pre-sizing code path was only used for new directories and it didn't actually improve anything as far as I can tell. This patch simplifies inode creation by simply always allocating empty inodes. Block allocation and block list generation now always happens on the same code path.