summaryrefslogtreecommitdiff
path: root/Kernel/ProcessExposed.cpp
AgeCommit message (Collapse)Author
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-05-06Kernel: Add /proc/{pid}/children to ProcFSMacDue
This exposes the child processes for a process as a directory of symlinks to the respective /proc entries for each child. This makes for an easier and possibly more efficient way to find and count a process's children. Previously the only method was to parse the entire /proc/all JSON file.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2021-12-30Kernel: Add some implied auto qualifiersHendiadyoin1
2021-11-18Kernel: Use DistinctNumeric for filesystem ID'sAndreas Kling
This patch adds the FileSystemID type, which is a distinct u32. This prevents accidental conversion from arbitrary integers.
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-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-17Kernel/ProcFS: Provide a way to write to ProcFS inodesSeekingBlues
ProcFSGlobalInode now calls `write_bytes()`, `truncate()` and `set_mtime()` on its associated component. This allows us to write 0 or 1 to a ProcFSSystemBoolean component to toggle a boolean value.
2021-09-07Kernel: Make it possible for KBufferBuilder creation to failAndreas Kling
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
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-07Kernel: Make UserOrKernelBuffer return KResult from read/write/memsetAndreas Kling
This allows us to simplify a whole bunch of call sites with TRY(). :^)
2021-09-06Kernel: Make KString factories return KResultOr + use TRY() everywhereAndreas Kling
There are a number of places that don't have an error propagation path right now, so I've added FIXME's about that.
2021-09-06Kernel: Make SysFS and ProcFS generator functions return KResultAndreas Kling
This allows us to propagate a whole bunch of KBufferBuilder errors.
2021-09-06Kernel: Use TRY() more in process-specific ProcFS codeAndreas Kling
2021-09-05Kernel: Make all Spinlocks use u8 for storage, remove templateBrian Gianforcaro
The default template argument is only used in one place, and it looks like it was probably just an oversight. The rest of the Kernel code all uses u8 as the type. So lets make that the default and remove the unused template argument, as there doesn't seem to be a reason to allow the size to be customizable.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-18Kernel: Specify directory entry types properlySergey Bugaev
...in a few more places, at least. find(1) is about to start relying on the reported types more or less reflecting reality. This is especially relevant for magic symlinks in ProcFS.
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-12Kernel: Steer away from heap allocations for ProcFS process dataLiav A
Instead, use more static patterns to acquire that sort of data.
2021-07-20Kernel: Simplify ProcFS generated buffer cachingAndreas Kling
Use a Mutex instead of a SpinLock to protect the per-FileDescription generated data cache. This allows processes to go to sleep while waiting their turn. Also don't try to be clever by reusing existing cache buffers. Just allocate KBuffers as needed (and make sure to surface failures.)
2021-07-18Kernel: Rename Locker => MutexLockerAndreas Kling
2021-07-17Kernel: Replace "folder" => "directory" everywhereAndreas Kling
Folders are a GUI concept. File systems have directories.
2021-07-14Kernel/ProcFS: Allow a process directory to have a null Process pointerLiav A
In case we are about to delete the PID directory, we clear the Process pointer. If someone still holds a reference to the PID directory (by opening it), we still need to delete the process, but we can't delete the directory, so we will keep it alive, but any operation on it will fail by propogating the error to userspace about that the Process was deleted and therefore there's no meaning to trying to do operations on the directory. Fixes #8576.
2021-07-11Kernel: Rename ProcFSComponentsRegistrar => ProcFSComponentRegistryAndreas Kling
This matches the formatting used in SysFS.
2021-07-11Kernel: Remove friend classes from ProcFSComponentsRegistrarAndreas Kling
2021-07-11Kernel: Replace "Folder" => "Directory" everywhereAndreas Kling
Folders are a GUI concept, file systems have directories. :^)
2021-07-11Kernel: Rename FS => FileSystemAndreas Kling
This matches our common naming style better.
2021-07-02Kernel/ProcFS: Clean dead processes properlyLiav A
Now we use WeakPtrs to break Ref-counting cycle. Also, we call the prepare_for_deletion method to ensure deleted objects are ready for deletion. This is necessary to ensure we don't keep dead processes, which would become zombies. In addition to that, add some debug prints to aid debug in the future.
2021-06-29Kernel/ProcFS: Split code into more separate filesLiav A
Instead of using one file for the entire "backend" of the ProcFS data and metadata, we could split that file into two files that represent 2 logical chunks of the ProcFS exposed objects: 1. Global and inter-process information. This includes all fixed data in the root folder of the ProcFS, networking information and the bus folder. 2. Per-process information. This includes all dynamic data about a process that resides in the /proc/PID/ folder. This change makes it more easier to read the code and to change it, hence we do it although there's no technical benefit from it now :)
2021-06-29Kernel: Don't copy a Vector<FileDescriptionAndFlags>Liav A
Instead of copying a Vector everytime we need to enumerate a Process' file descriptions, we can just temporarily lock so it won't change.
2021-06-29Kernel: Introduce the new ProcFS designLiav A
The new ProcFS design consists of two main parts: 1. The representative ProcFS class, which is derived from the FS class. The ProcFS and its inodes are much more lean - merely 3 classes to represent the common type of inodes - regular files, symbolic links and directories. They're backed by a ProcFSExposedComponent object, which is responsible for the functional operation behind the scenes. 2. The backend of the ProcFS - the ProcFSComponentsRegistrar class and all derived classes from the ProcFSExposedComponent class. These together form the entire backend and handle all the functions you can expect from the ProcFS. The ProcFSExposedComponent derived classes split to 3 types in the manner of lifetime in the kernel: 1. Persistent objects - this category includes all basic objects, like the root folder, /proc/bus folder, main blob files in the root folders, etc. These objects are persistent and cannot die ever. 2. Semi-persistent objects - this category includes all PID folders, and subdirectories to the PID folders. It also includes exposed objects like the unveil JSON'ed blob. These object are persistent as long as the the responsible process they represent is still alive. 3. Dynamic objects - this category includes files in the subdirectories of a PID folder, like /proc/PID/fd/* or /proc/PID/stacks/*. Essentially, these objects are always created dynamically and when no longer in need after being used, they're deallocated. Nevertheless, the new allocated backend objects and inodes try to use the same InodeIndex if possible - this might change only when a thread dies and a new thread is born with a new thread stack, or when a file descriptor is closed and a new one within the same file descriptor number is opened. This is needed to actually be able to do something useful with these objects. The new design assures that many ProcFS instances can be used at once, with one backend for usage for all instances.