]> git.pld-linux.org Git - packages/cpio.git/blame - cpio-freebsd.patch
- this way doesn't work any longer
[packages/cpio.git] / cpio-freebsd.patch
CommitLineData
dfcfd1c3
JB
1diff -Nur cpio-2.5.orig/copyin.c cpio-2.5/copyin.c
2--- cpio-2.5.orig/copyin.c Mon Jan 14 00:44:19 2002
3+++ cpio-2.5/copyin.c Sun Sep 1 00:49:09 2002
4@@ -18,6 +18,13 @@
696818ea 5 #include <stdio.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8+#ifdef HAVE_SYS_PARAM_H
9+#include <sys/param.h>
10+#endif
11+#if ((defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__))
12+#define HAVE_STRFTIME
13+#include <ctype.h>
14+#endif
15 #include "filetypes.h"
16 #include "system.h"
17 #include "cpiohdr.h"
dfcfd1c3 18@@ -28,6 +35,9 @@
696818ea 19 #ifndef FNM_PATHNAME
20 #include <fnmatch.h>
21 #endif
22+#if defined(HAVE_STRFTIME)
23+#include <langinfo.h>
24+#endif
25
dfcfd1c3
JB
26 #ifndef HAVE_LCHOWN
27 #define lchown chown
28@@ -1146,13 +1156,23 @@
29 }
30 return;
31 }
32-
33- res = mknod (file_hdr->c_name, file_hdr->c_mode,
34+
696818ea 35+#ifdef CP_IFIFO
dfcfd1c3
JB
36+ if ((file_hdr->c_mode & CP_IFMT) == CP_IFIFO)
37+ res = mkfifo (file_hdr->c_name, file_hdr->c_mode);
38+ else
696818ea 39+#endif
dfcfd1c3
JB
40+ res = mknod (file_hdr->c_name, file_hdr->c_mode,
41 makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min));
42 if (res < 0 && create_dir_flag)
43 {
44 create_all_directories (file_hdr->c_name);
45- res = mknod (file_hdr->c_name, file_hdr->c_mode,
696818ea 46+#ifdef CP_IFIFO
dfcfd1c3
JB
47+ if ((file_hdr->c_mode & CP_IFMT) == CP_IFIFO)
48+ res = mkfifo (file_hdr->c_name, file_hdr->c_mode);
49+ else
696818ea 50+#endif
dfcfd1c3
JB
51+ res = mknod (file_hdr->c_name, file_hdr->c_mode,
52 makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min));
53 }
54 if (res < 0)
55@@ -1238,12 +1258,31 @@
696818ea 56 char mbuf[11];
57 char tbuf[40];
58 time_t when;
59+ char *ptbuf;
60+#ifdef HAVE_STRFTIME
61+ static int d_first = -1;
62+#endif
63
64 mode_string (file_hdr->c_mode, mbuf);
65 mbuf[10] = '\0';
66
67 /* Get time values ready to print. */
68 when = file_hdr->c_mtime;
69+#ifdef HAVE_STRFTIME
70+#ifdef __FreeBSD__
71+ if (d_first < 0)
72+ d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
73+#else
74+ d_first = 0;
75+#endif
76+ if (current_time - when > 6L * 30L * 24L * 60L * 60L
77+ || current_time - when < 0L)
78+ ptbuf = d_first ? "%e %b %Y" : "%b %e %Y";
79+ else
80+ ptbuf = d_first ? "%e %b %R" : "%b %e %R";
81+ strftime(tbuf, sizeof(tbuf), ptbuf, localtime(&when));
82+ ptbuf = tbuf;
83+#else
84 strcpy (tbuf, ctime (&when));
85 if (current_time - when > 6L * 30L * 24L * 60L * 60L
86 || current_time - when < 0L)
dfcfd1c3 87@@ -1253,8 +1292,10 @@
696818ea 88 strcpy (tbuf + 11, tbuf + 19);
89 }
90 tbuf[16] = '\0';
91+ ptbuf = tbuf + 4;
92+#endif
93
94- printf ("%s %3u ", mbuf, file_hdr->c_nlink);
95+ printf ("%s %3lu ", mbuf, file_hdr->c_nlink);
96
97 #ifndef __MSDOS__
98 if (numeric_uid)
dfcfd1c3 99@@ -1268,13 +1309,13 @@
696818ea 100
101 if ((file_hdr->c_mode & CP_IFMT) == CP_IFCHR
102 || (file_hdr->c_mode & CP_IFMT) == CP_IFBLK)
103- printf ("%3u, %3u ", file_hdr->c_rdev_maj,
dfcfd1c3
JB
104+ printf ("%3lu, %3lu ", file_hdr->c_rdev_maj,
105 file_hdr->c_rdev_min);
696818ea 106 else
107 #endif
108 printf ("%8lu ", file_hdr->c_filesize);
109
110- printf ("%s ", tbuf + 4);
111+ printf ("%s ", ptbuf);
112
113 print_name_with_quoting (file_hdr->c_name);
114 if (link_name)
dfcfd1c3 115@@ -1330,6 +1371,9 @@
696818ea 116 break;
117
118 default:
119+#if ((defined(BSD) && BSD >= 199306) || defined(__GLIBC__))
120+ if (isprint(c))
121+#else
122 if (c > 040 &&
123 #ifdef __MSDOS__
124 c < 0377 && c != 0177
dfcfd1c3 125@@ -1337,6 +1381,7 @@
696818ea 126 c < 0177
127 #endif
128 )
129+#endif
130 putchar (c);
131 else
132 printf ("\\%03o", (unsigned int) c);
dfcfd1c3
JB
133diff -Nur cpio-2.5.orig/copyout.c cpio-2.5/copyout.c
134--- cpio-2.5.orig/copyout.c Sun Sep 1 00:43:11 2002
135+++ cpio-2.5/copyout.c Sun Sep 1 00:52:25 2002
136@@ -35,6 +35,7 @@
137 static void writeout_other_defers ();
696818ea 138 static void writeout_final_defers();
139 static void writeout_defered_file ();
696818ea 140+static int check_rdev ();
141
142 /* Write out header FILE_HDR, including the file name, to file
143 descriptor OUT_DES. */
dfcfd1c3 144@@ -296,8 +297,32 @@
696818ea 145 file_hdr.c_uid = file_stat.st_uid;
146 file_hdr.c_gid = file_stat.st_gid;
147 file_hdr.c_nlink = file_stat.st_nlink;
148- file_hdr.c_rdev_maj = major (file_stat.st_rdev);
149- file_hdr.c_rdev_min = minor (file_stat.st_rdev);
150+
151+ /* The rdev is meaningless except for block and character
152+ special files (POSIX standard) and perhaps fifos and
153+ sockets. Clear it for other types of files so that
154+ check_rdev() doesn't reject files just because stat()
155+ put garbage in st_rdev and so that the output doesn't
156+ depend on the garbage. */
157+ switch (file_hdr.c_mode & CP_IFMT)
158+ {
159+ case CP_IFBLK:
160+ case CP_IFCHR:
161+#ifdef CP_IFIFO
162+ case CP_IFIFO:
163+#endif
164+#ifdef CP_IFSOCK
165+ case CP_IFSOCK:
166+#endif
167+ file_hdr.c_rdev_maj = major (file_stat.st_rdev);
168+ file_hdr.c_rdev_min = minor (file_stat.st_rdev);
169+ break;
170+ default:
171+ file_hdr.c_rdev_maj = 0;
172+ file_hdr.c_rdev_min = 0;
173+ break;
174+ }
175+
176 file_hdr.c_mtime = file_stat.st_mtime;
177 file_hdr.c_filesize = file_stat.st_size;
178 file_hdr.c_chksum = 0;
dfcfd1c3 179@@ -341,6 +366,23 @@
696818ea 180 continue;
181 }
182
183+ switch (check_rdev (&file_hdr))
184+ {
185+ case 1:
186+ error (0, 0, "%s not dumped: major number would be truncated",
187+ file_hdr.c_name);
188+ continue;
189+ case 2:
190+ error (0, 0, "%s not dumped: minor number would be truncated",
191+ file_hdr.c_name);
192+ continue;
193+ case 4:
194+ error (0, 0, "%s not dumped: device number would be truncated",
195+ file_hdr.c_name);
196+ continue;
197+ }
198+
199+
200 /* Copy the named file to the output. */
201 switch (file_hdr.c_mode & CP_IFMT)
202 {
dfcfd1c3 203@@ -825,3 +867,98 @@
696818ea 204 return;
205 }
206
207+
208+static int
209+check_rdev (file_hdr)
210+ struct new_cpio_header *file_hdr;
211+{
212+ if (archive_format == arf_newascii || archive_format == arf_crcascii)
213+ {
214+ if ((file_hdr->c_rdev_maj & 0xFFFFFFFF) != file_hdr->c_rdev_maj)
215+ return 1;
216+ if ((file_hdr->c_rdev_min & 0xFFFFFFFF) != file_hdr->c_rdev_min)
217+ return 2;
218+ }
219+ else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
220+ {
221+#ifndef __MSDOS__
222+ dev_t rdev;
223+
224+ rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
225+ if (archive_format == arf_oldascii)
226+ {
227+ if ((rdev & 0xFFFF) != rdev)
228+ return 4;
229+ }
230+ else
231+ {
232+ switch (file_hdr->c_mode & CP_IFMT)
233+ {
234+ case CP_IFCHR:
235+ case CP_IFBLK:
236+#ifdef CP_IFSOCK
237+ case CP_IFSOCK:
238+#endif
239+#ifdef CP_IFIFO
240+ case CP_IFIFO:
241+#endif
242+ /* We could handle one more bit if longs are >= 33 bits. */
243+ if ((rdev & 037777777777) != rdev)
244+ return 4;
245+ break;
246+ default:
247+ if ((rdev & 0xFFFF) != rdev)
248+ return 4;
249+ break;
250+ }
251+ }
252+#endif
253+ }
254+ else if (archive_format == arf_tar || archive_format == arf_ustar)
255+ {
256+ /* The major and minor formats are limited to 7 octal digits in ustar
257+ format, and to_oct () adds a gratuitous trailing blank to further
258+ limit the format to 6 octal digits. */
259+ if ((file_hdr->c_rdev_maj & 0777777) != file_hdr->c_rdev_maj)
260+ return 1;
261+ if ((file_hdr->c_rdev_min & 0777777) != file_hdr->c_rdev_min)
262+ return 2;
263+ }
264+ else
265+ {
266+#ifndef __MSDOS__
267+ dev_t rdev;
268+
269+ rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
270+ if (archive_format != arf_hpbinary)
271+ {
272+ if ((rdev & 0xFFFF) != rdev)
273+ return 4;
274+ }
275+ else
276+ {
277+ switch (file_hdr->c_mode & CP_IFMT)
278+ {
279+ case CP_IFCHR:
280+ case CP_IFBLK:
281+#ifdef CP_IFSOCK
282+ case CP_IFSOCK:
283+#endif
284+#ifdef CP_IFIFO
285+ case CP_IFIFO:
286+#endif
287+ if ((rdev & 0xFFFFFFFF) != rdev)
288+ return 4;
289+ file_hdr->c_filesize = rdev;
290+ rdev = makedev (0, 1);
291+ break;
292+ default:
293+ if ((rdev & 0xFFFF) != rdev)
294+ return 4;
295+ break;
296+ }
297+ }
298+#endif
299+ }
300+ return 0;
301+}
dfcfd1c3
JB
302diff -Nur cpio-2.5.orig/copypass.c cpio-2.5/copypass.c
303--- cpio-2.5.orig/copypass.c Fri Dec 7 02:03:34 2001
304+++ cpio-2.5/copypass.c Sun Sep 1 00:53:14 2002
305@@ -317,13 +317,23 @@
696818ea 306
307 if (link_res < 0)
308 {
309- res = mknod (output_name.ds_string, in_file_stat.st_mode,
310- in_file_stat.st_rdev);
311+#ifdef S_ISFIFO
312+ if (S_ISFIFO (in_file_stat.st_mode))
313+ res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
314+ else
315+#endif
316+ res = mknod (output_name.ds_string, in_file_stat.st_mode,
317+ in_file_stat.st_rdev);
318 if (res < 0 && create_dir_flag)
319 {
320 create_all_directories (output_name.ds_string);
321- res = mknod (output_name.ds_string, in_file_stat.st_mode,
322- in_file_stat.st_rdev);
323+#ifdef S_ISFIFO
324+ if (S_ISFIFO (in_file_stat.st_mode))
325+ res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
326+ else
327+#endif
328+ res = mknod (output_name.ds_string, in_file_stat.st_mode,
329+ in_file_stat.st_rdev);
330 }
331 if (res < 0)
332 {
dfcfd1c3
JB
333diff -Nur cpio-2.5.orig/main.c cpio-2.5/main.c
334--- cpio-2.5.orig/main.c Sun Sep 1 00:43:11 2002
335+++ cpio-2.5/main.c Sun Sep 1 00:54:17 2002
336@@ -23,6 +23,12 @@
696818ea 337 #include <getopt.h>
338 #include <sys/types.h>
339 #include <sys/stat.h>
340+#ifdef HAVE_SYS_PARAM_H
341+#include <sys/param.h>
342+#endif
343+#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
344+#include <locale.h>
345+#endif
346 #include "filetypes.h"
347 #include "system.h"
348 #include "cpiohdr.h"
dfcfd1c3 349@@ -514,7 +520,10 @@
696818ea 350 char *argv[];
351 {
352 program_name = argv[0];
353- umask (0);
354+
355+#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
356+ (void) setlocale (LC_ALL, "");
357+#endif
358
359 #ifdef __TURBOC__
360 _fmode = O_BINARY; /* Put stdin and stdout in binary mode. */
dfcfd1c3 361@@ -525,6 +534,7 @@
696818ea 362 #endif
363
364 process_args (argc, argv);
365+ umask (0);
366
367 initialize_buffers ();
368
dfcfd1c3
JB
369diff -Nur cpio-2.5.orig/util.c cpio-2.5/util.c
370--- cpio-2.5.orig/util.c Fri Dec 7 02:08:30 2001
371+++ cpio-2.5/util.c Sun Sep 1 00:54:39 2002
372@@ -906,9 +906,9 @@
696818ea 373 fprintf (tty_out, "%s%d%s", new_media_message_with_number, reel_number,
374 new_media_message_after_number);
375 else if (archive_name)
376- fprintf (tty_out, "Found end of tape. Load next tape and press RETURN. ");
dfcfd1c3 377+ fprintf (tty_out, "Found end of volume. Load next tape and press RETURN. ");
696818ea 378 else
379- fprintf (tty_out, "Found end of tape. To continue, type device/file name when ready.\n");
380+ fprintf (tty_out, "Found end of volume. To continue, type device/file name when ready.\n");
381
382 fflush (tty_out);
383
This page took 0.122142 seconds and 4 git commands to generate.