summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileSystem.h
AgeCommit message (Collapse)Author
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-07Kernel: Move Mutex into Locking/Jean-Baptiste Boric
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: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
2021-07-17Kernel: Make FileSystem::class_name() return a StringViewAndreas Kling
2021-07-11Kernel: Use Forward.h headers moreAndreas Kling
2021-07-11Kernel: Remove unnecessary includes in FileSystem.{cpp,h}Andreas 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-05-19Kernel: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-19Kernel: Expose FileSystem's fragment sizeJustin
This commit will add a fragment_size() function similar to the block_size() function.
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-02-12Kernel: Add distinct InodeIndex typeAndreas Kling
Use the DistinctNumeric mechanism to make InodeIndex a strongly typed integer type.
2020-09-25Meta+Kernel: Make clang-format-10 cleanBen Wiederhake
2020-09-13Kernel: Make copy_to/from_user safe and remove unnecessary checksTom
Since the CPU already does almost all necessary validation steps for us, we don't really need to attempt to do this. Doing it ourselves doesn't really work very reliably, because we'd have to account for other processors modifying virtual memory, and we'd have to account for e.g. pages not being able to be allocated due to insufficient resources. So change the copy_to/from_user (and associated helper functions) to use the new safe_memcpy, which will return whether it succeeded or not. The only manual validation step needed (which the CPU can't perform for us) is making sure the pointers provided by user mode aren't pointing to kernel mappings. To make it easier to read/write from/to either kernel or user mode data add the UserOrKernelBuffer helper class, which will internally either use copy_from/to_user or directly memcpy, or pass the data through directly using a temporary buffer on the stack. Last but not least we need to keep syscall params trivial as we need to copy them from/to user mode using copy_from/to_user.
2020-08-29FileSystem: Convert file types to DT_* types at a later stageItamar
A change introduced in 5e01234 made it the resposibility of each filesystem to have the file types returned from 'traverse_as_directory' match up with the DT_* types. However, this caused corruption of the Ext2FS file format because the Ext2FS uses 'traverse_as_directory' internally when manipulating the file system. The result was a mixture between EXT2_FT_* and DT_* file types in the internal Ext2FS structures. Starting with this commit, the conversion from internal filesystem file types to the user facing DT_* types happens at a later stage, in the 'FileDescription::get_dir_entries' function which is directly used by sys$get_dir_entries.
2020-08-18Kernel: Remove the now-unused FS::DirectoryEntryAndreas Kling
This object was cumbersome and annoying (mostly due to its manually managed, statically sized name buffer.) And now we no longer need it!
2020-08-18Kernel: Add DirectoryEntryView for VFS directory traversalAndreas Kling
Unlike DirectoryEntry (which is used when constructing directories), DirectoryEntryView does not manage storage for file names. Names are just StringViews. This is much more suited to the directory traversal API and makes it easier to implement this in file system classes since they no longer need to create temporary name copies while traversing.
2020-06-25Kernel: Port mounts to reference inodes directlySergey Bugaev
...instead of going through their identifiers. See the previous commit for reasoning.
2020-06-25Kernel: Deemphasize inode identifiersSergey Bugaev
These APIs were clearly modeled after Ext2FS internals, and make perfect sense in Ext2FS context. The new APIs are more generic, and map better to the semantics exported to the userspace, where inode identifiers only appear in stat() and readdir() output, but never in any input. This will also hopefully reduce the potential for races (see commit https://github.com/SerenityOS/serenity/commit/c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2). Lastly, this makes it way more viable to implement a filesystem that only synthesizes its inodes lazily when queried, and destroys them when they are no longer in use. With inode identifiers being used to reference inodes, the only choice for such a filesystem is to persist any inode it has given out the identifier for, because it might be queried at any later time. With direct references to inodes, the filesystem will know when the last reference is dropped and the inode can be safely destroyed.
2020-05-26Kernel: Clang format file system in prep for changes.Brian Gianforcaro
2020-05-19Kernel: Make FS::block_size a size_tSergey Bugaev
2020-04-06Kernel: Change Ext2FS to be backed by a file instead of a block deviceLiav A
In contrast to the previous patchset that was reverted, this time we use a "special" method to access a file with block size of 512 bytes (like a harddrive essentially).
2020-04-03Revert "Kernel: Change Ext2FS to be backed by a file instead of a block device"Andreas Kling
This reverts commit 6b59311d4bdc1447e085573f9bd2c42819e264dd. Reverting these changes since they broke things. Fixes #1608.
2020-04-02Kernel: Change Ext2FS to be backed by a file instead of a block deviceLiav A
This ensures that we can mount image files as virtual disks without the need of implementing gross hacks like loopback devices :)
2020-02-16Kernel: Add forward declaration headerAndreas Kling
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-10AK: Remove bitrotted Traits::dump() mechanismAndreas Kling
This was only used by HashTable::dump() which I used when doing the first HashTable implementation. Removing this allows us to also remove most includes of <AK/kstdio.h>.
2020-02-08Kernel: Simplify FS::create_inode() a little bitAndreas Kling
Return a KResultOr<NonnullRefPtr<Inode>> instead of returning errors in an out-parameter.
2020-02-08Kernel: Simplify FS::create_directory() a little bitAndreas Kling
None of the clients of this function actually used the returned Inode, so it can simply return a KResult instead.
2020-02-08Kernel: Merge unnecessary DiskDevice class into BlockDeviceAndreas Kling
2020-01-28Kernel: Tweak some include statementsAndreas Kling
2020-01-18Kernel: Fix identifier casingSergey Bugaev
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-03Kernel: Allow passing initial UID and GID when creating new inodesAndreas Kling
If we're creating something that should have a different owner than the current process's UID/GID, we need to plumb that all the way through VFS down to the FS functions.
2019-12-15Kernel+FileManager: Disallow watch_file() in unsupported file systemsAndreas Kling
Currently only Ext2FS and TmpFS supports InodeWatchers. We now fail with ENOTSUPP if watch_file() is called on e.g ProcFS. This fixes an issue with FileManager chewing up all the CPU when /proc was opened. Watchers don't keep the watched Inode open, and when they close, the watcher FD will EOF. Since nothing else kept /proc open in FileManager, the watchers created for it would EOF immediately, causing a refresh over and over. Fixes #879.
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-09-10Ext2FS: Trying to create a too-long directory entry should ENAMETOOLONGAndreas Kling
Also added some assertions to DirectoryEntry in case someone tries to instantiate them with names that would overflow the name buffer. DirectoryEntry is a crappy data structure, and the name buffer is also crappy. Added a FIXME about replacing it with something nicer. Before this patch, the DirectoryEntry::name buffer would overflow if you did "touch extremely-long-file-name". Duh. Fixes #538.
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-17Kernel: Expose info about source devices of mounts in /proc/dfSergey Bugaev
2019-08-17Kernel: Added unmount ability to VFSJesse Buhagiar
It is now possible to unmount file systems from the VFS via `umount`. It works via looking up the `fsid` of the filesystem from the `Inode`'s metatdata so I'm not sure how fragile it is. It seems to work for now though as something to get us going.
2019-08-11FileSystem: Move block_size() from DiskBackedFS to FSAndreas Kling
Let's just say that all filesystems have a block size, to keep things nice and simple.
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-29AK: Defer to Traits<T> for equality comparison in container templates.Andreas Kling
This is prep work for supporting HashMap with NonnullRefPtr<T> as values. It's currently not possible because many HashTable functions require being able to default-construct the value type.
2019-06-21AK: Rename Retainable.h => RefCounted.h.Andreas Kling
2019-06-21AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h.Andreas Kling
2019-06-21AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr.Andreas Kling
2019-06-21AK: Rename Retainable => RefCounted.Andreas Kling
(And various related renames that go along with it.)
2019-06-16Kernel/Userland: Add a halt syscall, and a shutdown binary to invoke itRobin Burchell