summaryrefslogtreecommitdiff
path: root/archivers/afio/patches/patch-ac
blob: 51196a4ba15c3409362b8c087586bdb6721d02f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
$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);
 }