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.
This commit is contained in:
Undefine 2024-01-18 15:56:16 +01:00 committed by Tim Schumacher
commit 5e87b78935
Notes: sideshowbarker 2024-07-16 23:38:54 +09:00

View file

@ -223,10 +223,14 @@ ErrorOr<void> 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] = {