[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
chown: option to avoid unnecessary writes
From: |
Patrick Häcker |
Subject: |
chown: option to avoid unnecessary writes |
Date: |
Sun, 29 Sep 2024 07:48:38 +0200 |
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.
Kind regards
Patrick
signature.asc
Description: This is a digitally signed message part.
- chown: option to avoid unnecessary writes,
Patrick Häcker <=