summaryrefslogtreecommitdiff
path: root/Kernel/ProcessExposed.h
AgeCommit message (Collapse)Author
2022-11-24Kernel: Use AK::Time for InodeMetadata timestamps instead of time_tAndreas Kling
Before this change, we were truncating the nanosecond part of file timestamps in many different places.
2022-10-25Kernel/ProcFS: Remove all unnecessary componentsLiav A
Now that all global nodes are located in the /sys/kernel directory, we can safely drop the global nodes in /proc, which includes both /proc/net and /proc/sys directories as well. This in fact leaves the ProcFS to only have subdirectories for processes and the "self" symbolic link to reflect the current process being run.
2022-08-22Kernel: Update atime/ctime/mtime timestamps atomicallyAndreas Kling
Instead of having three separate APIs (one for each timestamp), there's now only Inode::update_timestamps() and it takes 3x optional timestamps. The non-empty timestamps are updated while holding the inode mutex, and the outside world no longer has to look at intermediate timestamp states.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-07-30Kernel: Remove PCI information node from ProcFSLiav A
The SystemMonitor program was the last client to utilize this node, and now it is not using this node anymore, we can simply remove this for good.
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-06-19Kernel: Create /proc/pid/cmdline to expose process arguments in procfsAndrew Kaster
In typical serenity style, they are just a JSON array
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-22Kernel: Don't assume paths of TTYs and pseudo terminals anymoreLiav A
The obsolete ttyname and ptsname syscalls are removed. LibC doesn't rely on these anymore, and it helps simplifying the Kernel in many places, so it's an overall an improvement. In addition to that, /proc/PID/tty node is removed too as it is not needed anymore by userspace to get the attached TTY of a process, as /dev/tty (which is already a character device) represents that as well.
2022-03-02Kernel/PCI: Don't create /proc/pci if PCI is disabledLiav A
Reading from /proc/pci assumes we have PCI enabled and also enumerated. However, if PCI is disabled for some reason, we can't allow the user to read from it as there's no valuable data we can supply.
2022-01-30Kernel: Remove unnecessary includes from Thread.hAndreas Kling
...and deal with the fallout by adding missing includes everywhere.
2021-12-12Kernel+SystemServer: Add /dev/ttyDaniel Bertalan
This file refers to the controlling terminal associated with the current process. It's specified by POSIX, and is used by ports like openssh to interface with the terminal even if the standard input/output is redirected to somewhere else. Our implementation leverages ProcFS's existing facilities to create process-specific symbolic links. In our setup, `/dev/tty` is a symbolic link to `/proc/self/tty`, which itself is a symlink to the appropriate `/dev/pts` entry. If no TTY is attached, `/dev/tty` is left dangling.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-01Kernel: Add an x86 include check+error in x86/CPU.hJames Mintram
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-14Kernel: Convert Process-related const member functions to staticAndrew Kaster
Process::get_syscall_path_argument() and ProcFSExposedComponent::modified_time() both are independent of this.
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: 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: Make SysFS and ProcFS generator functions return KResultAndreas Kling
This allows us to propagate a whole bunch of KBufferBuilder errors.
2021-09-06Kernel: Make KBufferBuilder::append() & friends return KResultAndreas Kling
This allows callers to react to a failed append (due to OOM.)
2021-09-05AK+Kernel: Move KResult.h to Kernel/API for userspace accesssin-ack
This commit moves the KResult and KResultOr objects to Kernel/API to signify that they may now be freely used by userspace code at points where a syscall-related error result is to be expected. It also exposes KResult and KResultOr to the global namespace to make it nicer to use for userspace code.
2021-08-29Kernel: Make all ProcFS and SysFS files zero-sizedAndreas Kling
There is no value in exposing particular sizes for these files.
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-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: 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-28Kernel/ProcFS: Make various things superuser-only once againAndreas Kling
File and directory permissions regressed with the recent ProcFS changes. This patch restores the superuser-only permissions where appropriate.
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/USB: Move USB bus information from /proc to /sysAndreas Kling
This patch moves all the USB data from /proc/bus/usb to /sys/bus/usb.
2021-07-17Kernel/ProcFS: Remove unused ProcFSExposedComponent::entries_count()Andreas Kling
2021-07-17Kernel: Replace "folder" => "directory" everywhereAndreas Kling
Folders are a GUI concept. File systems have directories.
2021-07-17Kernel: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
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: Use Forward.h headers moreAndreas Kling
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-08Kernel: Pledge promises accessible via /proc/PID/pledgeRalf Donau
2021-07-02Kernel/ProcFS: Lazily allocate all sub components of a PID folderLiav A
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 and SysFS component indices should be InodeIndexAndreas Kling
This fixes the x86_64 kernel build. :^)
2021-06-29Kernel/ProcFS: Tighten modified time value across the filesystem objectsLiav A
It didn't make any sense to hardcode the modified time of all created inodes with "mepoch", so we should query the procfs "backend" to get the modified time value. Since ProcFS is dynamically changed all the time, the modified time equals to the querying time. This could be changed if desired, by making the modified_time() method virtual and overriding it in different procfs-backed objects :)
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.