mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-08 03:44:13 -04:00
238 lines
6.4 KiB
Plaintext
238 lines
6.4 KiB
Plaintext
$NetBSD: patch-ac,v 1.2 2012/06/23 18:02:15 dholland Exp $
|
|
|
|
- Use standard headers.
|
|
- Use strerror, not sys_errlist and sys_nerr.
|
|
- Use POSIX utime() interface, not half-baked version.
|
|
- Use W* macros from sys/wait.h instead of hard-coding the historic
|
|
bit patterns.
|
|
- Build fix for makedev() on Solaris and Interix.
|
|
- Fix bad calls to execlp() that break on 64-bit platforms.
|
|
|
|
--- afio.c.orig 2003-12-20 22:16:13.000000000 +0000
|
|
+++ afio.c
|
|
@@ -166,52 +166,40 @@ static char *ident = "$Header: /u/buhrt/
|
|
#include <signal.h>
|
|
#include <strings.h>
|
|
#include <sys/wait.h>
|
|
-#define linux_tstamp 1
|
|
-/* fix SunOS errno.h not declaring what the manpage says it declares
|
|
- bogosity. */
|
|
- extern int sys_nerr;
|
|
- extern char *sys_errlist[];
|
|
-#endif
|
|
-
|
|
-#ifdef hpux
|
|
- /* Fix that HPUX dosent have sys_nerr or sys_errlist
|
|
- Added by Daniel Andersson, daniel.andersson@sto.sema.se
|
|
- */
|
|
-extern int sys_nerr;
|
|
-extern char *sys_errlist[];
|
|
#endif
|
|
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
-#include <sys/signal.h>
|
|
+#include <signal.h>
|
|
#include <sys/types.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/stat.h>
|
|
+#include <sys/wait.h>
|
|
#include <pwd.h>
|
|
#include <grp.h>
|
|
+#include <utime.h>
|
|
#include "patchlevel.h"
|
|
|
|
#ifdef linux
|
|
-
|
|
-#define linux_tstamp 1
|
|
-
|
|
-#include <utime.h>
|
|
-#include <sys/wait.h>
|
|
-
|
|
/* for flushing floppy cache */
|
|
#include <linux/fd.h>
|
|
#endif
|
|
|
|
/* compatibility fixes for IRIX native c compiler. */
|
|
#ifdef irix_cc_compatibility
|
|
-#define linux_tstamp 1
|
|
#include <strings.h>
|
|
#endif
|
|
|
|
+/* nothing should need this */
|
|
+/*#define broken_utime*/
|
|
+
|
|
#ifndef major
|
|
-#ifdef sun
|
|
+#if defined(sun) || defined(__INTERIX)
|
|
#include <sys/mkdev.h>
|
|
+# if !defined(makedev) && defined(mkdev)
|
|
+# define makedev(a,b) mkdev((a),(b))
|
|
+# endif
|
|
#else
|
|
#include <sys/sysmacros.h>
|
|
#endif
|
|
@@ -1122,7 +1110,7 @@ savedirstamp (char *name, time_t mtime)
|
|
STATIC void
|
|
restoredirstamps (void)
|
|
{
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
auto struct utimbuf tstamp;
|
|
#else
|
|
auto time_t tstamp[2];
|
|
@@ -1130,7 +1118,7 @@ restoredirstamps (void)
|
|
Dir *DirP_forw;
|
|
while(DirP!=NULL)
|
|
{
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
tstamp.actime = DirP->d_mtime;
|
|
tstamp.modtime = DirP->d_mtime;
|
|
/* no error code checking on purpose */
|
|
@@ -1212,7 +1200,7 @@ readcheck (av)
|
|
auto char name[PATHSIZE];
|
|
auto char local[PATHSIZE];
|
|
int sel, res;
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
auto struct utimbuf tstamp;
|
|
#else
|
|
auto time_t tstamp[2];
|
|
@@ -1241,7 +1229,7 @@ readcheck (av)
|
|
if(aflag && atime_sb_valid && ((sb.sb_mode & S_IFMT)==S_IFREG))
|
|
{
|
|
/* reset access time, this distroys the ctime btw. */
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
tstamp.actime = atime_sb.sb_atime;
|
|
tstamp.modtime = atime_sb.sb_mtime;
|
|
VOID utime (name, &tstamp);
|
|
@@ -1585,7 +1573,7 @@ incheckdata (int fd, off_t size, char *n
|
|
if(compressargs)
|
|
execvp (compressprog, compress_arg_list);
|
|
else
|
|
- execlp (compressprog, compressprog, "-d", "-c", 0);
|
|
+ execlp (compressprog, compressprog, "-d", "-c", (char *)NULL);
|
|
fprintf (stderr, "Could not uncompress, errno %d\n", errno);
|
|
exit(1);
|
|
break;
|
|
@@ -1696,7 +1684,7 @@ inentry (name, asb)
|
|
reg Link *linkp;
|
|
reg int ifd;
|
|
reg int ofd;
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
auto struct utimbuf tstamp;
|
|
#else
|
|
auto time_t tstamp[2];
|
|
@@ -1729,7 +1717,7 @@ inentry (name, asb)
|
|
/* Cannot set utime on symlink (at least not under Linux) */
|
|
if((asb->sb_mode & S_IFMT) != S_IFLNK)
|
|
{
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
tstamp.actime = tstamp.modtime = mflag ? timenow : asb->sb_mtime;
|
|
VOID utime (name, &tstamp);
|
|
#else
|
|
@@ -3004,7 +2992,7 @@ opencontrolscript (char *name)
|
|
VOID dup (pfd[0]);
|
|
VOID close (pfd[0]);
|
|
|
|
- execlp (controlscript, controlscript, label, 0);
|
|
+ execlp (controlscript, controlscript, label, (char *)NULL);
|
|
|
|
warnarch("Problems running control script:",(off_t)0);
|
|
warn(controlscript,syserr());
|
|
@@ -3266,7 +3254,7 @@ openotty (name, asb, linkp, ispass, dozf
|
|
if(compressargs)
|
|
execvp (compressprog, compress_arg_list);
|
|
else
|
|
- execlp (compressprog, compressprog, "-d", "-c", 0);
|
|
+ execlp (compressprog, compressprog, "-d", "-c", (char *)NULL);
|
|
fprintf (stderr, "Could not uncompress, errno %d\n", errno);
|
|
exit (1);
|
|
}
|
|
@@ -3493,7 +3481,7 @@ out (av)
|
|
auto char name[PATHSIZE];
|
|
auto char fsname[PATHSIZE];
|
|
auto int compression;
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
auto struct utimbuf tstamp;
|
|
#else
|
|
auto time_t tstamp[2];
|
|
@@ -3638,7 +3626,7 @@ out (av)
|
|
if(aflag && *fsname && ((sb.sb_mode & S_IFMT)==S_IFREG))
|
|
{
|
|
/* reset access time, this distroys the ctime btw. */
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
tstamp.actime = sb.sb_atime;
|
|
tstamp.modtime = sb.sb_mtime;
|
|
VOID utime (fsname, &tstamp);
|
|
@@ -4133,7 +4121,7 @@ passitem (from, asb, ifd, dir)
|
|
{
|
|
reg int ofd;
|
|
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
auto struct utimbuf tstamp;
|
|
#else
|
|
auto time_t tstamp[2];
|
|
@@ -4149,7 +4137,7 @@ passitem (from, asb, ifd, dir)
|
|
continue;
|
|
if (ofd > 0)
|
|
passdata (from, ifd, to, ofd);
|
|
-#ifdef linux_tstamp
|
|
+#ifndef broken_utime
|
|
tstamp.actime = tstamp.modtime = mflag ? timenow : asb->sb_mtime;
|
|
VOID utime (to, &tstamp);
|
|
#else
|
|
@@ -4354,12 +4342,7 @@ fswrite (fd, buf, len)
|
|
STATIC char *
|
|
syserr ()
|
|
{
|
|
- static char msg[40];
|
|
-
|
|
- if (errno > 0 && errno < sys_nerr)
|
|
- return ((char *) sys_errlist[errno]);
|
|
- VOID sprintf (msg, "Unknown error (errno %d)", errno);
|
|
- return (msg);
|
|
+ return strerror(errno);
|
|
}
|
|
|
|
/*
|
|
@@ -4765,7 +4748,7 @@ xwait (pid, what, compstat2)
|
|
char *what;
|
|
int compstat2;
|
|
{
|
|
- reg int status;
|
|
+ int status;
|
|
reg Child *cp;
|
|
reg Child **acp;
|
|
auto char why[100];
|
|
@@ -4782,16 +4765,16 @@ xwait (pid, what, compstat2)
|
|
free ((char *) cp);
|
|
if (status == 0)
|
|
return (0);
|
|
- if (status & 0377)
|
|
+ if (WIFSIGNALED(status))
|
|
VOID sprintf (why, "Killed by signal %d%s",
|
|
- status & 0177, status & 0200 ? " -- core dumped" : "");
|
|
+ WTERMSIG(status), WCOREDUMP(status) ? " -- core dumped" : "");
|
|
else
|
|
- VOID sprintf (why, "Exit %d", (status >> 8) & 0377);
|
|
+ VOID sprintf (why, "Exit %d", WEXITSTATUS(status));
|
|
|
|
- if ((!compstat2 && (((status >> 8) & 0377) != 2)) || compstat2)
|
|
+ if ((!compstat2 && (WEXITSTATUS(status) != 2)) || compstat2)
|
|
return (warn (what, why));
|
|
else
|
|
- return ((status >> 8) & 0377);
|
|
+ return WEXITSTATUS(status);
|
|
}
|
|
|
|
|