|
@@ -4,7 +4,6 @@
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
*/
|
|
|
|
|
|
-#include <AK/LexicalPath.h>
|
|
|
#include <AK/Singleton.h>
|
|
|
#include <AK/StringBuilder.h>
|
|
|
#include <Kernel/Debug.h>
|
|
@@ -14,6 +13,7 @@
|
|
|
#include <Kernel/FileSystem/FileDescription.h>
|
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
|
|
+#include <Kernel/KLexicalPath.h>
|
|
|
#include <Kernel/KSyms.h>
|
|
|
#include <Kernel/Process.h>
|
|
|
#include <Kernel/Sections.h>
|
|
@@ -353,14 +353,14 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
|
|
if (parent_custody->is_readonly())
|
|
|
return EROFS;
|
|
|
|
|
|
- auto basename = LexicalPath::basename(path);
|
|
|
+ auto basename = KLexicalPath::basename(path);
|
|
|
dbgln("VFS::mknod: '{}' mode={} dev={} in {}", basename, mode, dev, parent_inode.identifier());
|
|
|
return parent_inode.create_child(basename, mode, dev, current_process->euid(), current_process->egid()).result();
|
|
|
}
|
|
|
|
|
|
KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner)
|
|
|
{
|
|
|
- auto basename = LexicalPath::basename(path);
|
|
|
+ auto basename = KLexicalPath::basename(path);
|
|
|
if (auto result = validate_path_against_process_veil(String::formatted("{}/{}", parent_custody.absolute_path(), basename), options); result.is_error())
|
|
|
return result;
|
|
|
|
|
@@ -418,7 +418,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
|
|
|
if (parent_custody->is_readonly())
|
|
|
return EROFS;
|
|
|
|
|
|
- auto basename = LexicalPath::basename(path);
|
|
|
+ auto basename = KLexicalPath::basename(path);
|
|
|
dbgln_if(VFS_DEBUG, "VFS::mkdir: '{}' in {}", basename, parent_inode.identifier());
|
|
|
return parent_inode.create_child(basename, S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result();
|
|
|
}
|
|
@@ -533,7 +533,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
|
|
if (old_parent_custody->is_readonly() || new_parent_custody->is_readonly())
|
|
|
return EROFS;
|
|
|
|
|
|
- auto new_basename = LexicalPath::basename(new_path);
|
|
|
+ auto new_basename = KLexicalPath::basename(new_path);
|
|
|
|
|
|
if (!new_custody_or_error.is_error()) {
|
|
|
auto& new_custody = *new_custody_or_error.value();
|
|
@@ -554,7 +554,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
|
|
if (auto result = new_parent_inode.add_child(old_inode, new_basename, old_inode.mode()); result.is_error())
|
|
|
return result;
|
|
|
|
|
|
- if (auto result = old_parent_inode.remove_child(LexicalPath::basename(old_path)); result.is_error())
|
|
|
+ if (auto result = old_parent_inode.remove_child(KLexicalPath::basename(old_path)); result.is_error())
|
|
|
return result;
|
|
|
|
|
|
return KSuccess;
|
|
@@ -656,7 +656,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
|
|
if (!hard_link_allowed(old_inode))
|
|
|
return EPERM;
|
|
|
|
|
|
- return parent_inode.add_child(old_inode, LexicalPath::basename(new_path), old_inode.mode());
|
|
|
+ return parent_inode.add_child(old_inode, KLexicalPath::basename(new_path), old_inode.mode());
|
|
|
}
|
|
|
|
|
|
KResult VFS::unlink(StringView path, Custody& base)
|
|
@@ -689,7 +689,7 @@ KResult VFS::unlink(StringView path, Custody& base)
|
|
|
if (parent_custody->is_readonly())
|
|
|
return EROFS;
|
|
|
|
|
|
- if (auto result = parent_inode.remove_child(LexicalPath::basename(path)); result.is_error())
|
|
|
+ if (auto result = parent_inode.remove_child(KLexicalPath::basename(path)); result.is_error())
|
|
|
return result;
|
|
|
|
|
|
return KSuccess;
|
|
@@ -712,7 +712,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
|
|
|
if (parent_custody->is_readonly())
|
|
|
return EROFS;
|
|
|
|
|
|
- auto basename = LexicalPath::basename(linkpath);
|
|
|
+ auto basename = KLexicalPath::basename(linkpath);
|
|
|
dbgln_if(VFS_DEBUG, "VFS::symlink: '{}' (-> '{}') in {}", basename, target, parent_inode.identifier());
|
|
|
auto inode_or_error = parent_inode.create_child(basename, S_IFLNK | 0644, 0, current_process->euid(), current_process->egid());
|
|
|
if (inode_or_error.is_error())
|
|
@@ -771,7 +771,7 @@ KResult VFS::rmdir(StringView path, Custody& base)
|
|
|
if (auto result = inode.remove_child(".."); result.is_error())
|
|
|
return result;
|
|
|
|
|
|
- return parent_inode.remove_child(LexicalPath::basename(path));
|
|
|
+ return parent_inode.remove_child(KLexicalPath::basename(path));
|
|
|
}
|
|
|
|
|
|
VFS::Mount::Mount(FS& guest_fs, Custody* host_custody, int flags)
|
|
@@ -833,8 +833,7 @@ UnveilNode const& VFS::find_matching_unveiled_path(StringView path)
|
|
|
VERIFY(Process::current()->veil_state() != VeilState::None);
|
|
|
auto& unveil_root = Process::current()->unveiled_paths();
|
|
|
|
|
|
- LexicalPath lexical_path { path };
|
|
|
- auto& path_parts = lexical_path.parts_view();
|
|
|
+ auto path_parts = KLexicalPath::parts(path);
|
|
|
return unveil_root.traverse_until_last_accessible_node(path_parts.begin(), path_parts.end());
|
|
|
}
|
|
|
|