1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

Kernel: Make File::stat() & friends return Error<struct stat>

Instead of making the caller provide a stat buffer, let's just return
one as a value.
This commit is contained in:
Andreas Kling 2021-12-17 11:22:27 +01:00
parent 1f2d0d0ad4
commit 0ae8702692
10 changed files with 19 additions and 20 deletions

View file

@ -86,10 +86,11 @@ struct InodeMetadata {
bool is_setuid() const { return Kernel::is_setuid(mode); }
bool is_setgid() const { return Kernel::is_setgid(mode); }
ErrorOr<void> stat(stat& buffer) const
ErrorOr<struct stat> stat() const
{
if (!is_valid())
return EIO;
struct stat buffer = {};
buffer.st_rdev = encoded_device(major_device, minor_device);
buffer.st_ino = inode.index().value();
buffer.st_mode = mode;
@ -106,7 +107,7 @@ struct InodeMetadata {
buffer.st_mtim.tv_nsec = 0;
buffer.st_ctim.tv_sec = ctime;
buffer.st_ctim.tv_nsec = 0;
return {};
return buffer;
}
InodeIdentifier inode;