Commit Graph

868 Commits

Author SHA1 Message Date
Andreas Kling
d40ea1a0a8 Kernel: Move SystemExposed.* => FileSystem/SysFSComponent.* 2021-07-11 01:14:53 +02:00
Andreas Kling
807aadbe6e Kernel: Remove some dead code and unused includes in SysFS files 2021-07-11 01:13:24 +02:00
Andreas Kling
98acebf56b Kernel: Move SysFS forward declarations to FileSystem/Forward.h 2021-07-11 01:09:48 +02:00
Andreas Kling
60a7a9d523 Kernel: Rename SystemExposedFolder => SysFSDirectory
"Folder" is a GUI concept, let's call this "Directory".
Also, "System" is completely generic, so let's be more specific and
call this "SysFS..."
2021-07-11 01:07:27 +02:00
Andreas Kling
517170a986 Kernel: Rename SystemExposedComponent => SysFSComponent 2021-07-11 01:06:27 +02:00
Andreas Kling
27244eb0ee Kernel: Rename SystemRegistrar => SysFSComponentRegistry 2021-07-11 01:05:26 +02:00
Andreas Kling
ea8578bf11 Kernel: Remove unnecessary includes in FileSystem.{cpp,h} 2021-07-11 01:01:54 +02:00
Andreas Kling
66f483b1a1 Kerne: Switch SysFS to east-const style 2021-07-11 00:56:53 +02:00
Andreas Kling
7a4e6257b7 Kernel: Switch Custody to east-const style 2021-07-11 00:51:38 +02:00
Andreas Kling
4238e2e9be Kernel: Only allow looking up Mounts by InodeIdentifier
Let's simplify the interface by not allowing lookup by Inode&.
2021-07-11 00:51:06 +02:00
Andreas Kling
6a27de2d94 Kernel: Make VirtualFileSystem::Mount a top-level class
And move it to its own compilation unit.
2021-07-11 00:51:06 +02:00
Andreas Kling
79552c91d5 Kernel: Rename BlockBasedFS => BlockBasedFileSystem 2021-07-11 00:34:36 +02:00
Andreas Kling
502bbacea0 Kernel: Rename FileBackedFS => FileBackedFileSystem 2021-07-11 00:33:27 +02:00
Andreas Kling
07c4c89297 Kernel: Make VirtualFileSystem::sync() static 2021-07-11 00:26:17 +02:00
Andreas Kling
0d39bd04d3 Kernel: Rename VFS => VirtualFileSystem 2021-07-11 00:25:24 +02:00
Andreas Kling
d53d9d3677 Kernel: Rename FS => FileSystem
This matches our common naming style better.
2021-07-11 00:20:38 +02:00
Max Wipfli
d5722eab36 Kernel: Custody::absolute_path() => try_create_absolute_path()
This converts most users of Custody::absolute_path() to use the new
try_create_absolute_path() API, and return ENOMEM if the KString
allocation fails.
2021-07-07 15:32:17 +02:00
Max Wipfli
95f769ea51 Kernel: Add Custody::try_create_absolute_path()
This adds a way to get a Custody's absolute path as KString, which
enables it to fail gracefully on OOM.
2021-07-07 15:32:17 +02:00
Max Wipfli
1f792faf34 Kernel: Add KLexicalPath::try_join and use it
This adds KLexicalPath::try_join(). As this cannot be done without
allocation, it uses KString and can fail. This patch also uses it at one
place. All the other cases of String::formatted("{}/{}", ...) currently
rely on the return value being a String, which means they cannot easily
be converted to use the new API.
2021-07-07 15:32:17 +02:00
Max Wipfli
ee342f5ec3 Kernel: Replace usage of LexicalPath with KLexicalPath
This replaces all uses of LexicalPath in the Kernel with the functions
from KLexicalPath. This also allows the Kernel to stop including
AK::LexicalPath.
2021-07-07 15:32:17 +02:00
Jean-Baptiste Boric
fdb5367da1 Kernel: Promote various integers to 64 bits in storage layer 2021-07-06 00:16:22 +02:00
Max Wipfli
8a295299f3 Kernel: Fix regression in VFS::symlink
The create_child method should be called with basename, not the full
linkpath.
2021-07-05 19:12:31 +02:00
Max Wipfli
502436f9fc Kernel: Stricter path checking in validate_path_against_process_veil
This change enforces that paths passed to
VFS::validate_path_against_process_veil are absolute and do not contain
any '..' or '.' parts. We should VERIFY here instead of returning EINVAL
since the code that calls this should resolve non-canonical paths before
calling this function.
2021-07-05 18:51:21 +02:00
Max Wipfli
82c25aad01 Kernel: Use the static LexicalPath::basename(String) in VFS
This is just for improved code clarity, and shouldn't change anything
else.
2021-07-05 18:51:21 +02:00
Max Wipfli
3c0272126e Kernel: Don't allocate Strings unnecessarily in process veil validation
Previously, Custody::absolute_path() was called for every call to
validate_path_against_process_veil(). For processes that don't have a
veil, the path is not used by the function. This means that it is
unnecessarily generated. This introduces an overload to
validate_path_against_process_veil(), which takes a Custody const& and
only generates the absolute path if it there is actually a veil and it
is thus needed.

This patch results in a speed up of Assistant's file system cache
building by around 16 percent.
2021-07-05 18:51:21 +02:00
Daniel Bertalan
42d197cde7 Kernel: Fix miscellaneous warnings when building with Clang
These small changes fix the remaining warnings that come up during
kernel compilation with Clang. These specific fixes were for benign
things: unused lambda captures and braces around scalar initializers.
2021-07-03 01:56:31 +04:30
Daniel Bertalan
b97a00d4b1 Kernel: Add missing override specifiers
The `#pragma GCC diagnostic` part is needed because the class has
virtual methods with the same name but different arguments, and Clang
tries to warn us that we are not actually overriding anything with
these.

Weirdly enough, GCC does not seem to care.
2021-07-03 01:56:31 +04:30
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
Max Wipfli
7405536a1a AK+Everywhere: Use mostly StringView in LexicalPath
This changes the m_parts, m_dirname, m_basename, m_title and m_extension
member variables to StringViews onto the m_string String. It also
removes the m_is_absolute member in favour of computing if a path is
absolute in the is_absolute() getter. Due to this, the canonicalize()
method has been completely rewritten.

The parts() getter still returns a Vector<String>, although it is no
longer a const reference as m_parts is no longer a Vector<String>.
Rather, it is constructed from the StringViews in m_parts upon request.
The parts_view() getter has been added, which returns Vector<StringView>
const&. Most previous users of parts() have been changed to use
parts_view(), except where Strings are required.

Due to this change, it's is now no longer allow to create temporary
LexicalPath objects to call the dirname, basename, title, or extension
getters on them because the returned StringViews will point to possible
freed memory.
2021-06-30 11:13:54 +02:00
Max Wipfli
fc6d051dfd AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.

To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
2021-06-30 11:13:54 +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
d79d9e833e Kernel/ProcFS: Tighten permissions on the exposed objects
This is needed so we properly set the limits for different objects in
the filesystem.
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
Liav A
1baa05d6b2 Kernel/SysFS: Add PCI exposed folder 2021-06-29 20:53:59 +02:00
Liav A
92c0dab5ab Kernel: Introduce the new SysFS
The intention is to add dynamic mechanism for notifying the userspace
about hotplug events. Currently, the DMI (SMBIOS) blobs and ACPI tables
are exposed in the new filesystem.
2021-06-29 20:53:59 +02:00
Liav A
b8ec5449f2 Kernel: Remove DMI exposed blobs from ProcFS
This was a hack I wrote merely to allow dmidecode to find these blobs
somewhere.

These blobs are going to be part of upcoming SysFS :)
2021-06-29 20:53:59 +02:00
Daniel Bertalan
f820917a76 Everywhere: Use nothrow new with adopt_{ref,own}_if_nonnull
This commit converts naked `new`s to `AK::try_make` and `AK::try_create`
wherever possible. If the called constructor is private, this can not be
done, so we instead now use the standard-defined and compiler-agnostic
`new (nothrow)`.
2021-06-24 17:35:49 +04:30
Gunnar Beutner
441d6dcdf9 Kernel: Fix compiling TmpFSInode::write_bytes on x86_64 2021-06-24 09:27:13 +02:00
Hendiadyoin1
62f9377656 Kernel: Move special sections into Sections.h
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24 00:38:23 +02:00
Hendiadyoin1
7ca3d413f7 Kernel: Pull apart CPU.h
This does not add any functional changes
2021-06-24 00:38:23 +02:00
Sam Atkins
ab7023dbe5 Kernel: Ensure Ext2FSInode's lookup is populated before using it
This fixes #8133.

Ext2FSInode::remove_child() searches the lookup cache, so if it's not
initialized, removing the child fails. If the child was a directory,
this led to it being corrupted and having 0 children.

I also added populate_lookup_cache to add_child. I hadn't seen any
bugs there, but if the cache wasn't populated before, adding that
one entry would make it think it was populated, so that would cause
bugs later.
2021-06-22 11:01:59 +02:00
Jesse Buhagiar
f2ff55dd09 Kernel: Add /proc/bus/usb to store information about connected devices 2021-06-18 17:04:57 +04:30
Tim Schumacher
9559ac9dd6 Kernel: Correctly decode proc_file_type from identifier
inode identifiers in ProcFS are encoded in a way that the parent ID is
shifted 12 bits to the left and the PID is shifted by 16 bits. This
means that the rightmost 12 bits are reserved for the file type or the
fd.

Since the to_fd and to_proc_file_type decoders only decoded the
rightmost 8 bits, decoded values would wrap around beyond values of 255,
resulting in a different value compared to what was originally encoded.
2021-06-18 10:15:14 +02:00
Gunnar Beutner
58c182b19e Kernel: Update check in Inode::read_entire
The nread variable can't be less than zero anymore.
2021-06-17 19:52:54 +02:00
Gunnar Beutner
bf779e182e Kernel: Remove obsolete size_t casts 2021-06-17 19:52:54 +02:00
Gunnar Beutner
bc3076f894 Kernel: Remove various other uses of ssize_t 2021-06-16 21:29:36 +02:00
Andreas Kling
dc65f54c06 AK: Rename Vector::append(Vector) => Vector::extend(Vector)
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
2021-06-12 13:24:45 +02:00
Max Wipfli
90e229c9b5 Kernel: Use m_inode to stat in FileDescription::stat() if available
This is necessary since the Device class does not hold a reference to
its inode (because there could be multiple), and thus doesn't override
File::stat(). For simplicity, we should just always stat via the inode
if there is one, since that shouldn't ever be the wrong thing.

This partially reverts #7867.
2021-06-11 12:09:26 +02:00
Liav A
1c94b5e8eb Kernel: Introduce the NetworkingManagement singleton
Instead of initializing network adapters in init.cpp, let's move that
logic into a separate class to handle this.
Also, it seems like a good idea to shift responsiblity on enumeration
of network adapters after the boot process, so this singleton will take
care of finding the appropriate network adapter when asked to with an
IPv4 address or interface name.

With this change being merged, we simplify the creation logic of
NetworkAdapter derived classes, so we enumerate the PCI bus only once,
searching for driver candidates when doing so, and we let each driver
to test if it is resposible for the specified PCI device.
2021-06-09 22:44:09 +04:30
Max Wipfli
c1de46aaaf Kernel: Don't assume there are no nodes if m_unveiled_paths.is_empty()
If m_unveiled_paths.is_empty(), the root node (which is m_unveiled_paths
itself) is the matching veil. This means we should not return nullptr in
this case, but just use the code path for the general case.

This fixes a bug where calling e.g. unveil("/", "r") would refuse you
access to anything, because find_matching_unveiled_path would wrongly
return nullptr.

Since find_matching_unveiled_path can no longer return nullptr, we can
now just return a reference instead.
2021-06-08 12:15:04 +02:00
Max Wipfli
cac94b1c16 Kernel: Implement InodeFile::stat() and simplify FileDescription::stat() 2021-06-08 11:12:31 +02:00
Jelle Raaijmakers
3dab9d0b5c Kernel: Implement offset for lseek with SEEK_END 2021-06-04 23:49:48 +02:00
Brian Gianforcaro
cbe1e05771 Kernel: Move ProcFS API towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
23c021912e Kernel: Move TmpFS towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
8f9872581b Kernel: Move DevFS APIs towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
d2d6ab40f9 Kernel: Make AnonymousFile::create API OOM safe 2021-06-01 23:14:40 +01:00
Ali Mohammad Pur
2b5732ab77 AK+Kernel: Disallow implicitly lifting pointers to OwnPtr's
This doesn't really _fix_ anything, it just gets rid of the API and
instead makes the users explicitly use `adopt_own_if_non_null()`.
2021-05-31 17:09:12 +04:30
Ali Mohammad Pur
90de1ded55 Kernel: Ensure that an unveil node with no permission is never accepted
Otherwise nodes inheriting from root may still be accessed with
`access(..., F_OK)`.
Also adds a test case to TestKernelUnveil about this behaviour.
2021-05-29 22:05:34 +02:00
Andreas Kling
9d801d2345 Kernel: Rename Custody::create() => try_create()
The try_ prefix indicates that this may fail. :^)
2021-05-28 11:23:00 +02:00
Andreas Kling
9a827ad3da Kernel: Use a KString for Custody::m_name 2021-05-28 11:21:00 +02:00
Andrew Kaster
505f84daae Kernel+AK: Move UBSanitizer to AK, and to AK namespace
In preparation for copying UBSanitizer to userspace, move the header to
AK :^)
2021-05-27 15:18:03 +02:00
Brian Gianforcaro
493d4d1cd7 Kernel: Switch Inode to IntrusiveList from InlineLinkedList 2021-05-26 20:24:32 +02:00
Mart G
e16a50b586
Kernel: Remove an allocation from VFS::resolve_path_without_veil (#7287)
Use GenericLexer to replace a call to StringView::split() since that
returns its result in a heap-allocating Vector.
2021-05-22 00:12:32 +02:00
Lenny Maiorani
5751327195 Kernel: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-19 21:21:47 +01:00
Justin
721a867c65 Kernel: Expose FileSystem's fragment size
This commit will add a fragment_size() function similar to the
block_size() function.
2021-05-19 21:33:29 +02:00
Max Wipfli
9cc201fb29 Kernel: Ignore null parent custody without error in VFS::open
This modifies the error checks in VFS::open after the call to
resolve_path to ignore a null parent custody if there is no error, as
this is expected when the path to resolve points to "/". Rather, a null
parent custody only constitutes an error if it is accompanied by ENOENT.
This behavior is documented in the VFS::resolve_path_without_veil
method.

To accompany this change, the order of the error checks have been
changed to more naturally fit the new logic.
2021-05-19 12:27:25 +02:00
Liav A
8f2ddde4cb Kernel: Rename Console => ConsoleDevice
This change will help to distinguish between the console
device and the Console abstraction layer in the Graphics
subsystem later.
2021-05-16 19:58:33 +02:00
Nicholas Baron
aa4d41fe2c
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best
fitting one. All this will require is duplicating the implementation and
simplifying for the `void` case.

This constraining also informs both the caller and compiler by passing
the callback parameter types as part of the constraint
(e.g.: `IterationFunction<int>`).

Some `for_each` functions in LibELF only take functions which return
`void`. This is a minimal correctness check, as it removes one way for a
function to incompletely do something.

There seems to be a possible idiom where inside a lambda, a `return;` is
the same as `continue;` in a for-loop.
2021-05-16 10:36:52 +01:00
Andreas Kling
e46343bf9a Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr<size_t>
This makes error propagation less cumbersome (and also exposed some
places where we were not doing it.)
2021-05-13 23:28:40 +02:00
Brian Gianforcaro
0d50d3ed1e Kernel: Make InodeWatcher::crate API OOM safe 2021-05-13 16:21:53 +02:00
Brian Gianforcaro
fb40da0429 Kernel: Replace make<T>() with adopt_own_if_nonnull() in Ext2FileSystem
The make<T> factory function allocates internally and immediately
dereferences the pointer, and always returns a NonnullOwnPtr<T> making
it impossible to propagate an error on OOM.
2021-05-13 16:21:53 +02:00
Brian Gianforcaro
5dc5f31f76 Kernel: Replace bare new in Custody::create() with adopt_ref_if_nonnull 2021-05-13 16:21:53 +02:00
Brian Gianforcaro
b8fd52fad6 Kernel: Remove unused header from FileDescription.cpp 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
a643ee5759 Kernel: Move FileDescription::get_dir_entries to KResultOr<ssize_t>
This normalizes the error handling with the rest of the subsystem.
2021-05-13 08:29:01 +02:00
Brian Gianforcaro
12ab0dcee0 Kernel: Make FileDescription::create() APIs OOM safe 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
11bd2002bb Kernel: Make InodeFile::create() API OOM safe 2021-05-13 08:29:01 +02:00
sin-ack
fe5ca6ca27 Kernel: Implement multi-watch InodeWatcher :^)
This patch modifies InodeWatcher to switch to a one watcher, multiple
watches architecture.  The following changes have been made:

- The watch_file syscall is removed, and in its place the
  create_iwatcher, iwatcher_add_watch and iwatcher_remove_watch calls
  have been added.
- InodeWatcher now holds multiple WatchDescriptions for each file that
  is being watched.
- The InodeWatcher file descriptor can be read from to receive events on
  all watched files.

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-05-12 22:38:20 +02:00
Mart G
b00cdf8ed8 Kernel+LibC: Make get_dir_entries syscall retriable
The get_dir_entries syscall failed if the serialized form of all the
directory entries together was too large to fit in its temporary buffer.

Now the kernel uses a fixed size buffer, that is flushed to an output
buffer when it is full. If this flushing operation fails because there
is not enough space available, the syscall will return -EINVAL. That
error code is then used in userspace as a signal to allocate a larger
buffer and retry the syscall.
2021-05-12 12:50:23 +02:00
Brian Gianforcaro
0b7395848a Kernel: Plumb OOM propagation through Custody factory
Modify the Custody::create(..) API so it has the ability to propagate
OOM back to the caller.
2021-05-10 11:55:52 +02:00
Mart G
e0deb46723 Kernel: Traverse ext2 directories blockwise.
Instead of reading in the entire contents of a directory into a large
buffer, we can iterate block by block. This only requires a small
buffer.

Because directory entries are guaranteed to never span multiple blocks
we do not have to handle any edge cases related to that.
2021-05-08 20:01:08 +02:00
Mart G
25a5e59f79 Kernel: Place ext2 dir entries so they don't span multiple blocks
Ext2 dir entries spanning multiple blocks are not allowed.
If they do occur they are flagged as corrupt by e2fsck for example.
2021-05-08 15:25:50 +02:00
r-paiva
293a5c2b49 Kernel-VFS: Fixed kernel crash if parent custody is null
In VFS::rename, if new_path is equal to '/', then, parent custody is
set to null.
VFS::rename would then use parent custody without checking it first.

Fixed VFS::rename to check both old and new path parent custody
before actually using them.
2021-05-08 15:22:47 +02:00
Mart G
cab6155254 Kernel: Allow Ext2FSInode::write_bytes calls with a byte count of zero
write_bytes is called with a count of 0 bytes if a directory is being
deleted, because in that case even the . and .. pseudo directories are
getting removed. In this case write_bytes is now a no-op.

Before write_bytes would fail because it would check to see if there
were any blocks available to write in (even though it wasn't going to
write in them anyway).

This behaviour was uncovered because of a recent change where
directories are correctly reduced in size. Which in this case results in
all the blocks being removed from the inode, whereas previously there
would be some stale blocks around to pass the check.
2021-05-07 21:11:55 +02:00
Mart G
bfce328ade Kernel: Set unused block pointers in ext2 inodes to zero
e2fsck considers all blocks reachable through any of the pointers in
m_raw_inode.i_block as part of this inode regardless of the value in
m_raw_inode.i_size. When it finds more blocks than the amount that
is indicated by i_size or i_blocks it offers to repair the filesystem
by changing those values. That will actually cause further corruption.
So we must zero all pointers to blocks that are now unused.
2021-05-07 20:13:00 +02:00
Mart G
6e641fadfa
Kernel: Resize Ext2FSInode when writing directory contents (#6897)
Ext2 directory contents are stored in a linked list of ext2_dir_entry
structs. There is no sentinel value to determine where the list ends.
Instead the list fills the entirety of the allocated space for the
inode.

Previously the inode was not correctly resized when it became smaller.
This resulted in stale data being interpreted as part of the linked list
of directory entries.
2021-05-06 17:53:59 +02:00
Spencer Dixon
0f89e47a1a
Kernel: Allow remapping Caps Lock to Control (#6883)
We use a global setting to determine if Caps Lock should be remapped to
Control because we don't care how keyboard events come in, just that they
should be massaged into different scan codes.

The `proc` filesystem is able to manipulate this global variable using
the `sysctl` utility like so:

```
# sysctl caps_lock_to_ctrl=1
```
2021-05-05 23:10:56 +02:00
Spencer Dixon
2156c728cd
Kernel: Fix writes to ProcFS (#6879)
When using `sysctl` you can enable/disable values by writing to the
ProcFS. Some drift must have occured where writing was failing due to
a missing `set_mtime` call. Whenever one `write`'s a file the modified
time (mtime) will be updated so we need to implement this interface in
ProcFS.
2021-05-05 21:07:13 +02:00
Brian Gianforcaro
35bb8ab4db Kernel: Return one kernel frame from procfs$tid_stack for normal users.
Previously we would return a 0xdeadc0de frame for every kernel frame
in the real kernel stack when an non super-user issued the request.
This isn't useful, and just produces visual clutter in tools which
attempt to symbolize stacks.
2021-05-04 10:57:39 +02:00
Brian Gianforcaro
869becc944 Kernel: Remove unused function ProcFS::add_sys_string 2021-05-04 10:57:39 +02:00
Brian Gianforcaro
9b5c137f46 Kernel: Remove unused header includes from ProcFS.cpp 2021-05-04 10:57:39 +02:00
Gunnar Beutner
6990ab41c8 Kernel: Fix some 64-bit portability issues 2021-05-03 08:42:39 +02:00
Spencer Dixon
27bfb01f25 Kernel: Fix ProcFS for non-process backed sub dirs
While hacking on `sysctl` an issue in ProcFS was making me unable to
read/write from `/proc/sys/XXX`. Some directories in the ProcFS are not
actually backed by a process and need to return `nullptr` so callbacks
get properly set. We now do an explicit check for the parent to ensure
it's one that is PID-based.
2021-05-02 19:21:42 +02:00
Brian Gianforcaro
234c6ae32d Kernel: Change Inode::{read/write}_bytes interface to KResultOr<ssize_t>
The error handling in all these cases was still using the old style
negative values to indicate errors. We have a nicer solution for this
now with KResultOr<T>. This change switches the interface and then all
implementers to use the new style.
2021-05-02 13:27:37 +02:00
Brian Gianforcaro
f05086a5d2 Kernel: Harden Ext2FileSystem Vector usage against OOM. 2021-05-01 09:10:30 +02:00
Brian Gianforcaro
ee84b8a845 Kernel: Harden DevFS Vector usage against OOM.
The dance here is not complicated, but it is something that should
be taken note of. Since we append to both lists, we don't want to
orphan the new Inode in the m_links/m_subfolders Vector in the event
that the append to m_parent_fs.m_nodes fails.
2021-05-01 09:10:30 +02:00
Gunnar Beutner
488ee56cf7 Kernel: chmod()/chown() for PTYs should return EROFS
All the other methods already do this and this is also what OpenSSH
expects when trying to change modes/ownership for devpts files.
2021-04-30 23:10:22 +02:00
Andreas Kling
cd9be1733c Kernel: Make Inode::set_{a,c,m}time return KResult
This exposed some missing error propagation, which this patch also
takes care of.
2021-04-30 15:51:06 +02:00
Gunnar Beutner
7a1d09ef1a Kernel: Closing a file descriptor should not always close the file
When there is more than one file descriptor for a file closing
one of them should not close the underlying file.

Previously this relied on the file's ref_count() but at least
for sockets this didn't work reliably.
2021-04-30 11:42:35 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00