1 diff -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
8 +#ifdef HAVE_SYS_PARAM_H
9 +#include <sys/param.h>
11 +#if ((defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__))
12 +#define HAVE_STRFTIME
15 #include "filetypes.h"
22 +#if defined(HAVE_STRFTIME)
23 +#include <langinfo.h>
28 @@ -1146,13 +1156,23 @@
33 - res = mknod (file_hdr->c_name, file_hdr->c_mode,
36 + if ((file_hdr->c_mode & CP_IFMT) == CP_IFIFO)
37 + res = mkfifo (file_hdr->c_name, file_hdr->c_mode);
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)
44 create_all_directories (file_hdr->c_name);
45 - res = mknod (file_hdr->c_name, file_hdr->c_mode,
47 + if ((file_hdr->c_mode & CP_IFMT) == CP_IFIFO)
48 + res = mkfifo (file_hdr->c_name, file_hdr->c_mode);
51 + res = mknod (file_hdr->c_name, file_hdr->c_mode,
52 makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min));
55 @@ -1238,12 +1258,31 @@
61 + static int d_first = -1;
64 mode_string (file_hdr->c_mode, mbuf);
67 /* Get time values ready to print. */
68 when = file_hdr->c_mtime;
72 + d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
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";
80 + ptbuf = d_first ? "%e %b %R" : "%b %e %R";
81 + strftime(tbuf, sizeof(tbuf), ptbuf, localtime(&when));
84 strcpy (tbuf, ctime (&when));
85 if (current_time - when > 6L * 30L * 24L * 60L * 60L
86 || current_time - when < 0L)
87 @@ -1253,8 +1292,10 @@
88 strcpy (tbuf + 11, tbuf + 19);
94 - printf ("%s %3u ", mbuf, file_hdr->c_nlink);
95 + printf ("%s %3lu ", mbuf, file_hdr->c_nlink);
99 @@ -1268,13 +1309,13 @@
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,
104 + printf ("%3lu, %3lu ", file_hdr->c_rdev_maj,
105 file_hdr->c_rdev_min);
108 printf ("%8lu ", file_hdr->c_filesize);
110 - printf ("%s ", tbuf + 4);
111 + printf ("%s ", ptbuf);
113 print_name_with_quoting (file_hdr->c_name);
115 @@ -1330,6 +1371,9 @@
119 +#if ((defined(BSD) && BSD >= 199306) || defined(__GLIBC__))
124 c < 0377 && c != 0177
125 @@ -1337,6 +1381,7 @@
132 printf ("\\%03o", (unsigned int) c);
133 diff -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
137 static void writeout_other_defers ();
138 static void writeout_final_defers();
139 static void writeout_defered_file ();
140 +static int check_rdev ();
142 /* Write out header FILE_HDR, including the file name, to file
143 descriptor OUT_DES. */
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);
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)
167 + file_hdr.c_rdev_maj = major (file_stat.st_rdev);
168 + file_hdr.c_rdev_min = minor (file_stat.st_rdev);
171 + file_hdr.c_rdev_maj = 0;
172 + file_hdr.c_rdev_min = 0;
176 file_hdr.c_mtime = file_stat.st_mtime;
177 file_hdr.c_filesize = file_stat.st_size;
178 file_hdr.c_chksum = 0;
183 + switch (check_rdev (&file_hdr))
186 + error (0, 0, "%s not dumped: major number would be truncated",
190 + error (0, 0, "%s not dumped: minor number would be truncated",
194 + error (0, 0, "%s not dumped: device number would be truncated",
200 /* Copy the named file to the output. */
201 switch (file_hdr.c_mode & CP_IFMT)
209 +check_rdev (file_hdr)
210 + struct new_cpio_header *file_hdr;
212 + if (archive_format == arf_newascii || archive_format == arf_crcascii)
214 + if ((file_hdr->c_rdev_maj & 0xFFFFFFFF) != file_hdr->c_rdev_maj)
216 + if ((file_hdr->c_rdev_min & 0xFFFFFFFF) != file_hdr->c_rdev_min)
219 + else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
224 + rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
225 + if (archive_format == arf_oldascii)
227 + if ((rdev & 0xFFFF) != rdev)
232 + switch (file_hdr->c_mode & CP_IFMT)
242 + /* We could handle one more bit if longs are >= 33 bits. */
243 + if ((rdev & 037777777777) != rdev)
247 + if ((rdev & 0xFFFF) != rdev)
254 + else if (archive_format == arf_tar || archive_format == arf_ustar)
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)
261 + if ((file_hdr->c_rdev_min & 0777777) != file_hdr->c_rdev_min)
269 + rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
270 + if (archive_format != arf_hpbinary)
272 + if ((rdev & 0xFFFF) != rdev)
277 + switch (file_hdr->c_mode & CP_IFMT)
287 + if ((rdev & 0xFFFFFFFF) != rdev)
289 + file_hdr->c_filesize = rdev;
290 + rdev = makedev (0, 1);
293 + if ((rdev & 0xFFFF) != rdev)
302 diff -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 @@
309 - res = mknod (output_name.ds_string, in_file_stat.st_mode,
310 - in_file_stat.st_rdev);
312 + if (S_ISFIFO (in_file_stat.st_mode))
313 + res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
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)
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);
324 + if (S_ISFIFO (in_file_stat.st_mode))
325 + res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
328 + res = mknod (output_name.ds_string, in_file_stat.st_mode,
329 + in_file_stat.st_rdev);
333 diff -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
338 #include <sys/types.h>
339 #include <sys/stat.h>
340 +#ifdef HAVE_SYS_PARAM_H
341 +#include <sys/param.h>
343 +#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
346 #include "filetypes.h"
352 program_name = argv[0];
355 +#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
356 + (void) setlocale (LC_ALL, "");
360 _fmode = O_BINARY; /* Put stdin and stdout in binary mode. */
364 process_args (argc, argv);
367 initialize_buffers ();
369 diff -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
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. ");
377 + fprintf (tty_out, "Found end of volume. Load next tape and press RETURN. ");
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");