summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/dirent.cpp
AgeCommit message (Collapse)Author
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-16LibC: Fix `scandir` not checking for allocation failureMichel Hermier
2021-12-28LibC: Add alphasort() implementationBrian Gianforcaro
This is a POSIX API required for the latest stress-ng port.
2021-12-28LibC: Add POSIX spec comments for dirent APIsBrian Gianforcaro
2021-08-14LibC: Add function fdopendirKenneth Myhra
This adds the function fdopendir and refactors opendir so that opendir just opens a file descriptor and passes the file descriptor onto fdopendir.
2021-08-12Kernel+LibC: Use 64 bit values for ino_tLiav A
Since the InodeIndex encapsulates a 64 bit value, it is correct to ensure that the Kernel is exposing the entire value and the LibC is aware of it. This commit requires an entire re-compile because it's essentially a change in the Kernel ABI, together with a corresponding change in LibC.
2021-08-08Userland: Use kmalloc_array() where appropriateAndreas Kling
2021-06-29LibC: Fix struct layout for sys_dirent on x86_64Gunnar Beutner
2021-05-12Kernel+LibC: Make get_dir_entries syscall retriableMart G
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-03LibC: Fix invalid 1-byte read I introduced in dirent.Brian Gianforcaro
When attempting to fix the dirent code I also changed this to use strlcpy instead of the custom string copy loop that was there before. Looking over strlcpy it looked like it should work when using a non null terminated string, I obviously misinterpreted the implementation as it will read till it finds a null terminator. Manually null terminate the string to address this. Gunnar found this after he fixed UserspaceEmulator. I reproduced it locally using his branch, and also found the memory leak I had in the unit test for the scandir that I added, so lets fix that as well. Reported-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-02LibC: Implement scandir(...) to enumerate directories.Brian Gianforcaro
I ran into a need for this when running stress-ng against the system. This change implements the full functionality of scandir, where it accepts a selection callback, as well as a comparison callback. These can be used to trim and sort the entries from the directory that we are being asked to enumerate. A test was also included to validate the new functionality.
2021-05-02LibC: Fix bugs in the population of dirent members.Brian Gianforcaro
While adding new functionality which used the d_reclen member to copy a dirent, I realized that the value being populated was incorrect. sys_ent::total_size() function calculates the size of the sys_ent structure, but dirent is larger than sys_ent. This causes the malloc to be too small and you end up missing the end of the copy, which can miss the null terminator resulting in corrupt dirent names. Since we don't actually use the variable length member nature of dirent on other platforms we can just use the full size of the struct ad the d_reclen value. Also replace the custom strcpy with the standard version.
2021-04-25LibC: Implement the rewinddir() functionGunnar Beutner
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-05Userland: Add LibSystem and funnel all syscalls through itAndreas Kling
This achieves two things: - Programs can now intentionally perform arbitrary syscalls by calling syscall(). This allows us to work on things like syscall fuzzing. - It restricts the ability of userspace to make syscalls to a single 4KB page of code. In order to call the kernel directly, an attacker must now locate this page and call through it.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling