1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 23:14:59 +00:00

Kernel: Make Inode::set_{a,c,m}time return KResult

This exposed some missing error propagation, which this patch also
takes care of.
This commit is contained in:
Andreas Kling 2021-04-30 15:51:06 +02:00
parent a5f385f052
commit cd9be1733c
8 changed files with 42 additions and 44 deletions

View file

@ -209,12 +209,10 @@ KResult VFS::utime(StringView path, Custody& base, time_t atime, time_t mtime)
if (custody.is_readonly())
return EROFS;
int error = inode.set_atime(atime);
if (error < 0)
return KResult((ErrnoCode)-error);
error = inode.set_mtime(mtime);
if (error < 0)
return KResult((ErrnoCode)-error);
if (auto result = inode.set_atime(atime); result.is_error())
return result;
if (auto result = inode.set_mtime(mtime); result.is_error())
return result;
return KSuccess;
}
@ -319,10 +317,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
return EROFS;
if (should_truncate_file) {
KResult result = inode.truncate(0);
if (result.is_error())
if (auto result = inode.truncate(0); result.is_error())
return result;
if (auto result = inode.set_mtime(kgettimeofday().to_truncated_seconds()); result.is_error())
return result;
inode.set_mtime(kgettimeofday().to_truncated_seconds());
}
auto description = FileDescription::create(custody);
if (!description.is_error()) {