Commit Graph

19 Commits

Author SHA1 Message Date
Liav A
7ba991dc37 Kernel: Steer away from heap allocations for ProcFS process data
Instead, use more static patterns to acquire that sort of data.
2021-08-12 20:57:32 +02:00
Andreas Kling
07141434e0 Kernel/ProcFS: Make various things superuser-only once again
File and directory permissions regressed with the recent ProcFS changes.
This patch restores the superuser-only permissions where appropriate.
2021-07-28 18:59:53 +02:00
Andreas Kling
a3063dfd33 Kernel: Simplify ProcFS generated buffer caching
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-20 18:05:05 +02:00
Andreas Kling
b975a74a1d Kernel/USB: Move USB bus information from /proc to /sys
This patch moves all the USB data from /proc/bus/usb to /sys/bus/usb.
2021-07-18 00:55:16 +02:00
Andreas Kling
6fae2a5f9e Kernel/ProcFS: Remove unused ProcFSExposedComponent::entries_count() 2021-07-17 23:50:01 +02:00
Andreas Kling
2da0581fd2 Kernel: Replace "folder" => "directory" everywhere
Folders are a GUI concept. File systems have directories.
2021-07-17 23:50:00 +02:00
Andreas Kling
cee9528168 Kernel: Rename Lock to Mutex
Let's be explicit about what kind of lock this is meant to be.
2021-07-17 21:10:32 +02:00
Liav A
bee75c1f24 Kernel/ProcFS: Allow a process directory to have a null Process pointer
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-14 13:40:01 +02:00
Andreas Kling
98080497d2 Kernel: Use Forward.h headers more 2021-07-11 14:14:51 +02:00
Andreas Kling
fa9111ac46 Kernel: Rename ProcFSComponentsRegistrar => ProcFSComponentRegistry
This matches the formatting used in SysFS.
2021-07-11 01:40:26 +02:00
Andreas Kling
c1143e1bae Kernel: Remove friend classes from ProcFSComponentsRegistrar 2021-07-11 01:39:51 +02:00
Andreas Kling
805319ed30 Kernel: Replace "Folder" => "Directory" everywhere
Folders are a GUI concept, file systems have directories. :^)
2021-07-11 01:33:40 +02:00
Andreas Kling
d53d9d3677 Kernel: Rename FS => FileSystem
This matches our common naming style better.
2021-07-11 00:20:38 +02:00
Ralf Donau
6113fe4747 Kernel: Pledge promises accessible via /proc/PID/pledge 2021-07-08 01:16:26 +02:00
Liav A
32a4a4ac19 Kernel/ProcFS: Lazily allocate all sub components of a PID folder 2021-07-02 13:16:12 +02:00
Liav A
3344f91fc4 Kernel/ProcFS: Clean dead processes properly
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-07-02 13:16:12 +02:00
Andreas Kling
fd06b8b713 Kernel: ProcFS and SysFS component indices should be InodeIndex
This fixes the x86_64 kernel build. :^)
2021-06-29 23:07:02 +02:00
Liav A
1f98d7d638 Kernel/ProcFS: Tighten modified time value across the filesystem objects
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-29 20:53:59 +02:00
Liav A
12b6e69150 Kernel: Introduce the new ProcFS design
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.
2021-06-29 20:53:59 +02:00