Skip to content

Commit

Permalink
FileSystem: Rename VFS::resolve_path_to_custody() => resolve_path().
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed May 31, 2019
1 parent 8adadf8 commit 056a7fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 19 additions & 19 deletions Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ InodeIdentifier VFS::root_inode_id() const

bool VFS::mount(Retained<FS>&& file_system, StringView path)
{
auto result = resolve_path_to_custody(path, root_custody());
auto result = resolve_path(path, root_custody());
if (result.is_error()) {
kprintf("VFS: mount can't resolve mount point '%s'\n", path.characters());
return false;
Expand Down Expand Up @@ -143,15 +143,15 @@ KResult VFS::utime(StringView path, Custody& base, time_t atime, time_t mtime)

KResult VFS::stat(StringView path, int options, Custody& base, struct stat& statbuf)
{
auto custody_or_error = resolve_path_to_custody(path, base, nullptr, options);
auto custody_or_error = resolve_path(path, base, nullptr, options);
if (custody_or_error.is_error())
return custody_or_error.error();
return FileDescriptor::create(custody_or_error.value().ptr())->fstat(statbuf);
}

KResultOr<Retained<FileDescriptor>> VFS::open(StringView path, int options, mode_t mode, Custody& base)
{
auto custody_or_error = resolve_path_to_custody(path, base, nullptr, options);
auto custody_or_error = resolve_path(path, base, nullptr, options);
if (options & O_CREAT) {
if (custody_or_error.is_error())
return create(path, options, mode, base);
Expand Down Expand Up @@ -203,7 +203,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
return KResult(-EINVAL);

RetainPtr<Custody> parent_custody;
auto existing_file_or_error = resolve_path_to_custody(path, base, &parent_custody);
auto existing_file_or_error = resolve_path(path, base, &parent_custody);
if (!existing_file_or_error.is_error())
return KResult(-EEXIST);
if (!parent_custody)
Expand Down Expand Up @@ -234,7 +234,7 @@ KResultOr<Retained<FileDescriptor>> VFS::create(StringView path, int options, mo
}

RetainPtr<Custody> parent_custody;
auto existing_custody_or_error = resolve_path_to_custody(path, base, &parent_custody);
auto existing_custody_or_error = resolve_path(path, base, &parent_custody);
if (!existing_custody_or_error.is_error())
return KResult(-EEXIST);
if (!parent_custody)
Expand All @@ -259,7 +259,7 @@ KResultOr<Retained<FileDescriptor>> VFS::create(StringView path, int options, mo
KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
{
RetainPtr<Custody> parent_custody;
auto result = resolve_path_to_custody(path, base, &parent_custody);
auto result = resolve_path(path, base, &parent_custody);
if (!result.is_error())
return KResult(-EEXIST);
if (!parent_custody)
Expand All @@ -282,7 +282,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)

KResult VFS::access(StringView path, int mode, Custody& base)
{
auto custody_or_error = resolve_path_to_custody(path, base);
auto custody_or_error = resolve_path(path, base);
if (custody_or_error.is_error())
return custody_or_error.error();
auto& custody = *custody_or_error.value();
Expand All @@ -305,7 +305,7 @@ KResult VFS::access(StringView path, int mode, Custody& base)

KResultOr<Retained<Custody>> VFS::open_directory(StringView path, Custody& base)
{
auto inode_or_error = resolve_path_to_custody(path, base);
auto inode_or_error = resolve_path(path, base);
if (inode_or_error.is_error())
return inode_or_error.error();
auto& custody = *inode_or_error.value();
Expand All @@ -332,7 +332,7 @@ KResult VFS::fchmod(Inode& inode, mode_t mode)

KResult VFS::chmod(StringView path, mode_t mode, Custody& base)
{
auto custody_or_error = resolve_path_to_custody(path, base);
auto custody_or_error = resolve_path(path, base);
if (custody_or_error.is_error())
return custody_or_error.error();
auto& custody = *custody_or_error.value();
Expand All @@ -343,14 +343,14 @@ KResult VFS::chmod(StringView path, mode_t mode, Custody& base)
KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
{
RetainPtr<Custody> old_parent_custody;
auto old_custody_or_error = resolve_path_to_custody(old_path, base, &old_parent_custody);
auto old_custody_or_error = resolve_path(old_path, base, &old_parent_custody);
if (old_custody_or_error.is_error())
return old_custody_or_error.error();
auto& old_custody = *old_custody_or_error.value();
auto& old_inode = old_custody.inode();

RetainPtr<Custody> new_parent_custody;
auto new_custody_or_error = resolve_path_to_custody(new_path, base, &new_parent_custody);
auto new_custody_or_error = resolve_path(new_path, base, &new_parent_custody);
if (new_custody_or_error.is_error()) {
if (new_custody_or_error.error() != -ENOENT)
return new_custody_or_error.error();
Expand Down Expand Up @@ -404,7 +404,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)

KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
{
auto custody_or_error = resolve_path_to_custody(path, base);
auto custody_or_error = resolve_path(path, base);
if (custody_or_error.is_error())
return custody_or_error.error();
auto& custody = *custody_or_error.value();
Expand Down Expand Up @@ -436,14 +436,14 @@ KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)

KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
{
auto old_custody_or_error = resolve_path_to_custody(old_path, base);
auto old_custody_or_error = resolve_path(old_path, base);
if (old_custody_or_error.is_error())
return old_custody_or_error.error();
auto& old_custody = *old_custody_or_error.value();
auto& old_inode = old_custody.inode();

RetainPtr<Custody> parent_custody;
auto new_custody_or_error = resolve_path_to_custody(new_path, base, &parent_custody);
auto new_custody_or_error = resolve_path(new_path, base, &parent_custody);
if (!new_custody_or_error.is_error())
return KResult(-EEXIST);

Expand All @@ -467,7 +467,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
KResult VFS::unlink(StringView path, Custody& base)
{
RetainPtr<Custody> parent_custody;
auto custody_or_error = resolve_path_to_custody(path, base, &parent_custody);
auto custody_or_error = resolve_path(path, base, &parent_custody);
if (custody_or_error.is_error())
return custody_or_error.error();
auto& custody = *custody_or_error.value();
Expand Down Expand Up @@ -496,7 +496,7 @@ KResult VFS::unlink(StringView path, Custody& base)
KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
{
RetainPtr<Custody> parent_custody;
auto existing_custody_or_error = resolve_path_to_custody(linkpath, base, &parent_custody);
auto existing_custody_or_error = resolve_path(linkpath, base, &parent_custody);
if (!existing_custody_or_error.is_error())
return KResult(-EEXIST);
if (!parent_custody)
Expand All @@ -522,7 +522,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
KResult VFS::rmdir(StringView path, Custody& base)
{
RetainPtr<Custody> parent_custody;
auto custody_or_error = resolve_path_to_custody(path, base, &parent_custody);
auto custody_or_error = resolve_path(path, base, &parent_custody);
if (custody_or_error.is_error())
return KResult(custody_or_error.error());

Expand Down Expand Up @@ -621,7 +621,7 @@ Custody& VFS::root_custody()
return *m_root_custody;
}

KResultOr<Retained<Custody>> VFS::resolve_path_to_custody(StringView path, Custody& base, RetainPtr<Custody>* parent_custody, int options)
KResultOr<Retained<Custody>> VFS::resolve_path(StringView path, Custody& base, RetainPtr<Custody>* parent_custody, int options)
{
if (path.is_empty())
return KResult(-EINVAL);
Expand Down Expand Up @@ -694,7 +694,7 @@ KResultOr<Retained<Custody>> VFS::resolve_path_to_custody(StringView path, Custo
return KResult(-ENOENT);

// FIXME: We should limit the recursion here and return -ELOOP if it goes to deep.
return resolve_path_to_custody(
return resolve_path(
StringView(symlink_contents.pointer(),
symlink_contents.size()),
*current_parent,
Expand Down
2 changes: 1 addition & 1 deletion Kernel/FileSystem/VirtualFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class VFS {
Device* get_device(unsigned major, unsigned minor);

Custody& root_custody();
KResultOr<Retained<Custody>> resolve_path_to_custody(StringView path, Custody& base, RetainPtr<Custody>* parent = nullptr, int options = 0);
KResultOr<Retained<Custody>> resolve_path(StringView path, Custody& base, RetainPtr<Custody>* parent = nullptr, int options = 0);

private:
friend class FileDescriptor;
Expand Down

0 comments on commit 056a7fe

Please sign in to comment.