git: 3e7e3b5bdf90 - main - cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Dec 2023 20:38:42 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3e7e3b5bdf902a375decc11b95179fd2fbc0da2a commit 3e7e3b5bdf902a375decc11b95179fd2fbc0da2a Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-12-07 19:32:30 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-12-07 20:36:44 +0000 cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0 From NetBSD's utils.c 1.5 importing importing BSDI change, with light formatting changes: Author: cgd <cgd@NetBSD.org> Date: Wed Feb 26 14:40:51 1997 +0000 Patch from BSDI (via Keith Bostic): >NFS doesn't support chflags; ignore errors unless there's reason >to believe we're losing bits. (Note, this still won't be right >if the server supports flags and we were trying to *remove* flags >on a file that we copied, i.e., that we didn't create.) CVS Info: utils.c 1.6 Obtained from: NetBSD Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42674 --- bin/cp/utils.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 686db13ef0cf..3621c89dd2f2 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -354,8 +354,17 @@ setfile(struct stat *fs, int fd) fchflags(fd, fs->st_flags) : (islink ? lchflags(to.p_path, fs->st_flags) : chflags(to.p_path, fs->st_flags))) { - warn("chflags: %s", to.p_path); - rval = 1; + /* + * NFS doesn't support chflags; ignore errors unless + * there's reason to believe we're losing bits. (Note, + * this still won't be right if the server supports + * flags and we were trying to *remove* flags on a file + * that we copied, i.e., that we didn't create.) + */ + if (errno != EOPNOTSUPP || fs->st_flags != 0) { + warn("chflags: %s", to.p_path); + rval = 1; + } } return (rval);