mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Support trailing slashes in VFS::mkdir()
This is apparently a special case unlike any other, so let's handle it directly in VFS::mkdir() instead of adding an alternative code path into VFS::resolve_path(). Fixes https://github.com/SerenityOS/serenity/issues/1253
This commit is contained in:
parent
7ff256aab6
commit
3439498744
1 changed files with 7 additions and 0 deletions
|
@ -334,6 +334,13 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
|
|||
|
||||
KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
|
||||
{
|
||||
// Unlike in basically every other case, where it's only the last
|
||||
// path component (the one being created) that is allowed not to
|
||||
// exist, POSIX allows mkdir'ed path to have trailing slashes.
|
||||
// Let's handle that case by trimming any trailing slashes.
|
||||
while (path.length() > 1 && path.ends_with("/"))
|
||||
path = path.substring_view(0, path.length() - 1);
|
||||
|
||||
RefPtr<Custody> parent_custody;
|
||||
auto result = resolve_path(path, base, &parent_custody);
|
||||
if (!result.is_error())
|
||||
|
|
Loading…
Add table
Reference in a new issue