summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-01 15:36:45 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-01 15:36:45 +0100
commitfeed67ede2c7f41328625f58d1b92b5d2fce0c5d (patch)
tree33fcbc1df150ef9fdffd2b4344b5e65fb70cf8ad /Kernel
parent6618411fbacfe0169a569a695f29819e4153e5a4 (diff)
downloadserenity-feed67ede2c7f41328625f58d1b92b5d2fce0c5d.zip
Kernel: VFS::open/create should take base Inode& instead of InodeIdentifier.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/KSyms.cpp2
-rw-r--r--Kernel/Process.cpp14
-rw-r--r--Kernel/VirtualFileSystem.cpp8
-rw-r--r--Kernel/VirtualFileSystem.h4
4 files changed, 14 insertions, 14 deletions
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 7715b06af3..0e49a6c094 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -122,7 +122,7 @@ void init_ksyms()
void load_ksyms()
{
int error;
- auto descriptor = VFS::the().open("/kernel.map", error, 0, 0);
+ auto descriptor = VFS::the().open("/kernel.map", error, 0, 0, *VFS::the().root_inode());
if (!descriptor) {
kprintf("Failed to open /kernel.map\n");
} else {
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index f0898e531f..652f1a9d80 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -292,7 +292,7 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
return -ENOENT;
int error;
- auto descriptor = VFS::the().open(path, error, 0, 0, m_cwd ? m_cwd->identifier() : InodeIdentifier());
+ auto descriptor = VFS::the().open(path, error, 0, 0, *cwd_inode());
if (!descriptor) {
ASSERT(error != 0);
return error;
@@ -1126,7 +1126,7 @@ int Process::sys$utime(const char* pathname, const utimbuf* buf)
return -EFAULT;
String path(pathname);
int error;
- auto descriptor = VFS::the().open(move(path), error, 0, 0, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(move(path), error, 0, 0, *cwd_inode());
if (!descriptor)
return error;
auto& inode = *descriptor->inode();
@@ -1215,7 +1215,7 @@ int Process::sys$lstat(const char* path, stat* statbuf)
if (!validate_write_typed(statbuf))
return -EFAULT;
int error;
- auto descriptor = VFS::the().open(move(path), error, O_NOFOLLOW_NOERROR | O_DONT_OPEN_DEVICE, 0, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(move(path), error, O_NOFOLLOW_NOERROR | O_DONT_OPEN_DEVICE, 0, *cwd_inode());
if (!descriptor)
return error;
descriptor->fstat(statbuf);
@@ -1227,7 +1227,7 @@ int Process::sys$stat(const char* path, stat* statbuf)
if (!validate_write_typed(statbuf))
return -EFAULT;
int error;
- auto descriptor = VFS::the().open(move(path), error, O_DONT_OPEN_DEVICE, 0, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(move(path), error, O_DONT_OPEN_DEVICE, 0, *cwd_inode());
if (!descriptor)
return error;
descriptor->fstat(statbuf);
@@ -1242,7 +1242,7 @@ int Process::sys$readlink(const char* path, char* buffer, size_t size)
return -EFAULT;
int error;
- auto descriptor = VFS::the().open(path, error, O_RDONLY | O_NOFOLLOW_NOERROR, 0, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(path, error, O_RDONLY | O_NOFOLLOW_NOERROR, 0, *cwd_inode());
if (!descriptor)
return error;
@@ -1264,7 +1264,7 @@ int Process::sys$chdir(const char* path)
if (!validate_read_str(path))
return -EFAULT;
int error;
- auto descriptor = VFS::the().open(path, error, 0, 0, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(path, error, 0, 0, *cwd_inode());
if (!descriptor)
return error;
if (!descriptor->is_directory())
@@ -1308,7 +1308,7 @@ int Process::sys$open(const char* path, int options, mode_t mode)
return -EMFILE;
int error = -EWHYTHO;
ASSERT(cwd_inode());
- auto descriptor = VFS::the().open(path, error, options, mode, cwd_inode()->identifier());
+ auto descriptor = VFS::the().open(path, error, options, mode, *cwd_inode());
if (!descriptor)
return error;
if (options & O_DIRECTORY && !descriptor->is_directory())
diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp
index 4d78912665..15cc406394 100644
--- a/Kernel/VirtualFileSystem.cpp
+++ b/Kernel/VirtualFileSystem.cpp
@@ -136,9 +136,9 @@ RetainPtr<FileDescriptor> VFS::open(RetainPtr<CharacterDevice>&& device, int& er
return FileDescriptor::create(move(device));
}
-RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options, mode_t mode, InodeIdentifier base)
+RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options, mode_t mode, Inode& base)
{
- auto inode_id = resolve_path(path, base, error, options);
+ auto inode_id = resolve_path(path, base.identifier(), error, options);
auto inode = get_inode(inode_id);
if (!inode) {
if (options & O_CREAT)
@@ -159,7 +159,7 @@ RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options,
return FileDescriptor::create(move(inode));
}
-RetainPtr<FileDescriptor> VFS::create(const String& path, int& error, int options, mode_t mode, InodeIdentifier base)
+RetainPtr<FileDescriptor> VFS::create(const String& path, int& error, int options, mode_t mode, Inode& base)
{
(void) options;
error = -EWHYTHO;
@@ -177,7 +177,7 @@ RetainPtr<FileDescriptor> VFS::create(const String& path, int& error, int option
}
InodeIdentifier parent_dir;
- auto existing_file = resolve_path(path, base, error, 0, &parent_dir);
+ auto existing_file = resolve_path(path, base.identifier(), error, 0, &parent_dir);
if (existing_file.is_valid()) {
error = -EEXIST;
return nullptr;
diff --git a/Kernel/VirtualFileSystem.h b/Kernel/VirtualFileSystem.h
index 0ef4995857..758ce13028 100644
--- a/Kernel/VirtualFileSystem.h
+++ b/Kernel/VirtualFileSystem.h
@@ -65,8 +65,8 @@ public:
bool mount(RetainPtr<FS>&&, const String& path);
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);
+ RetainPtr<FileDescriptor> open(const String& path, int& error, int options, mode_t mode, Inode& base);
+ RetainPtr<FileDescriptor> create(const String& path, int& error, int options, mode_t mode, Inode& base);
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);