pkgsrc - initial commit
[pkgsrc.git] / archivers / gcpio / patches / patch-ap
1 $NetBSD: patch-ap,v 1.1 2006/02/12 01:44:28 seb Exp $
2
3 --- src/copyout.c.orig  2004-10-14 09:14:03.000000000 +0000
4 +++ src/copyout.c
5 @@ -159,7 +159,7 @@ add_link_defer (struct new_cpio_header *
6  }
7  
8  /* We are about to put a file into a newc or crc archive that is
9 -   multiply linked.  We have already seen and defered all of the
10 +   multiply linked.  We have already seen and deferred all of the
11     other links to the file but haven't written them into the archive.
12     Write the other links into the archive, and remove them from the
13     deferouts list.  */
14 @@ -231,8 +231,10 @@ writeout_defered_file (struct new_cpio_h
15                                            file_hdr.c_filesize,
16                                            header->c_name);
17  
18 -  write_out_header (&file_hdr, out_file_des);
19 -  copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, header->c_name);
20 +  if (write_out_header (&file_hdr, out_file_des))
21 +    return;
22 +  copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize,
23 +                          header->c_name);
24    warn_if_file_changed(header->c_name, file_hdr.c_filesize, file_hdr.c_mtime);
25  
26    if (archive_format == arf_tar || archive_format == arf_ustar)
27 @@ -288,153 +290,313 @@ writeout_final_defers (int out_des)
28      }
29  }
30  
31 -\f
32 -/* Write out header FILE_HDR, including the file name, to file
33 -   descriptor OUT_DES.  */
34 +/* FIXME: These two defines should be defined in paxutils */
35 +#define LG_8  3
36 +#define LG_16 4
37 +
38 +/* FIXME: to_ascii could be used instead of to_oct() and to_octal() from tar,
39 +   so it should be moved to paxutils too.
40 +   Allowed values for logbase are: 1 (binary), 2, 3 (octal), 4 (hex) */
41 +int
42 +to_ascii (char *where, uintmax_t v, size_t digits, unsigned logbase)
43 +{
44 +  static char codetab[] = "0123456789ABCDEF";
45 +  int i = digits;
46 +  
47 +  do
48 +    {
49 +      where[--i] = codetab[(v & ((1 << logbase) - 1))];
50 +      v >>= logbase;
51 +    }
52 +  while (i);
53 +
54 +  return v != 0;
55 +}
56 +
57 +static void
58 +field_width_error (const char *filename, const char *fieldname)
59 +{
60 +  error (0, 0, _("%s: field width not sufficient for storing %s"),
61 +        filename, fieldname);
62 +}
63 +
64 +static void
65 +field_width_warning (const char *filename, const char *fieldname)
66 +{
67 +  if (warn_option & CPIO_WARN_TRUNCATE)
68 +    error (0, 0, _("%s: truncating %s"), filename, fieldname);
69 +}
70  
71  void
72 -write_out_header (struct new_cpio_header *file_hdr, int out_des)
73 +to_ascii_or_warn (char *where, uintmax_t n, size_t digits,
74 +                 unsigned logbase,
75 +                 const char *filename, const char *fieldname)
76  {
77 -  if (archive_format == arf_newascii || archive_format == arf_crcascii)
78 +  if (to_ascii (where, n, digits, logbase))
79 +    field_width_warning (filename, fieldname);
80 +}    
81 +
82 +int
83 +to_ascii_or_error (char *where, uintmax_t n, size_t digits,
84 +                  unsigned logbase,
85 +                  const char *filename, const char *fieldname)
86 +{
87 +  if (to_ascii (where, n, digits, logbase))
88      {
89 -      char ascii_header[112];
90 -      char *magic_string;
91 +      field_width_error (filename, fieldname);
92 +      return 1;
93 +    }
94 +  return 0;
95 +}    
96  
97 -      if (archive_format == arf_crcascii)
98 -       magic_string = "070702";
99 -      else
100 -       magic_string = "070701";
101 -      sprintf (ascii_header,
102 -              "%6s%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx",
103 -              magic_string,
104 -              file_hdr->c_ino, file_hdr->c_mode, file_hdr->c_uid,
105 -              file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
106 -            file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
107 -          file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
108 -              file_hdr->c_chksum);
109 -      tape_buffered_write (ascii_header, out_des, 110L);
110 -
111 -      /* Write file name to output.  */
112 -      tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
113 -      tape_pad_output (out_des, file_hdr->c_namesize + 110);
114 -    }
115 -  else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
116 -    {
117 -      char ascii_header[78];
118 -      dev_t dev;
119 -      dev_t rdev;
120 +int
121 +write_out_new_ascii_header (const char *magic_string,
122 +                           struct new_cpio_header *file_hdr, int out_des)
123 +{
124 +  char ascii_header[110];
125 +  char *p;
126  
127 -      if (archive_format == arf_oldascii)
128 -       {
129 -         dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
130 -         rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
131 -       }
132 -      else
133 -       {
134 -         /* HP/UX cpio creates archives that look just like ordinary archives,
135 -            but for devices it sets major = 0, minor = 1, and puts the
136 -            actual major/minor number in the filesize field.  */
137 -         switch (file_hdr->c_mode & CP_IFMT)
138 -           {
139 -             case CP_IFCHR:
140 -             case CP_IFBLK:
141 +  (void)strncpy(ascii_header, magic_string, sizeof(ascii_header) - 1);
142 +  ascii_header[sizeof(ascii_header) -1] = '\0';
143 +  p = ascii_header + strlen(ascii_header);
144 +  to_ascii_or_warn (p, file_hdr->c_ino, 8, LG_16,
145 +                   file_hdr->c_name, _("inode number"));
146 +  p += 8;
147 +  to_ascii_or_warn (p, file_hdr->c_mode, 8, LG_16, file_hdr->c_name,
148 +                   _("file mode"));
149 +  p += 8;
150 +  to_ascii_or_warn (p, file_hdr->c_uid, 8, LG_16, file_hdr->c_name,
151 +                   _("uid"));
152 +  p += 8;
153 +  to_ascii_or_warn (p, file_hdr->c_gid, 8, LG_16, file_hdr->c_name,
154 +                   _("gid"));
155 +  p += 8;
156 +  to_ascii_or_warn (p, file_hdr->c_nlink, 8, LG_16, file_hdr->c_name,
157 +                   _("number of links"));
158 +  p += 8;
159 +  to_ascii_or_warn (p, file_hdr->c_mtime, 8, LG_16, file_hdr->c_name,
160 +                   _("modification time"));
161 +  p += 8;
162 +  if (to_ascii_or_error (p, file_hdr->c_filesize, 8, LG_16, file_hdr->c_name,
163 +                        _("file size")))
164 +    return 1;
165 +  p += 8;
166 +  if (to_ascii_or_error (p, file_hdr->c_dev_maj, 8, LG_16, file_hdr->c_name,
167 +                        _("device major number")))
168 +    return 1;
169 +  p += 8;
170 +  if (to_ascii_or_error (p, file_hdr->c_dev_min, 8, LG_16, file_hdr->c_name,
171 +                        _("device minor number")))
172 +    return 1;
173 +  p += 8;
174 +  if (to_ascii_or_error (p, file_hdr->c_rdev_maj, 8, LG_16, file_hdr->c_name,
175 +                        _("rdev major")))
176 +    return 1;
177 +  p += 8;
178 +  if (to_ascii_or_error (p, file_hdr->c_rdev_min, 8, LG_16, file_hdr->c_name,
179 +                        _("rdev minor")))
180 +    return 1;
181 +  p += 8;
182 +  if (to_ascii_or_error (p, file_hdr->c_namesize, 8, LG_16, file_hdr->c_name,
183 +                        _("name size")))
184 +    return 1;
185 +  p += 8;
186 +  to_ascii (p, file_hdr->c_chksum & 0xffffffff, 8, LG_16);
187 +
188 +  tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
189 +
190 +  /* Write file name to output.  */
191 +  tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
192 +  tape_pad_output (out_des, file_hdr->c_namesize + sizeof ascii_header);
193 +  return 0;
194 +}  
195 +
196 +int
197 +write_out_old_ascii_header (dev_t dev, dev_t rdev,
198 +                           struct new_cpio_header *file_hdr, int out_des)
199 +{
200 +  char ascii_header[76];
201 +  char *p = ascii_header;
202 +  
203 +  to_ascii (p, file_hdr->c_magic, 6, LG_8);
204 +  p += 6;
205 +  to_ascii_or_warn (p, dev, 6, LG_8, file_hdr->c_name, _("device number"));
206 +  p += 6;
207 +  to_ascii_or_warn (p, file_hdr->c_ino, 6, LG_8, file_hdr->c_name,
208 +                   _("inode number"));
209 +  p += 6;
210 +  to_ascii_or_warn (p, file_hdr->c_mode, 6, LG_8, file_hdr->c_name,
211 +                   _("file mode"));
212 +  p += 6;
213 +  to_ascii_or_warn (p, file_hdr->c_uid, 6, LG_8, file_hdr->c_name, _("uid"));
214 +  p += 6;
215 +  to_ascii_or_warn (p, file_hdr->c_gid, 6, LG_8, file_hdr->c_name, _("gid"));
216 +  p += 6;
217 +  to_ascii_or_warn (p, file_hdr->c_nlink, 6, LG_8, file_hdr->c_name,
218 +                   _("number of links"));
219 +  p += 6;
220 +  to_ascii_or_warn (p, rdev, 6, LG_8, file_hdr->c_name, _("rdev"));
221 +  p += 6;
222 +  to_ascii_or_warn (p, file_hdr->c_mtime, 11, LG_8, file_hdr->c_name,
223 +                   _("modification time"));
224 +  p += 11;
225 +  if (to_ascii_or_error (p, file_hdr->c_namesize, 6, LG_8, file_hdr->c_name,
226 +                        _("name size")))
227 +    return 1;
228 +  p += 6;
229 +  if (to_ascii_or_error (p, file_hdr->c_filesize, 11, LG_8, file_hdr->c_name,
230 +                        _("file size")))
231 +    return 1;
232 +
233 +  tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
234 +
235 +  /* Write file name to output.  */
236 +  tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
237 +  return 0;
238 +}
239 +
240 +void
241 +hp_compute_dev (struct new_cpio_header *file_hdr, dev_t *pdev, dev_t *prdev)
242 +{
243 +  /* HP/UX cpio creates archives that look just like ordinary archives,
244 +     but for devices it sets major = 0, minor = 1, and puts the
245 +     actual major/minor number in the filesize field.  */
246 +  switch (file_hdr->c_mode & CP_IFMT)
247 +    {
248 +    case CP_IFCHR:
249 +    case CP_IFBLK:
250  #ifdef CP_IFSOCK
251 -             case CP_IFSOCK:
252 +    case CP_IFSOCK:
253  #endif
254  #ifdef CP_IFIFO
255 -             case CP_IFIFO:
256 +    case CP_IFIFO:
257  #endif
258 -               file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
259 -                                               file_hdr->c_rdev_min);
260 -               rdev = 1;
261 -               break;
262 -             default:
263 -               dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
264 -               rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
265 -               break;
266 -           }
267 -       }
268 +      file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
269 +                                     file_hdr->c_rdev_min);
270 +      *pdev = *prdev = makedev (0, 1);
271 +      break;
272 +
273 +    default:
274 +      *pdev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
275 +      *prdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
276 +      break;
277 +    }
278 +}
279  
280 -      if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
281 -       error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
282 +int
283 +write_out_binary_header (dev_t rdev,
284 +                        struct new_cpio_header *file_hdr, int out_des)
285 +{
286 +  struct old_cpio_header short_hdr;
287  
288 -      /* Debian hack: The type of dev_t has changed in glibc.  Fixed output
289 -         to ensure that a long int is passed to sprintf.  This has been
290 -         reported to "bug-gnu-utils@prep.ai.mit.edu". (1998/5/26) -BEM */
291 -      sprintf (ascii_header,
292 -              "%06ho%06lo%06lo%06lo%06lo%06lo%06lo%06lo%011lo%06lo%011lo",
293 -              file_hdr->c_magic & 0xFFFF, (long) dev & 0xFFFF,
294 -              file_hdr->c_ino & 0xFFFF, file_hdr->c_mode & 0xFFFF,
295 -              file_hdr->c_uid & 0xFFFF, file_hdr->c_gid & 0xFFFF,
296 -              file_hdr->c_nlink & 0xFFFF, (long) rdev & 0xFFFF,
297 -              file_hdr->c_mtime, file_hdr->c_namesize & 0xFFFF,
298 -              file_hdr->c_filesize);
299 -      tape_buffered_write (ascii_header, out_des, 76L);
300 +  short_hdr.c_magic = 070707;
301 +  short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
302  
303 -      /* Write file name to output.  */
304 -      tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
305 -    }
306 -  else if (archive_format == arf_tar || archive_format == arf_ustar)
307 -    {
308 -      write_out_tar_header (file_hdr, out_des);
309 -    }
310 -  else
311 -    {
312 -      struct old_cpio_header short_hdr;
313 +  if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
314 +    error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
315  
316 -      short_hdr.c_magic = 070707;
317 -      short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
318 +  short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
319 +  if (short_hdr.c_ino != file_hdr->c_ino)
320 +    field_width_warning (file_hdr->c_name, _("inode number"));
321 +  
322 +  short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
323 +  if (short_hdr.c_mode != file_hdr->c_mode)
324 +    field_width_warning (file_hdr->c_name, _("file mode"));
325 +  
326 +  short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
327 +  if (short_hdr.c_uid != file_hdr->c_uid)
328 +    field_width_warning (file_hdr->c_name, _("uid"));
329 +  
330 +  short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
331 +  if (short_hdr.c_gid != file_hdr->c_gid)
332 +    field_width_warning (file_hdr->c_name, _("gid"));
333 +  
334 +  short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
335 +  if (short_hdr.c_nlink != file_hdr->c_nlink)
336 +    field_width_warning (file_hdr->c_name, _("number of links"));
337 +                     
338 +  short_hdr.c_rdev = rdev;
339 +  short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
340 +  short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
341 +
342 +  short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
343 +  if (short_hdr.c_namesize != file_hdr->c_namesize)
344 +    {
345 +      field_width_error (file_hdr->c_name, _("name size"));
346 +      return 1;
347 +    }
348 +                     
349 +  short_hdr.c_filesize = file_hdr->c_filesize;
350 +  if (short_hdr.c_filesize != file_hdr->c_filesize)
351 +    {
352 +      field_width_error (file_hdr->c_name, _("file size"));
353 +      return 1;
354 +    }
355 +                     
356 +  short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
357 +  short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
358  
359 -      if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
360 -       error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
361 +  /* Output the file header.  */
362 +  tape_buffered_write ((char *) &short_hdr, out_des, 26);
363  
364 -      short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
365 -      short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
366 -      short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
367 -      short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
368 -      short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
369 -      if (archive_format != arf_hpbinary)
370 -       short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
371 -      else
372 -       {
373 -         switch (file_hdr->c_mode & CP_IFMT)
374 -           {
375 -             /* HP/UX cpio creates archives that look just like ordinary 
376 -                archives, but for devices it sets major = 0, minor = 1, and 
377 -                puts the actual major/minor number in the filesize field.  */
378 -             case CP_IFCHR:
379 -             case CP_IFBLK:
380 -#ifdef CP_IFSOCK
381 -             case CP_IFSOCK:
382 -#endif
383 -#ifdef CP_IFIFO
384 -             case CP_IFIFO:
385 -#endif
386 -               file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
387 -                                               file_hdr->c_rdev_min);
388 -               short_hdr.c_rdev = makedev (0, 1);
389 -               break;
390 -             default:
391 -               short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj, 
392 -                                           file_hdr->c_rdev_min);
393 -               break;
394 -           }
395 -       }
396 -      short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
397 -      short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
398 +  /* Write file name to output.  */
399 +  tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
400  
401 -      short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
402 +  tape_pad_output (out_des, file_hdr->c_namesize + 26);
403 +  return 0;
404 +}
405  
406 -      short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
407 -      short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
408 +\f
409 +/* Write out header FILE_HDR, including the file name, to file
410 +   descriptor OUT_DES.  */
411  
412 -      /* Output the file header.  */
413 -      tape_buffered_write ((char *) &short_hdr, out_des, 26L);
414 +int 
415 +write_out_header (struct new_cpio_header *file_hdr, int out_des)
416 +{
417 +  dev_t dev;
418 +  dev_t rdev;
419 +  
420 +  switch (archive_format)
421 +    {
422 +    case arf_newascii:
423 +      return write_out_new_ascii_header ("070701", file_hdr, out_des);
424 +      
425 +    case arf_crcascii:
426 +      return write_out_new_ascii_header ("070702", file_hdr, out_des);
427 +      
428 +    case arf_oldascii:
429 +      return write_out_old_ascii_header (makedev (file_hdr->c_dev_maj,
430 +                                                 file_hdr->c_dev_min),
431 +                                        makedev (file_hdr->c_rdev_maj,
432 +                                                 file_hdr->c_rdev_min),
433 +                                        file_hdr, out_des);
434 +      
435 +    case arf_hpoldascii:
436 +      hp_compute_dev (file_hdr, &dev, &rdev);
437 +      return write_out_old_ascii_header (dev, rdev, file_hdr, out_des);
438 +      
439 +    case arf_tar:
440 +    case arf_ustar:
441 +      if (is_tar_filename_too_long (file_hdr->c_name))
442 +       {
443 +         error (0, 0, _("%s: file name too long"), file_hdr->c_name);
444 +         return 1;
445 +       }
446 +      write_out_tar_header (file_hdr, out_des); /* FIXME: No error checking */
447 +      return 0;
448  
449 -      /* Write file name to output.  */
450 -      tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
451 +    case arf_binary:
452 +      return write_out_binary_header (makedev (file_hdr->c_rdev_maj,
453 +                                              file_hdr->c_rdev_min),
454 +                                     file_hdr, out_des);
455 +
456 +    case arf_hpbinary:
457 +      hp_compute_dev (file_hdr, &dev, &rdev);
458 +      /* FIXME: dev ignored. Should it be? */
459 +      return write_out_binary_header (rdev, file_hdr, out_des);
460  
461 -      tape_pad_output (out_des, file_hdr->c_namesize + 26);
462 +    default:
463 +      abort ();
464      }
465  }
466  
467 @@ -593,14 +755,7 @@ process_copy_out ()
468               file_hdr.c_namesize = strlen (p) + 1;
469             }
470  #endif
471 -         if ((archive_format == arf_tar || archive_format == arf_ustar)
472 -             && is_tar_filename_too_long (file_hdr.c_name))
473 -           {
474 -             error (0, 0, _("%s: file name too long"),
475 -                    file_hdr.c_name);
476 -             continue;
477 -           }
478 -         
479 +
480           /* Copy the named file to the output.  */
481           switch (file_hdr.c_mode & CP_IFMT)
482             {
483 @@ -613,8 +768,8 @@ process_copy_out ()
484                                                     file_hdr.c_dev_min)))
485                     {
486                       file_hdr.c_tar_linkname = otherfile;
487 -                     write_out_header (&file_hdr, out_file_des);
488 -                     break;
489 +                     if (write_out_header (&file_hdr, out_file_des))
490 +                       continue;
491                     }
492                 }
493               if ( (archive_format == arf_newascii || archive_format == arf_crcascii)
494 @@ -643,7 +798,8 @@ process_copy_out ()
495                                                        file_hdr.c_filesize,
496                                                        input_name.ds_string);
497  
498 -             write_out_header (&file_hdr, out_file_des);
499 +             if (write_out_header (&file_hdr, out_file_des))
500 +               continue;
501               copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, input_name.ds_string);
502               warn_if_file_changed(input_name.ds_string, file_hdr.c_filesize,
503                                     file_hdr.c_mtime);
504 @@ -673,7 +829,8 @@ process_copy_out ()
505  
506             case CP_IFDIR:
507               file_hdr.c_filesize = 0;
508 -             write_out_header (&file_hdr, out_file_des);
509 +             if (write_out_header (&file_hdr, out_file_des))
510 +               continue;
511               break;
512  
513             case CP_IFCHR:
514 @@ -702,14 +859,16 @@ process_copy_out ()
515                       file_hdr.c_mode = (file_stat.st_mode & 07777);
516                       file_hdr.c_mode |= CP_IFREG;
517                       file_hdr.c_tar_linkname = otherfile;
518 -                     write_out_header (&file_hdr, out_file_des);
519 +                     if (write_out_header (&file_hdr, out_file_des))
520 +                       continue;
521                       break;
522                     }
523                   add_inode (file_hdr.c_ino, file_hdr.c_name, 
524                              file_hdr.c_dev_maj, file_hdr.c_dev_min);
525                 }
526               file_hdr.c_filesize = 0;
527 -             write_out_header (&file_hdr, out_file_des);
528 +             if (write_out_header (&file_hdr, out_file_des))
529 +               continue;
530               break;
531  
532  #ifdef CP_IFLNK
533 @@ -738,12 +897,14 @@ process_copy_out ()
534                       {
535                         link_name[link_size] = '\0';
536                         file_hdr.c_tar_linkname = link_name;
537 -                       write_out_header (&file_hdr, out_file_des);
538 +                       if (write_out_header (&file_hdr, out_file_des))
539 +                         continue;
540                       }
541                   }
542                 else
543                   {
544 -                   write_out_header (&file_hdr, out_file_des);
545 +                   if (write_out_header (&file_hdr, out_file_des))
546 +                     continue;
547                     tape_buffered_write (link_name, out_file_des, link_size);
548                     tape_pad_output (out_file_des, link_size);
549                   }