mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
Kernel: Add KResult and KResultOr<T> classes.
The idea here is to combine a potential syscall error code with an arbitrary type in the case of success. I feel like this will end up much less error prone than returning some arbitrary type that kinda sorta has bool semantics (but sometimes not really) and passing the error through an out-param. This patch only converts a few syscalls to using it. More to come.
This commit is contained in:
parent
901b7d5d91
commit
5af4e622b9
12 changed files with 162 additions and 118 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "InodeMetadata.h"
|
||||
#include "Limits.h"
|
||||
#include "FileSystem.h"
|
||||
#include <Kernel/KResult.h>
|
||||
|
||||
#define O_RDONLY 0
|
||||
#define O_WRONLY 1
|
||||
|
@ -64,13 +65,13 @@ public:
|
|||
RetainPtr<FileDescriptor> open(RetainPtr<Device>&&, int& error, int options);
|
||||
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);
|
||||
KResult mkdir(const String& path, mode_t mode, Inode& base);
|
||||
bool link(const String& old_path, const String& new_path, 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);
|
||||
KResult chmod(const String& path, mode_t, Inode& base);
|
||||
bool stat(const String& path, int& error, int options, Inode& base, struct stat&);
|
||||
bool utime(const String& path, int& error, Inode& base, time_t atime, time_t mtime);
|
||||
KResult utime(const String& path, Inode& base, time_t atime, time_t mtime);
|
||||
|
||||
void register_device(Device&);
|
||||
void unregister_device(Device&);
|
||||
|
@ -97,9 +98,11 @@ private:
|
|||
bool is_vfs_root(InodeIdentifier) const;
|
||||
|
||||
void traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntry&)>);
|
||||
InodeIdentifier resolve_path(const String& path, InodeIdentifier base, int& error, int options = 0, InodeIdentifier* parent_id = nullptr);
|
||||
InodeIdentifier old_resolve_path(const String& path, InodeIdentifier base, int& error, int options = 0, InodeIdentifier* parent_id = nullptr);
|
||||
KResultOr<InodeIdentifier> resolve_path(const String& path, InodeIdentifier base, int options = 0, InodeIdentifier* parent_id = nullptr);
|
||||
RetainPtr<Inode> resolve_path_to_inode(const String& path, Inode& base, int& error, RetainPtr<Inode>* parent_id = nullptr);
|
||||
InodeIdentifier resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode, int& error);
|
||||
KResultOr<RetainPtr<Inode>> resolve_path_to_inode(const String& path, Inode& base, RetainPtr<Inode>* parent_id = nullptr);
|
||||
KResultOr<InodeIdentifier> resolve_symbolic_link(InodeIdentifier base, Inode& symlink_inode);
|
||||
|
||||
Mount* find_mount_for_host(InodeIdentifier);
|
||||
Mount* find_mount_for_guest(InodeIdentifier);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue