diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-02 00:11:08 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-02 00:11:27 +0100 |
commit | 37f6844c6c4702d3244ee4a26eb988fb8dd5a951 (patch) | |
tree | 3b55ba7b5eb3c79a6a6fd6cfb1bd9ea653a70164 /Kernel/FileDescriptor.cpp | |
parent | f75eb9af16b7bb58fa2d862ab550e79a2849929c (diff) | |
download | serenity-37f6844c6c4702d3244ee4a26eb988fb8dd5a951.zip |
Kernel: Port stat() to KResult/KResultOr<T>.
Diffstat (limited to 'Kernel/FileDescriptor.cpp')
-rw-r--r-- | Kernel/FileDescriptor.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Kernel/FileDescriptor.cpp b/Kernel/FileDescriptor.cpp index 461e0d9828..ea680ee909 100644 --- a/Kernel/FileDescriptor.cpp +++ b/Kernel/FileDescriptor.cpp @@ -112,30 +112,30 @@ bool addition_would_overflow(off_t a, off_t b) return (ua + b) > maxFileOffset; } -int FileDescriptor::fstat(stat* buffer) +KResult FileDescriptor::fstat(stat& buffer) { ASSERT(!is_fifo()); if (!m_inode && !m_device) - return -EBADF; + return KResult(-EBADF); auto metadata = this->metadata(); if (!metadata.is_valid()) - return -EIO; - - buffer->st_rdev = encoded_device(metadata.major_device, metadata.minor_device); - buffer->st_ino = metadata.inode.index(); - buffer->st_mode = metadata.mode; - buffer->st_nlink = metadata.link_count; - buffer->st_uid = metadata.uid; - buffer->st_gid = metadata.gid; - buffer->st_dev = 0; // FIXME - buffer->st_size = metadata.size; - buffer->st_blksize = metadata.block_size; - buffer->st_blocks = metadata.block_count; - buffer->st_atime = metadata.atime; - buffer->st_mtime = metadata.mtime; - buffer->st_ctime = metadata.ctime; - return 0; + return KResult(-EIO); + + buffer.st_rdev = encoded_device(metadata.major_device, metadata.minor_device); + buffer.st_ino = metadata.inode.index(); + buffer.st_mode = metadata.mode; + buffer.st_nlink = metadata.link_count; + buffer.st_uid = metadata.uid; + buffer.st_gid = metadata.gid; + buffer.st_dev = 0; // FIXME + buffer.st_size = metadata.size; + buffer.st_blksize = metadata.block_size; + buffer.st_blocks = metadata.block_count; + buffer.st_atime = metadata.atime; + buffer.st_mtime = metadata.mtime; + buffer.st_ctime = metadata.ctime; + return KSuccess; } KResult FileDescriptor::fchmod(mode_t mode) |