From 5e87b789358e32e9b41851c2d18fbfed372c3c44 Mon Sep 17 00:00:00 2001 From: Undefine Date: Thu, 18 Jan 2024 15:56:16 +0100 Subject: [PATCH] LibFileSystem: Ignore ENOTSUP when using chown and chmod during copy With FAT write support copying the file would show two errors because it does not support chown and chmod and would return ENOTSUP. After this commit these errors are ignored in that case. --- Userland/Libraries/LibFileSystem/FileSystem.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index 43a96586e01..da8bdd25533 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -223,10 +223,14 @@ ErrorOr copy_file(StringView destination_path, StringView source_path, str if (!has_flag(preserve_mode, PreserveMode::Permissions)) my_umask |= 06000; - TRY(Core::System::fchmod(destination->fd(), source_stat.st_mode & ~my_umask)); + if (auto result = Core::System::fchmod(destination->fd(), source_stat.st_mode & ~my_umask); result.is_error()) + if (result.error().is_errno() && result.error().code() != ENOTSUP) + return result.release_error(); if (has_flag(preserve_mode, PreserveMode::Ownership)) - TRY(Core::System::fchown(destination->fd(), source_stat.st_uid, source_stat.st_gid)); + if (auto result = Core::System::fchown(destination->fd(), source_stat.st_uid, source_stat.st_gid); result.is_error()) + if (result.error().is_errno() && result.error().code() != ENOTSUP) + return result.release_error(); if (has_flag(preserve_mode, PreserveMode::Timestamps)) { struct timespec times[2] = {