Page MenuHomeFreeBSD

Fallback to copy if chown/chgrp would land in different filesystems
AbandonedPublic

Authored by cem on Mar 29 2018, 5:05 PM.
Tags
None
Referenced Files
F82101416: D14897.id40886.diff
Thu, Apr 25, 1:12 PM
Unknown Object (File)
Wed, Apr 24, 8:12 AM
Unknown Object (File)
Sun, Apr 7, 9:20 PM
Unknown Object (File)
Mar 19 2024, 2:22 PM
Unknown Object (File)
Dec 20 2023, 5:35 AM
Unknown Object (File)
Nov 5 2023, 6:33 PM
Unknown Object (File)
Oct 4 2023, 5:30 PM
Unknown Object (File)
Apr 25 2023, 9:33 AM

Details

Reviewers
bdrewery
brooks
se
bcr
Group Reviewers
manpages
Summary

Add install hardlink mode, -l c, that falls back to copy on EXDEV.

Add prog/progs target, LINKS_OR_COPIES, which implies this installation mode.
(Just in case it should not totally replace LINKS.)

Use that mode for usr.sbin/chown.

Documentation is provided.

Test Plan

This is wholly untested.

Motivated by https://github.com/freebsd/freebsd/pull/133 .

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15875
Build 15879: arc lint + arc unit

Event Timeline

Out of curiosity, why specifically for chown / chgrp?

Out of curiosity, why specifically for chown / chgrp?

They are the observed weird case of being "links" in different directories — usr/sbin for chown, but usr/bin for chgrp. This causes problems for ZFS users who hyper-partition their installation filesystems (in order to set nosetuid+noexec etc by default, but reeanble it for specific directories like /bin, /sbin, and /usr/[s]bin).

For more detail, see the linked github PR.

I'm not a fan of this or the mixed link support, but this seems like an ok solution to the problem. I'd mostly prefer to burn the extra 10k of disk space and do copy all the time.

I'm not a fan of this or the mixed link support, but this seems like an ok solution to the problem. I'd mostly prefer to burn the extra 10k of disk space and do copy all the time.

Copy all the time sounds totally fine to me as well.

bcr added a subscriber: bcr.

Looks good to me from manpages.

This revision is now accepted and ready to land.Aug 19 2018, 7:06 PM

I don't intend to commit this. I don't think it's necessarily a bad idea, I just don't particularly care about it and don't have time to verify (to my own satisfaction) that it doesn't break anything.

This is perhaps in general a reasonable approach. I think it would be fine for the xinstall change to go in, and for bsd.links.mk to just use this mode instead of -l h. But that said, I do see that both BSD tar and GNU tar do not fallback, they just fail, and prior to switching to install we just used ln -f which would fail

Instead of LINKS_OR_COPIES we could use LINKS_OR_SYMLINKS to try a hard link and if that fails a symbolic link.

I had used SYMLINKS instead of LINKS in chown/Makefile for a long time, but meanwhile have recreated /usr/bin and /usr/sbin on a single file system.

I consider falling back to a sym-link the better approach (compared to a file copy) in case of a failed hard-link.

(Instead of SYMLINKS I'd rather use RSYMLINKS now, BTW.)