summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
AgeCommit message (Collapse)Author
2021-08-19Kernel: Make Process::current() return a Process& instead of Process*Idan Horowitz
This has several benefits: 1) We no longer just blindly derefence a null pointer in various places 2) We will get nicer runtime error messages if the current process does turn out to be null in the call location 3) GCC no longer complains about possible nullptr dereferences when compiling without KUBSAN
2021-08-19AK: Move FormatParser definition from header to implementation fileTimothy Flynn
This is primarily to be able to remove the GenericLexer include out of Format.h as well. A subsequent commit will add AK::Result to GenericLexer, which will cause naming conflicts with other structures named Result. This can be avoided (for now) by preventing nearly every file in the system from implicitly including GenericLexer. Other changes in this commit are to add the GenericLexer include to files where it is missing.
2021-08-19Kernel: Move set_metadata_dirty calls to notify_watchersEdward Palmer
2021-08-18Kernel: Protect the Custody cache with a mutex instead of a spinlockAndreas Kling
We don't need to access the Custody cache in IRQs or anything like that, so it should be fine to use a regular Mutex (via ProtectedValue.) This allows threads to block while waiting for the custody cache. Thanks to Sergey for pointing this out. :^)
2021-08-17Kernel/SysFS: Prepend to the custody cache instead of appendAndrew January
Usage patterns mean we are more likely to need a Custody we just cached. Because lookup walks the list from the beginning, prepending new items instead of appending means they will be found quicker. This reduces the number of items in the cache we need to walk by 50% for boot and application startups.
2021-08-17Kernel: Port Inode to ListedRefCountedAndreas Kling
This consolidates the lock+list combo into a SpinLockProtectedValue and closes yet another unref() race. :^)
2021-08-17Kernel/DevPtsFS: Avoid String allocation during directory traversalAndreas Kling
Use a StringBuilder to generate a temporary string buffer with the slave PTY names. (This works because StringBuilder has 128 bytes of inline stack capacity before it does any heap allocations.)
2021-08-17Kernel: Convert SlavePTY all-instances HashTable to an IntrusiveListAndreas Kling
This simplifies the DevPtsFS implementation somewhat, as it no longer requires SlavePTY to register itself with it, since it can now simply use the list of SlavePTY instances.
2021-08-17Kernel: Customize File::unref() and make it virtualAndreas Kling
Make File inherit from RefCountedBase and provide a custom unref() implementation. This will allow subclasses that participate in lists to remove themselves in a safe way when being destroyed.
2021-08-17Kernel/DevPtsFS: Add tightly typed DevPtsFSInode::fs()Andreas Kling
2021-08-16Kernel: Use ProtectedValue for VirtualFileSystem::m_mountsAndreas Kling
This is what VirtualFileSystem::m_lock was actually guarding, and wrapping it in a ProtectedValue makes it so much more obvious how it all works. :^)
2021-08-15Kernel: Cache Custody objects (weakly) to avoid expensive reconstructionAndreas Kling
This patch adds a (spinlock-protected) custody cache. It's a simple intrusive list containing all currently live custody objects. This allows us to re-use existing custodies instead of creating them again and again. This gives a pretty decent performance improvement on "find /" :^)
2021-08-15Kernel: Remove unused FIFO::all_fifos() tableAndreas Kling
2021-08-15Kernel: Simplify OOM handling in ISO9660FileSystemsin-ack
2021-08-15Kernel: Add tightly typed ISO9660Inode::fs() overloadAndreas Kling
We know the fs() is always an ISO9660FS, so let's be nice and make fs() return that when called on an ISO9660Inode. :^)
2021-08-15Kernel+Userland: Remove chroot functionalityAndreas Kling
We are not using this for anything and it's just been sitting there gathering dust for well over a year, so let's stop carrying all this complexity around for no good reason.
2021-08-15Kernel: Move ProcFS related overrides in Process to ProcessProcFSTraitssin-ack
This allows us to 1) let go of the Process when an inode is ref'ing for ProcFSExposedComponent related reasons, and 2) change our ref/unref implementation.
2021-08-15Kernel: Handle allocation failure in ProcFS and friendssin-ack
There were many places in which allocation failure was noticed but ignored.
2021-08-14Kernel: Move VFS-internal O_FOO definitions to VirtualFileSystem.hAndreas Kling
2021-08-14Kernel: Stop allowing implicit conversion from KResult to intAndreas Kling
This patch removes KResult::operator int() and deals with the fallout. This forces a lot of code to be more explicit in its handling of errors, greatly improving readability.
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-14Kernel/ProcFS: Get unveil stats instead of FDs stats for unveil dataLuke
It was accidentally using `procfs_get_fds_stats` instead of `procfs_get_unveil_stats`.
2021-08-13Kernel/ProcFS: Propagate errors correctly when they occurLiav A
Calling error() on KResult is a mistake I made in 7ba991dc371, so instead of doing that, which triggers an assertion if an error occured, in Inode::read_entire method with VERIFY(nread <= sizeof(buffer)), we really should just return the KResult and not to call error() on it.
2021-08-12Kernel: Steer away from heap allocations for ProcFS process dataLiav A
Instead, use more static patterns to acquire that sort of data.
2021-08-12Kernel+LibC: Use 64 bit values for ino_tLiav A
Since the InodeIndex encapsulates a 64 bit value, it is correct to ensure that the Kernel is exposing the entire value and the LibC is aware of it. This commit requires an entire re-compile because it's essentially a change in the Kernel ABI, together with a corresponding change in LibC.
2021-08-10VirtualFileSystem: Return early in rename() when old_path==new_pathLuK1337
This change fixes disappearing symlink after trying to do the following thing: cp /res/icons/16x16/add-event.png . ln -s add-event.png a mv a a
2021-08-10Kernel: Properly handle non-blocking I/O on pipesJean-Baptiste Boric
Previously, non-blocking read operations on pipes returned EOF instead of EAGAIN and non-blocking write operations blocked. This fixes pkgsrc's bmake "eof on job pipe!" error message when running in non-compatibility mode.
2021-08-08Kernel: Port BlockBasedFileSystem to ProtectedValue :^)Andreas Kling
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-07Kernel: Implement a ISO 9660 filesystem reader :^)sin-ack
This commit implements the ISO 9660 filesystem as specified in ECMA 119. Currently, it only supports the base specification and Joliet or Rock Ridge support is not present. The filesystem will normalize all filenames to be lowercase (same as Linux). The filesystem can be mounted directly from a file. Loop devices are currently not supported by SerenityOS. Special thanks to Lubrsi for testing on real hardware and providing profiling help. Co-Authored-By: Luke <luke.wilde@live.co.uk>
2021-08-07Kernel: Migrate FIFO table locking to ProtectedValueJean-Baptiste Boric
2021-08-07Kernel: Use atomic integer for next FIFO idJean-Baptiste Boric
2021-08-07Kernel: Move Lockable into its own headerJean-Baptiste Boric
2021-08-07Kernel: Move Mutex into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Move UnveilNode.h into Kernel/FileSystem/Andreas Kling
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Rename Range => VirtualRangeAndreas Kling
...and also RangeAllocator => VirtualRangeAllocator. This clarifies that the ranges we're dealing with are *virtual* memory ranges and not anything else.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-08-06Kernel: Fix handful of remaining "return -EFOO" mistakesAndreas Kling
Now that all KResult and KResultOr are used consistently throughout the kernel, it's no longer necessary to return negative error codes. However, we were still doing that in some places, so let's fix all those (bugs) by removing the minuses. :^)
2021-08-06Kernel: Make Thread::state_string() return StringViewAndreas Kling
2021-08-03Kernel: Handle OOM in DiskCache when mounting Ext2 filesystemsBrian Gianforcaro
Create the disk cache up front, so we can verify it succeeds. Make the KBuffer allocation fail-able, so we can properly handle failure when the user asks up to mount a Ext2 filesystem under OOM conditions.
2021-08-03Kernel: Handle OOM from DoubleBuffer creation in FIFO creationBrian Gianforcaro
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-08-02VirtualFileSystem: Don't let rename() overwrite non-empty directoryLuK1337
According to POSIX, rename shouldn't succeed if newpath is a non-empty directory.
2021-07-28Kernel/ProcFS: Add S_IFREG bit to regular files in /procAndreas Kling
Regular files should have regular file mode.
2021-07-27Kernel: Modify the IOCTL API to return KResultBrian Gianforcaro
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
2021-07-27Kernel: Utilize AK::Userspace<T> in the ioctl interfaceBrian Gianforcaro
It's easy to forget the responsibility of validating and safely copying kernel parameters in code that is far away from syscalls. ioctl's are one such example, and bugs there are just as dangerous as at the root syscall level. To avoid this case, utilize the AK::Userspace<T> template in the ioctl kernel interface so that implementors have no choice but to properly validate and copy ioctl pointer arguments.