summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
AgeCommit message (Collapse)Author
2021-07-11Kernel: Remove some dead code and unused includes in SysFS filesAndreas Kling
2021-07-11Kernel: Move SysFS forward declarations to FileSystem/Forward.hAndreas Kling
2021-07-11Kernel: Rename SystemExposedFolder => SysFSDirectoryAndreas Kling
"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-11Kernel: Rename SystemExposedComponent => SysFSComponentAndreas Kling
2021-07-11Kernel: Rename SystemRegistrar => SysFSComponentRegistryAndreas Kling
2021-07-11Kernel: Remove unnecessary includes in FileSystem.{cpp,h}Andreas Kling
2021-07-11Kerne: Switch SysFS to east-const styleAndreas Kling
2021-07-11Kernel: Switch Custody to east-const styleAndreas Kling
2021-07-11Kernel: Only allow looking up Mounts by InodeIdentifierAndreas Kling
Let's simplify the interface by not allowing lookup by Inode&.
2021-07-11Kernel: Make VirtualFileSystem::Mount a top-level classAndreas Kling
And move it to its own compilation unit.
2021-07-11Kernel: Rename BlockBasedFS => BlockBasedFileSystemAndreas Kling
2021-07-11Kernel: Rename FileBackedFS => FileBackedFileSystemAndreas Kling
2021-07-11Kernel: Make VirtualFileSystem::sync() staticAndreas Kling
2021-07-11Kernel: Rename VFS => VirtualFileSystemAndreas Kling
2021-07-11Kernel: Rename FS => FileSystemAndreas Kling
This matches our common naming style better.
2021-07-07Kernel: Custody::absolute_path() => try_create_absolute_path()Max Wipfli
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-07Kernel: Add Custody::try_create_absolute_path()Max Wipfli
This adds a way to get a Custody's absolute path as KString, which enables it to fail gracefully on OOM.
2021-07-07Kernel: Add KLexicalPath::try_join and use itMax Wipfli
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-07Kernel: Replace usage of LexicalPath with KLexicalPathMax Wipfli
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-06Kernel: Promote various integers to 64 bits in storage layerJean-Baptiste Boric
2021-07-05Kernel: Fix regression in VFS::symlinkMax Wipfli
The create_child method should be called with basename, not the full linkpath.
2021-07-05Kernel: Stricter path checking in validate_path_against_process_veilMax Wipfli
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-05Kernel: Use the static LexicalPath::basename(String) in VFSMax Wipfli
This is just for improved code clarity, and shouldn't change anything else.
2021-07-05Kernel: Don't allocate Strings unnecessarily in process veil validationMax Wipfli
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-03Kernel: Fix miscellaneous warnings when building with ClangDaniel Bertalan
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-03Kernel: Add missing override specifiersDaniel Bertalan
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-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-30AK+Everywhere: Use mostly StringView in LexicalPathMax Wipfli
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-30AK+Everywhere: Add and use static APIs for LexicalPathMax Wipfli
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-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/ProcFS: Tighten permissions on the exposed objectsLiav A
This is needed so we properly set the limits for different objects in the filesystem.
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.
2021-06-29Kernel/SysFS: Add PCI exposed folderLiav A
2021-06-29Kernel: Introduce the new SysFSLiav A
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-29Kernel: Remove DMI exposed blobs from ProcFSLiav A
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-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
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-24Kernel: Fix compiling TmpFSInode::write_bytes on x86_64Gunnar Beutner
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24Kernel: Pull apart CPU.hHendiadyoin1
This does not add any functional changes
2021-06-22Kernel: Ensure Ext2FSInode's lookup is populated before using itSam Atkins
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-18Kernel: Add /proc/bus/usb to store information about connected devicesJesse Buhagiar
2021-06-18Kernel: Correctly decode proc_file_type from identifierTim Schumacher
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-17Kernel: Update check in Inode::read_entireGunnar Beutner
The nread variable can't be less than zero anymore.
2021-06-17Kernel: Remove obsolete size_t castsGunnar Beutner
2021-06-16Kernel: Remove various other uses of ssize_tGunnar Beutner
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
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-11Kernel: Use m_inode to stat in FileDescription::stat() if availableMax Wipfli
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-09Kernel: Introduce the NetworkingManagement singletonLiav A
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-08Kernel: Don't assume there are no nodes if m_unveiled_paths.is_empty()Max Wipfli
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-08Kernel: Implement InodeFile::stat() and simplify FileDescription::stat()Max Wipfli