* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static const char copyright[] =
+__used static const char copyright[] =
"@(#) Copyright (c) 1987, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#if 0
static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#endif
-static const char rcsid[] =
+__used static const char rcsid[] =
"$FreeBSD: src/usr.bin/xinstall/xinstall.c,v 1.43 2001/05/30 07:08:49 ru Exp $";
#endif /* not lint */
#include <unistd.h>
#include <sysexits.h>
#include <utime.h>
+#include <spawn.h>
#ifdef __APPLE__
+#include <TargetConditionals.h>
#include <copyfile.h>
#endif /* __APPLE__ */
{
struct stat from_sb, to_sb;
mode_t *set;
- u_long fset;
+ u_long fset = 0;
int ch, no_target;
u_int iflags;
char *flags, *group, *owner, *to_name;
if (!devnull)
(void)close(from_fd);
}
-
+#if TARGET_OS_EMBEDDED
+#define BUFFER_SIZE 128*1024
+#else /* !TARGET_OS_EMBEDDED */
+#define BUFFER_SIZE MAXBSIZE
+#endif /* TARGET_OS_EMBEDDED */
/*
* compare --
* compare two files; non-zero means files differ
}
out:
if (!done_compare) {
- char buf1[MAXBSIZE];
- char buf2[MAXBSIZE];
+ char buf1[BUFFER_SIZE];
+ char buf2[BUFFER_SIZE];
int n1, n2;
rv = 0;
{
register int nr, nw;
int serrno;
- char *p, buf[MAXBSIZE];
+ char *p, buf[BUFFER_SIZE];
int done_copy;
/* Rewind file descriptors. */
strip(to_name)
char *to_name;
{
- int serrno, status;
-
- switch (fork()) {
- case -1:
- serrno = errno;
- (void)unlink(to_name);
- errno = serrno;
- err(EX_TEMPFAIL, "fork");
- case 0:
- execlp("strip", "strip", to_name, NULL);
- err(EX_OSERR, "exec(strip)");
- default:
- if (wait(&status) == -1 || status) {
- (void)unlink(to_name);
- exit(EX_SOFTWARE);
- /* NOTREACHED */
+ pid_t pid;
+ int error;
+ extern char** environ;
+ char *const argv[] = { "xcrun", "strip", "-", to_name, NULL };
+
+ if (0 == (error = posix_spawnp(&pid, "xcrun", NULL, NULL, argv, environ))) {
+ int status = 0;
+ pid_t child = waitpid(pid, &status, 0);
+ if ((child == -1) || status) {
+ unlink(to_name);
+ errx(EX_SOFTWARE, "child process failed: xcrun strip - %s", to_name);
}
+ } else {
+ errno = error;
+ err(EX_OSERR, "xcrun strip - %s", to_name);
}
}