summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
AgeCommit message (Collapse)Author
2021-01-17Kernel: Assert on attempt to mark inode metadata dirty on read-only FSAndreas Kling
2021-01-17Kernel: Remove /proc/PID/vmobjectsAndreas Kling
This file was useful for debugging a long time ago, but has bitrotted at this point. Instead of updating it, let's just remove it since nothing is using it.
2021-01-17Kernel: Remove unused /proc/mm fileAndreas Kling
This was a file I used very early on to dump information about kernel VM objects. It's long since superseded by other JSON-based files.
2021-01-17Kernel: Unbreak /proc/PID/root symlinkAndreas Kling
The generator callback for this file was mistakenly returning false on success, which caused the kernel to fail sys$readlink() with ENOENT.
2021-01-17Ext2FS: Update block group directory count after directory removalAndreas Kling
When freeing an inode, we were checking if it's a directory *after* wiping the inode metadata. This caused us to forget updating the block group descriptor with the new directory count.
2021-01-15Kernel: Make Process::allocate_region*() return KResultOr<Region*>Andreas Kling
This allows region allocation to return specific errors and we don't have to assume every failure is an ENOMEM.
2021-01-15Kernel: Add anonymous files, created with sys$anon_create()Andreas Kling
This patch adds a new AnonymousFile class which is a File backed by an AnonymousVMObject that can only be mmap'ed and nothing else, really. I'm hoping that this can become a replacement for shbufs. :^)
2021-01-14ProcFS: Ignore directories in refresh_data().Mart G
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2021-01-11Kernel: Remove /proc/mountsAndreas Kling
Everyone was already using /proc/df which has all the info anyway.
2021-01-11Kernel: Remove /proc/inodesAndreas Kling
There was nothing interesting in this file.
2021-01-11Kernel: Convert a bunch of String::format() => String::formatted()Andreas Kling
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Kernel+Profiler: Make profiling per-process and without core dumpsAndreas Kling
This patch merges the profiling functionality in the kernel with the performance events mechanism. A profiler sample is now just another perf event, rather than a dedicated thing. Since perf events were already per-process, this now makes profiling per-process as well. Processes with perf events would already write out a perfcore.PID file to the current directory on death, but since we may want to profile a process and then let it continue running, recorded perf events can now be accessed at any time via /proc/PID/perf_events. This patch also adds information about process memory regions to the perfcore JSON format. This removes the need to supply a core dump to the Profiler app for symbolication, and so the "profiler coredump" mechanism is removed entirely. There's still a hard limit of 4MB worth of perf events per process, so this is by no means a perfect final design, but it's a nice step forward for both simplicity and stability. Fixes #4848 Fixes #4849
2021-01-10Kernel: Don't allow non-root, non-owners to rmdir any child of stickyAndreas Kling
We were not handling sticky parents properly in sys$rmdir(). Child directories of a sticky parent should not be rmdir'able by just anyone. Only the owner and root. Fixes #4875.
2021-01-09Ext2FS: Zero out new space when growing an inodeAndreas Kling
Before this change, truncating an Ext2FS inode to a larger size than it was before would give you uninitialized on-disk data. Fix this by zeroing out all the new space when doing an inode resize. This is pretty naively implemented via Inode::write_bytes() and there's lots of room for cleverness here in the future.
2021-01-09Ext2FS: Convert dbg() to dbgln()Andreas Kling
Also remove some dbg()'s that were printing incorrect information.
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything: The modifications in this commit were automatically made using the following command: find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-05Kernel: Provide consistent memory stats in ProcFSTom
We should take the MM lock when gathering all the statistics that we need so that the values are consistent.
2021-01-04Kernel: Specify default memory order for some non-synchronizing AtomicsTom
2021-01-03Kernel: Improve ProcFS behavior in low memory conditionsTom
When ProcFS could no longer allocate KBuffer objects to serve calls to read, it would just return 0, indicating EOF. This then triggered parsing errors because code assumed it read the file. Because read isn't supposed to return ENOMEM, change ProcFS to populate the file data upon file open or seek to the beginning. This also means that calls to open can now return ENOMEM if needed. This allows the caller to either be able to successfully open the file and read it, or fail to open it in the first place.
2021-01-03Kernel: Fix ProcFS returning Inodes that are being deletedTom
There is a window between dropping the last reference and removing a ProcFSInode from the lookup map. So, when looking up we need to check if that Inode is being destructed.
2021-01-02Kernel: Pass "shared" flag to Region constructorAndreas Kling
Before this change, we would sometimes map a region into the address space with !is_shared(), and then moments later call set_shared(true). I found this very confusing while debugging, so this patch makes us pass the initial shared flag to the Region constructor, ensuring that it's in the correct state by the time we first map the region.
2021-01-02Kernel: Fix dirty page map bitmapTom
We also need to check against the new lazy allocation page when generating the dirty page bitmap.
2021-01-01Kernel: Improve some low-memory situations with ext2Tom
2021-01-01Kernel: Merge PurgeableVMObject into AnonymousVMObjectTom
This implements memory commitments and lazy-allocation of committed memory.
2021-01-01Kernel: Memory purging improvementsTom
This adds the ability for a Region to define volatile/nonvolatile areas within mapped memory using madvise(). This also means that memory purging takes into account all views of the PurgeableVMObject and only purges memory that is not needed by all of them. When calling madvise() to change an area to nonvolatile memory, return whether memory from that area was purged. At that time also try to remap all memory that is requested to be nonvolatile, and if insufficient pages are available notify the caller of that fact.
2020-12-31Everywhere: Re-format with clang-format-11Linus Groh
Compared to version 10 this fixes a bunch of formatting issues, mostly around structs/classes with attributes like [[gnu::packed]], and incorrect insertion of spaces in parameter types ("T &"/"T &&"). I also removed a bunch of // clang-format off/on and FIXME comments that are no longer relevant - on the other hand it tried to destroy a couple of neatly formatted comments, so I had to add some as well.
2020-12-31Kernel: Sprinkle some lockers in InodeAndreas Kling
It did look pretty suspicious the way we were accessing members in some of these functions without taking the lock first.
2020-12-30Kernel: Consolidate the various BlockCondition::unblock variantsTom
The unblock_all variant used to ASSERT if a blocker didn't unblock, but it wasn't clear from the name that it would do that. Because the BlockCondition already asserts that no blockers are left at destruction time, it would still catch blockers that haven't been unblocked for whatever reason. Fixes #4496
2020-12-29Kernel: Remove unnecessary non-const Inode::shared_vmobject()Andreas Kling
2020-12-29Revert "Kernel: Convert read_block method to get a reference instead of pointer"Andreas Kling
This reverts commit 092a13211a4216c19c08280bd5e5803e1030f087. Fixes #4611.
2020-12-27Kernel: Introduce a new partitioning subsystemLiav A
The partitioning code was very outdated, and required a full refactor. The new subsystem removes duplicated code and uses more AK containers. The most important change is that all implementations of the PartitionTable class conform to one interface, which made it possible to remove unnecessary code in the EBRPartitionTable class. Finding partitions is now done in the StorageManagement singleton, instead of doing so in init.cpp. Also, now we don't try to find partitions on demand - the kernel will try to detect if a StorageDevice is partitioned, and if so, will check what is the partition table, which could be MBR, GUID or EBR. Then, it will create DiskPartitionMetadata object for each partition that is available in the partition table. This object will be used by the partition enumeration code to create a DiskPartition with the correct minor number.
2020-12-27Kernel: Introduce the DevFSLiav A
The DevFS along with DevPtsFS give a complete solution for populating device nodes in /dev. The main purpose of DevFS is to eliminate the need of device nodes generation when building the system. Later on, DevFS will assist with exposing disk partition nodes.
2020-12-27Kernel: Convert read_block method to get a reference instead of pointerLiav A
BlockBasedFileSystem::read_block method should get a reference of a UserOrKernelBuffer. If we need to force caching a block, we will call other method to do so.
2020-12-27AK: Use direct-list-initialization for Vector::empend() (#4564)Nathan Lanza
clang trunk with -std=c++20 doesn't seem to properly look for an aggregate initializer here when the type being constructed is a simple aggregate (e.g. `struct Thing { int a; int b; };`). This template fails to compile in a usage added 12/16/2020 in `AK/Trie.h`. Both forms of initialization are supposed to call the aggregate-initializers but direct-list-initialization delegating to aggregate initializers is a new addition in c++20 that might not be implemented yet.
2020-12-27Kernel: Allow sys$rename() to rename symlinksAndreas Kling
Previously, this syscall would try to rename the target of the link, not the link itself.
2020-12-27Kernel: Remove the per-process icon_id and sys$set_process_icon()Andreas Kling
This was a goofy kernel API where you could assign an icon_id (int) to a process which referred to a global shbuf with a 16x16 icon bitmap inside it. Instead of this, programs that want to display a process icon now retrieve it from the process executable instead.
2020-12-27Kernel: Expose process executable paths in /proc/allAndreas Kling
2020-12-26Kernel: Implement unveil() as a prefix-treeAnotherTest
Fixes #4530.
2020-12-25Kernel+LibC: Introduce a "dumpable" flag for processesAndreas Kling
This new flag controls two things: - Whether the kernel will generate core dumps for the process - Whether the EUID:EGID should own the process's files in /proc Processes are automatically made non-dumpable when their EUID or EGID is changed, either via syscalls that specifically modify those ID's, or via sys$execve(), when a set-uid or set-gid program is executed. A process can change its own dumpable flag at any time by calling the new sys$prctl(PR_SET_DUMPABLE) syscall. Fixes #4504.
2020-12-25Kernel: Make /proc/PID directories owned by the EUID:EGIDAndreas Kling
This is instead of the UID:GID, since that was allowing some very bad information leaks like spawning "su" as an unprivileged user and having full /proc access to it. Work towards #4504.
2020-12-24ProcFS: pid_vm: Replace duplicated purgeable key with kernel+cacheableBrendan Coles
ProcFS /proc/<pid>/vm map info no longer contains two `purgeable` keys. The second `purgeable` key has been removed and replaced with keys for `kernel` and `cacheable`.
2020-12-23Kernel: Tweak parameter name in Inode::read_entire()Andreas Kling
This is a descriptION, not a descriptOR. :^)
2020-12-22Kernel: Allow sys$chmod() to modify the set-gid bitAndreas Kling
We were incorrectly masking off the set-gid bit. Fixes #4060.
2020-12-21Kernel: Improve time keeping and dramatically reduce interrupt loadTom
This implements a number of changes related to time: * If a HPET is present, it is now used only as a system timer, unless the Local APIC timer is used (in which case the HPET timer will not trigger any interrupts at all). * If a HPET is present, the current time can now be as accurate as the chip can be, independently from the system timer. We now query the HPET main counter for the current time in CPU #0's system timer interrupt, and use that as a base line. If a high precision time is queried, that base line is used in combination with quering the HPET timer directly, which should give a much more accurate time stamp at the expense of more overhead. For faster time stamps, the more coarse value based on the last interrupt will be returned. This also means that any missed interrupts should not cause the time to drift. * The default system interrupt rate is reduced to about 250 per second. * Fix calculation of Thread CPU usage by using the amount of ticks they used rather than the number of times a context switch happened. * Implement CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE and use it for most cases where precise timestamps are not needed.
2020-12-21Everywhere: Switch from (void) to [[maybe_unused]] (#4473)Lenny Maiorani
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
2020-12-18Kernel: Move KBufferBuilder to the fallible KBuffer APIAndreas Kling
KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail. Clients of the API have been updated to handle that situation.
2020-12-18TmpFS: Use fallible KBuffer APIAndreas Kling
If allocation fails, some TmpFS operations can now fail with ENOMEM.