Subject: bin/3288: install: fchflags EOPNOTSUPP should be nonfatal.
To: None <gnats-bugs@gnats.netbsd.org>
From: Brian C. Grayson <bgrayson@data.ece.utexas.edu>
List: netbsd-bugs
Date: 03/04/1997 17:40:39
>Number:         3288
>Category:       bin
>Synopsis:       fchflags not supported on NFS --> fatal error in install.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar  4 15:50:01 1997
>Last-Modified:
>Originator:     Brian Grayson
>Organization:
	Parallel and Distributed Systems
	Electrical and Computer Engineering
	The University of Texas at Austin
>Release:        Early March, 1997
>Environment:
System:NetBSD marvin 1.2C NetBSD 1.2C (MARVIN) #18: Tue Mar  4 10:01:21 CST 1997
bgrayson@marvin:/a/orac/home/orac/src/sys/arch/i386/compile/MARVIN i386


>Description:
	fchflags() attempts on an NFS-mounted directory fail with
	EOPNOTSUPP (this is a relatively recent change, IIRC).
	The source code for install attempts an fchflags() call,
	and then considers _any_ error code to be a complete
	failure, leading to the install failing.  For people
	with, say, /usr/share mounted via NFS, this prevents
	'make build' and even 'make install' from working
	properly from /usr/src.

	Although NFS and other file systems do not support the
	chflags() family of operations, an 'install' on them
	most likely should cause a warning and not a fatal error.

>How-To-Repeat:
	mount /usr/share via NFS.
	(cd /usr/src/share && make install)

	Watch as man pages get removed (install unlinks them in
	preparation to installing the new ones, but then unlinks
	the new ones and dies after the failed fchflags() call).
	After such an action, even send-pr won't work, since it
	requires a file in /usr/share/gnats.

>Fix:
	Someone in the know might want to figure out what the
	best course of action is.  A good fix might be to look
	at the error, and warn if it is nonfatal or die if it
	really is fatal (such as EPERM, although install
	probably would have died earlier in that case).  As a
	temporary fix, I simply removed the unlink() and
	changed errx to warnx, via the following patch, for
	/usr/src/usr.bin/xinstall.  The setting of serrno can
	probably be removed, if this is committed, provided the
	strerror() call uses errno instead!  :)
--- xinstall.c.dist	Tue Mar  4 13:10:38 1997
+++ xinstall.c	Tue Mar  4 16:20:40 1997
@@ -273,18 +273,17 @@
 
 	/*
 	 * If provided a set of flags, set them, otherwise, preserve the
 	 * flags, except for the dump flag.
 	 */
 	if (fchflags(to_fd,
 	    flags & SETFLAGS ? fset : from_sb.st_flags & ~UF_NODUMP)) {
 		serrno = errno;
-		(void)unlink(to_name);
-		errx(1, "%s: chflags: %s", to_name, strerror(serrno));
+		warnx("%s: chflags: %s", to_name, strerror(serrno));
 	}
 
 	(void)close(to_fd);
 	if (!docopy && !devnull && unlink(from_name))
 		err(1, "%s", from_name);
 }
 
 /*
>Audit-Trail:
>Unformatted: