1 --- cpio-2.4.2/copyin.c.fbsd Mon Oct 1 13:50:04 2001
2 +++ cpio-2.4.2/copyin.c Mon Oct 1 13:50:05 2001
7 +#ifdef HAVE_SYS_PARAM_H
8 +#include <sys/param.h>
10 +#if ((defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__))
11 +#define HAVE_STRFTIME
14 #include "filetypes.h"
21 +#if defined(HAVE_STRFTIME)
22 +#include <langinfo.h>
25 /* Debian hack to fix a bug in the --sparse option. This bug has been
26 reported to "bug-gnu-utils@prep.ai.mit.edu". (96/7/10) -BEM */
31 - res = mknod (file_hdr.c_name, file_hdr.c_mode,
32 - makedev (file_hdr.c_rdev_maj, file_hdr.c_rdev_min));
34 + if ((file_hdr.c_mode & CP_IFMT) == CP_IFIFO)
35 + res = mkfifo (file_hdr.c_name, file_hdr.c_mode);
38 + res = mknod (file_hdr.c_name, file_hdr.c_mode,
39 + makedev (file_hdr.c_rdev_maj, file_hdr.c_rdev_min));
40 if (res < 0 && create_dir_flag)
42 create_all_directories (file_hdr.c_name);
43 - res = mknod (file_hdr.c_name, file_hdr.c_mode,
44 - makedev (file_hdr.c_rdev_maj, file_hdr.c_rdev_min));
46 + if ((file_hdr.c_mode & CP_IFMT) == CP_IFIFO)
47 + res = mkfifo (file_hdr.c_name, file_hdr.c_mode);
50 + res = mknod (file_hdr.c_name, file_hdr.c_mode,
51 + makedev (file_hdr.c_rdev_maj,
52 + file_hdr.c_rdev_min));
56 @@ -1087,12 +1111,31 @@
62 + static int d_first = -1;
65 mode_string (file_hdr->c_mode, mbuf);
68 /* Get time values ready to print. */
69 when = file_hdr->c_mtime;
73 + d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
77 + if (current_time - when > 6L * 30L * 24L * 60L * 60L
78 + || current_time - when < 0L)
79 + ptbuf = d_first ? "%e %b %Y" : "%b %e %Y";
81 + ptbuf = d_first ? "%e %b %R" : "%b %e %R";
82 + strftime(tbuf, sizeof(tbuf), ptbuf, localtime(&when));
85 strcpy (tbuf, ctime (&when));
86 if (current_time - when > 6L * 30L * 24L * 60L * 60L
87 || current_time - when < 0L)
88 @@ -1102,8 +1145,10 @@
89 strcpy (tbuf + 11, tbuf + 19);
95 - printf ("%s %3u ", mbuf, file_hdr->c_nlink);
96 + printf ("%s %3lu ", mbuf, file_hdr->c_nlink);
100 @@ -1117,13 +1162,12 @@
102 if ((file_hdr->c_mode & CP_IFMT) == CP_IFCHR
103 || (file_hdr->c_mode & CP_IFMT) == CP_IFBLK)
104 - printf ("%3u, %3u ", file_hdr->c_rdev_maj,
105 - file_hdr->c_rdev_min);
106 + printf ("%3lu, %3lu ", file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
109 printf ("%8lu ", file_hdr->c_filesize);
111 - printf ("%s ", tbuf + 4);
112 + printf ("%s ", ptbuf);
114 print_name_with_quoting (file_hdr->c_name);
116 @@ -1179,6 +1223,9 @@
120 +#if ((defined(BSD) && BSD >= 199306) || defined(__GLIBC__))
125 c < 0377 && c != 0177
126 @@ -1186,6 +1233,7 @@
133 printf ("\\%03o", (unsigned int) c);
134 --- cpio-2.4.2/copyout.c.fbsd Mon Oct 1 13:50:04 2001
135 +++ cpio-2.4.2/copyout.c Mon Oct 1 13:51:21 2001
137 static void writeout_final_defers();
138 static void writeout_defered_file ();
139 static void check_for_changed_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)
203 @@ -822,6 +864,102 @@
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)
304 check_for_changed_file (name, header)
306 --- cpio-2.4.2/copypass.c.fbsd Mon Oct 1 13:50:05 2001
307 +++ cpio-2.4.2/copypass.c Mon Oct 1 13:50:05 2001
308 @@ -311,13 +311,23 @@
312 - res = mknod (output_name.ds_string, in_file_stat.st_mode,
313 - in_file_stat.st_rdev);
315 + if (S_ISFIFO (in_file_stat.st_mode))
316 + res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
319 + res = mknod (output_name.ds_string, in_file_stat.st_mode,
320 + in_file_stat.st_rdev);
321 if (res < 0 && create_dir_flag)
323 create_all_directories (output_name.ds_string);
324 - res = mknod (output_name.ds_string, in_file_stat.st_mode,
325 - in_file_stat.st_rdev);
327 + if (S_ISFIFO (in_file_stat.st_mode))
328 + res = mkfifo (output_name.ds_string, in_file_stat.st_mode);
331 + res = mknod (output_name.ds_string, in_file_stat.st_mode,
332 + in_file_stat.st_rdev);
336 --- cpio-2.4.2/main.c.fbsd Mon Oct 1 13:50:05 2001
337 +++ cpio-2.4.2/main.c Mon Oct 1 13:50:05 2001
341 #include <sys/types.h>
342 #include <sys/stat.h>
343 +#ifdef HAVE_SYS_PARAM_H
344 +#include <sys/param.h>
346 +#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
349 #include "filetypes.h"
352 @@ -508,13 +516,16 @@
353 bzero (zeros_512, 512);
362 program_name = argv[0];
365 +#if (defined(BSD) && (BSD >= 199306)) || defined(__GLIBC__)
366 + (void) setlocale (LC_ALL, "");
370 _fmode = O_BINARY; /* Put stdin and stdout in binary mode. */
374 process_args (argc, argv);
377 initialize_buffers ();
379 --- cpio-2.4.2/util.c.fbsd Mon Oct 1 13:50:05 2001
380 +++ cpio-2.4.2/util.c Mon Oct 1 13:50:05 2001
382 fprintf (tty_out, "%s%d%s", new_media_message_with_number, reel_number,
383 new_media_message_after_number);
384 else if (archive_name)
385 - fprintf (tty_out, "Found end of tape. Load next tape and press RETURN. ");
386 + fprintf (tty_out, "Found end of volume. Load next volume and press RETURN. ");
388 - fprintf (tty_out, "Found end of tape. To continue, type device/file name when ready.\n");
389 + fprintf (tty_out, "Found end of volume. To continue, type device/file name when ready.\n");