svn commit: r244521 - projects/mtree/contrib/install
Brooks Davis
brooks at FreeBSD.org
Thu Dec 20 23:06:48 UTC 2012
Author: brooks
Date: Thu Dec 20 23:06:47 2012
New Revision: 244521
URL: http://svnweb.freebsd.org/changeset/base/244521
Log:
Don't unlink or displace the file just before calling install(). That's
on of the first things it does.
Modified:
projects/mtree/contrib/install/xinstall.c
Modified: projects/mtree/contrib/install/xinstall.c
==============================================================================
--- projects/mtree/contrib/install/xinstall.c Thu Dec 20 23:01:53 2012 (r244520)
+++ projects/mtree/contrib/install/xinstall.c Thu Dec 20 23:06:47 2012 (r244521)
@@ -371,33 +371,16 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- if (!no_target) {
+ if (!no_target && !dolink) {
/* makelink() handles checks for links */
- if (!dolink) {
- if (stat(*argv, &from_sb))
- err(1, "%s: stat", *argv);
- if (!S_ISREG(to_sb.st_mode))
- errx(1, "%s: not a regular file", to_name);
- if (to_sb.st_dev == from_sb.st_dev &&
- to_sb.st_ino == from_sb.st_ino)
- errx(1, "%s and %s are the same file", *argv,
- to_name);
- }
- /*
- * Unlink now... avoid ETXTBSY errors later. Try and turn
- * off the append/immutable bits -- if we fail, go ahead,
- * it might work.
- */
-#if ! HAVE_NBTOOL_CONFIG_H
-#define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)
- if (to_sb.st_flags & NOCHANGEBITS)
- (void)chflags(to_name,
- to_sb.st_flags & ~(NOCHANGEBITS));
-#endif
- if (dobackup)
- backup(to_name);
- else if (!dorename)
- (void)unlink(to_name);
+ if (stat(*argv, &from_sb))
+ err(1, "%s: stat", *argv);
+ if (!S_ISREG(to_sb.st_mode))
+ errx(1, "%s: not a regular file", to_name);
+ if (to_sb.st_dev == from_sb.st_dev &&
+ to_sb.st_ino == from_sb.st_ino)
+ errx(1, "%s and %s are the same file", *argv,
+ to_name);
}
install(*argv, to_name, iflags);
exit(0);
@@ -676,6 +659,7 @@ install(char *from_name, char *to_name,
* it might work.
*/
#if ! HAVE_NBTOOL_CONFIG_H
+#define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)
if (stat(to_name, &to_sb) == 0 &&
to_sb.st_flags & (NOCHANGEBITS))
(void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
More information about the svn-src-projects
mailing list