Skip to content

Commit

Permalink
Kernel: mkdir() should use the containing directory's FS for inode cr…
Browse files Browse the repository at this point in the history
…eation.
  • Loading branch information
awesomekling committed Feb 1, 2019
1 parent 33e7df5 commit 6618411
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ int Process::sys$mkdir(const char* pathname, mode_t mode)
if (pathname_length >= 255)
return -ENAMETOOLONG;
int error;
if (!VFS::the().mkdir(String(pathname, pathname_length), mode, cwd_inode()->identifier(), error))
if (!VFS::the().mkdir(String(pathname, pathname_length), mode, *cwd_inode(), error))
return error;
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions Kernel/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ RetainPtr<FileDescriptor> VFS::create(const String& path, int& error, int option
return FileDescriptor::create(move(new_file));
}

bool VFS::mkdir(const String& path, mode_t mode, InodeIdentifier base, int& error)
bool VFS::mkdir(const String& path, mode_t mode, Inode& base, int& error)
{
error = -EWHYTHO;
// FIXME: This won't work nicely across mount boundaries.
Expand All @@ -209,7 +209,7 @@ bool VFS::mkdir(const String& path, mode_t mode, InodeIdentifier base, int& erro
}

InodeIdentifier parent_dir;
auto existing_dir = resolve_path(path, base, error, 0, &parent_dir);
auto existing_dir = resolve_path(path, base.identifier(), error, 0, &parent_dir);
if (existing_dir.is_valid()) {
error = -EEXIST;
return false;
Expand All @@ -222,7 +222,7 @@ bool VFS::mkdir(const String& path, mode_t mode, InodeIdentifier base, int& erro
return false;
}
dbgprintf("VFS::mkdir: '%s' in %u:%u\n", p.basename().characters(), parent_dir.fsid(), parent_dir.index());
auto new_dir = base.fs()->create_directory(parent_dir, p.basename(), mode, error);
auto new_dir = parent_dir.fs()->create_directory(parent_dir, p.basename(), mode, error);
if (new_dir) {
error = 0;
return true;
Expand Down
2 changes: 1 addition & 1 deletion Kernel/VirtualFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class VFS {
RetainPtr<FileDescriptor> open(RetainPtr<CharacterDevice>&&, int& error, int options);
RetainPtr<FileDescriptor> open(const String& path, int& error, int options, mode_t mode, InodeIdentifier base = InodeIdentifier());
RetainPtr<FileDescriptor> create(const String& path, int& error, int options, mode_t mode, InodeIdentifier base);
bool mkdir(const String& path, mode_t mode, InodeIdentifier base, int& error);
bool mkdir(const String& path, mode_t mode, Inode& base, int& error);
bool unlink(const String& path, Inode& base, int& error);
bool rmdir(const String& path, Inode& base, int& error);
bool chmod(const String& path, mode_t, Inode& base, int& error);
Expand Down

0 comments on commit 6618411

Please sign in to comment.