Page MenuHomeFreeBSD

Enhance install(1) -C's handling of hardlinked files
Needs ReviewPublic

Authored by sigsys_gmail.com on Sep 10 2018, 4:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 21, 7:31 AM
Unknown Object (File)
Mon, Oct 21, 6:57 AM
Unknown Object (File)
Mon, Oct 21, 6:56 AM
Unknown Object (File)
Oct 3 2024, 11:34 AM
Unknown Object (File)
Sep 22 2024, 11:14 AM
Unknown Object (File)
Sep 20 2024, 12:27 PM
Unknown Object (File)
Sep 15 2024, 11:15 PM
Unknown Object (File)
Sep 7 2024, 3:04 PM
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Using install -C to installworld (e.g. with "INSTALL+=-C" in src.conf(5)) avoids copying files that have not changed. Which is useful to save some space if you have filesystem snapshots.

But I noticed that it still copies some files that have not changed if they have hardlinks. That's because it doesn't want to cause unintended side-effects if it has to change the file's attributes. So it "snaps" the hardlinks by instaling a new copy of the file, thus leaving the existing file (and its remaining links) unaffected. But it is doing this in all cases, even if the attributes do not have to be changed.

This diff makes it check that beforehand. It only snaps the hardlink if it's going to try to change the file's attributes later on.

Also, this hardlink snapping logic was only being applied when stripping is to be done (-s flag).

echo test > f
install -C f t
ln t l
install -C -m 0 f t

  1. "l" now has mode 0

I believe that this is unintended. This diff makes it snap the hardlink in this case too.

Also, the logic dealing with installing "/dev/null" as a source file seems a bit off WRT file flags.

install -f uappnd /dev/null t

  1. "t" does not have uappnd flag

So this diff fixes this too.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped