Hi,
currently chown always seems to do a chown syscall, even if the requested
user:group pair is identical to the file's user:group pair. This is especially
the case when doing a recursive run.
While this might be faster than checking whether the syscall is needed in some
cases and there might be use cases where the syscall should always be done,
there are certainly use cases to avoid the syscalls when unnecessary (see e.g.
https://github.com/sharkdp/fd/issues/1087 or https://askubuntu.com/q/1151431).
This check can be implemented in a wrapper around chown, but reinventing the
wheel in each wrapper does not seem to be the optimum solution besides making
simple "chown -R" calls more complicated than necessary.
Therefore, I propose to add an option to chown which only does the chown
syscall if the user and/or the group will change.
This would avoid ctime changes for files where the metadata really is unchanged
and would reduce writes on storage where writes are more expensive than reads.