3 /* copyout.c - create a cpio archive
4 Copyright (C) 1990, 1991, 1992, 2001, 2003, 2004,
5 2006 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public
18 License along with this program; if not, write to the Free
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301 USA. */
25 #include <sys/types.h>
27 #include "filetypes.h"
35 static int check_rdev ();
37 /* Read FILE_SIZE bytes of FILE_NAME from IN_FILE_DES and
38 compute and return a checksum for them. */
41 read_for_checksum (int in_file_des, int file_size, char *file_name)
51 for (bytes_left = file_size; bytes_left > 0; bytes_left -= bytes_read)
53 bytes_read = read (in_file_des, buf, BUFSIZ);
55 error (1, errno, _("cannot read checksum for %s"), file_name);
58 if (bytes_left < bytes_read)
59 bytes_read = bytes_left;
60 for (i = 0; i < bytes_read; ++i)
63 if (lseek (in_file_des, 0L, SEEK_SET))
64 error (1, errno, _("cannot read checksum for %s"), file_name);
69 /* Write out NULs to fill out the rest of the current block on
73 tape_clear_rest_of_block (int out_file_des)
75 write_nuls_to_file (io_block_size - output_size, out_file_des,
79 /* Write NULs on OUT_FILE_DES to move from OFFSET (the current location)
80 to the end of the header. */
83 tape_pad_output (int out_file_des, int offset)
87 if (archive_format == arf_newascii || archive_format == arf_crcascii)
88 pad = (4 - (offset % 4)) % 4;
89 else if (archive_format == arf_tar || archive_format == arf_ustar)
90 pad = (512 - (offset % 512)) % 512;
91 else if (archive_format != arf_oldascii && archive_format != arf_hpoldascii)
92 pad = (2 - (offset % 2)) % 2;
97 write_nuls_to_file (pad, out_file_des, tape_buffered_write);
101 /* When creating newc and crc archives if a file has multiple (hard)
102 links, we don't put any of them into the archive until we have seen
103 all of them (or until we get to the end of the list of files that
104 are going into the archive and know that we have seen all of the links
105 to the file that we will see). We keep these "defered" files on
108 struct deferment *deferouts = NULL;
110 /* Count the number of other (hard) links to this file that have
111 already been defered. */
114 count_defered_links_to_dev_ino (struct cpio_file_stat *file_hdr)
121 ino = file_hdr->c_ino;
122 maj = file_hdr->c_dev_maj;
123 min = file_hdr->c_dev_min;
125 for (d = deferouts; d != NULL; d = d->next)
127 if ( (d->header.c_ino == ino) && (d->header.c_dev_maj == maj)
128 && (d->header.c_dev_min == min) )
134 /* Is this file_hdr the last (hard) link to a file? I.e., have
135 we already seen and defered all of the other links? */
138 last_link (struct cpio_file_stat *file_hdr)
140 int other_files_sofar;
142 other_files_sofar = count_defered_links_to_dev_ino (file_hdr);
143 if (file_hdr->c_nlink == (other_files_sofar + 1) )
151 /* Add the file header for a link that is being defered to the deferouts
155 add_link_defer (struct cpio_file_stat *file_hdr)
158 d = create_deferment (file_hdr);
163 /* We are about to put a file into a newc or crc archive that is
164 multiply linked. We have already seen and deferred all of the
165 other links to the file but haven't written them into the archive.
166 Write the other links into the archive, and remove them from the
170 writeout_other_defers (struct cpio_file_stat *file_hdr, int out_des)
173 struct deferment *d_prev;
177 ino = file_hdr->c_ino;
178 maj = file_hdr->c_dev_maj;
179 min = file_hdr->c_dev_min;
184 if ( (d->header.c_ino == ino) && (d->header.c_dev_maj == maj)
185 && (d->header.c_dev_min == min) )
187 struct deferment *d_free;
188 d->header.c_filesize = 0;
189 write_out_header (&d->header, out_des);
191 d_prev->next = d->next;
196 free_deferment (d_free);
207 /* Write a file into the archive. This code is the same as
208 the code in process_copy_out(), but we need it here too
209 for writeout_final_defers() to call. */
212 writeout_defered_file (struct cpio_file_stat *header, int out_file_des)
215 struct cpio_file_stat file_hdr;
220 in_file_des = open (header->c_name,
221 O_RDONLY | O_BINARY, 0);
224 open_error (header->c_name);
228 if (archive_format == arf_crcascii)
229 file_hdr.c_chksum = read_for_checksum (in_file_des,
233 if (write_out_header (&file_hdr, out_file_des))
235 copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize,
237 warn_if_file_changed(header->c_name, file_hdr.c_filesize, file_hdr.c_mtime);
239 if (archive_format == arf_tar || archive_format == arf_ustar)
240 add_inode (file_hdr.c_ino, file_hdr.c_name, file_hdr.c_dev_maj,
243 tape_pad_output (out_file_des, file_hdr.c_filesize);
246 set_file_times (in_file_des, file_hdr.c_name, file_hdr.c_mtime,
248 if (close (in_file_des) < 0)
249 close_error (header->c_name);
252 /* When writing newc and crc format archives we defer multiply linked
253 files until we have seen all of the links to the file. If a file
254 has links to it that aren't going into the archive, then we will
255 never see the "last" link to the file, so at the end we just write
256 all of the leftover defered files into the archive. */
259 writeout_final_defers (int out_des)
263 while (deferouts != NULL)
266 other_count = count_defered_links_to_dev_ino (&d->header);
267 if (other_count == 1)
269 writeout_defered_file (&d->header, out_des);
273 struct cpio_file_stat file_hdr;
274 file_hdr = d->header;
275 file_hdr.c_filesize = 0;
276 write_out_header (&file_hdr, out_des);
278 deferouts = deferouts->next;
282 /* FIXME: to_ascii could be used instead of to_oct() and to_octal() from tar,
283 so it should be moved to paxutils too.
284 Allowed values for logbase are: 1 (binary), 2, 3 (octal), 4 (hex) */
286 to_ascii (char *where, uintmax_t v, size_t digits, unsigned logbase)
288 static char codetab[] = "0123456789ABCDEF";
293 where[--i] = codetab[(v & ((1 << logbase) - 1))];
302 field_width_error (const char *filename, const char *fieldname)
304 error (0, 0, _("%s: field width not sufficient for storing %s"),
305 filename, fieldname);
309 field_width_warning (const char *filename, const char *fieldname)
311 if (warn_option & CPIO_WARN_TRUNCATE)
312 error (0, 0, _("%s: truncating %s"), filename, fieldname);
316 to_ascii_or_warn (char *where, uintmax_t n, size_t digits,
318 const char *filename, const char *fieldname)
320 if (to_ascii (where, n, digits, logbase))
321 field_width_warning (filename, fieldname);
325 to_ascii_or_error (char *where, uintmax_t n, size_t digits,
327 const char *filename, const char *fieldname)
329 if (to_ascii (where, n, digits, logbase))
331 field_width_error (filename, fieldname);
339 write_out_new_ascii_header (const char *magic_string,
340 struct cpio_file_stat *file_hdr, int out_des)
342 char ascii_header[110];
345 p = stpcpy (ascii_header, magic_string);
346 to_ascii_or_warn (p, file_hdr->c_ino, 8, LG_16,
347 file_hdr->c_name, _("inode number"));
349 to_ascii_or_warn (p, file_hdr->c_mode, 8, LG_16, file_hdr->c_name,
352 to_ascii_or_warn (p, file_hdr->c_uid, 8, LG_16, file_hdr->c_name,
355 to_ascii_or_warn (p, file_hdr->c_gid, 8, LG_16, file_hdr->c_name,
358 to_ascii_or_warn (p, file_hdr->c_nlink, 8, LG_16, file_hdr->c_name,
359 _("number of links"));
361 to_ascii_or_warn (p, file_hdr->c_mtime, 8, LG_16, file_hdr->c_name,
362 _("modification time"));
364 if (to_ascii_or_error (p, file_hdr->c_filesize, 8, LG_16, file_hdr->c_name,
368 if (to_ascii_or_error (p, file_hdr->c_dev_maj, 8, LG_16, file_hdr->c_name,
369 _("device major number")))
372 if (to_ascii_or_error (p, file_hdr->c_dev_min, 8, LG_16, file_hdr->c_name,
373 _("device minor number")))
376 if (to_ascii_or_error (p, file_hdr->c_rdev_maj, 8, LG_16, file_hdr->c_name,
380 if (to_ascii_or_error (p, file_hdr->c_rdev_min, 8, LG_16, file_hdr->c_name,
384 if (to_ascii_or_error (p, file_hdr->c_namesize, 8, LG_16, file_hdr->c_name,
388 to_ascii (p, file_hdr->c_chksum & 0xffffffff, 8, LG_16);
390 tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
392 /* Write file name to output. */
393 tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
394 tape_pad_output (out_des, file_hdr->c_namesize + sizeof ascii_header);
399 write_out_old_ascii_header (dev_t dev, dev_t rdev,
400 struct cpio_file_stat *file_hdr, int out_des)
402 char ascii_header[76];
403 char *p = ascii_header;
405 to_ascii (p, file_hdr->c_magic, 6, LG_8);
407 to_ascii_or_warn (p, dev, 6, LG_8, file_hdr->c_name, _("device number"));
409 to_ascii_or_warn (p, file_hdr->c_ino, 6, LG_8, file_hdr->c_name,
412 to_ascii_or_warn (p, file_hdr->c_mode, 6, LG_8, file_hdr->c_name,
415 to_ascii_or_warn (p, file_hdr->c_uid, 6, LG_8, file_hdr->c_name, _("uid"));
417 to_ascii_or_warn (p, file_hdr->c_gid, 6, LG_8, file_hdr->c_name, _("gid"));
419 to_ascii_or_warn (p, file_hdr->c_nlink, 6, LG_8, file_hdr->c_name,
420 _("number of links"));
422 to_ascii_or_warn (p, rdev, 6, LG_8, file_hdr->c_name, _("rdev"));
424 to_ascii_or_warn (p, file_hdr->c_mtime, 11, LG_8, file_hdr->c_name,
425 _("modification time"));
427 if (to_ascii_or_error (p, file_hdr->c_namesize, 6, LG_8, file_hdr->c_name,
431 if (to_ascii_or_error (p, file_hdr->c_filesize, 11, LG_8, file_hdr->c_name,
435 tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
437 /* Write file name to output. */
438 tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
443 hp_compute_dev (struct cpio_file_stat *file_hdr, dev_t *pdev, dev_t *prdev)
445 /* HP/UX cpio creates archives that look just like ordinary archives,
446 but for devices it sets major = 0, minor = 1, and puts the
447 actual major/minor number in the filesize field. */
448 switch (file_hdr->c_mode & CP_IFMT)
458 file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
459 file_hdr->c_rdev_min);
460 *pdev = *prdev = makedev (0, 1);
464 *pdev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
465 *prdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
471 write_out_binary_header (dev_t rdev,
472 struct cpio_file_stat *file_hdr, int out_des)
474 struct old_cpio_header short_hdr;
476 short_hdr.c_magic = 070707;
477 short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
479 if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
480 error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
482 short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
483 if (short_hdr.c_ino != file_hdr->c_ino)
484 field_width_warning (file_hdr->c_name, _("inode number"));
486 short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
487 if (short_hdr.c_mode != file_hdr->c_mode)
488 field_width_warning (file_hdr->c_name, _("file mode"));
490 short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
491 if (short_hdr.c_uid != file_hdr->c_uid)
492 field_width_warning (file_hdr->c_name, _("uid"));
494 short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
495 if (short_hdr.c_gid != file_hdr->c_gid)
496 field_width_warning (file_hdr->c_name, _("gid"));
498 short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
499 if (short_hdr.c_nlink != file_hdr->c_nlink)
500 field_width_warning (file_hdr->c_name, _("number of links"));
502 short_hdr.c_rdev = rdev;
503 short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
504 short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
506 short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
507 if (short_hdr.c_namesize != file_hdr->c_namesize)
509 field_width_error (file_hdr->c_name, _("name size"));
513 short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
514 short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
516 if (((off_t)short_hdr.c_filesizes[0] << 16) + short_hdr.c_filesizes[1]
517 != file_hdr->c_filesize)
519 field_width_error (file_hdr->c_name, _("file size"));
523 /* Output the file header. */
524 tape_buffered_write ((char *) &short_hdr, out_des, 26);
526 /* Write file name to output. */
527 tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
529 tape_pad_output (out_des, file_hdr->c_namesize + 26);
534 /* Write out header FILE_HDR, including the file name, to file
535 descriptor OUT_DES. */
538 write_out_header (struct cpio_file_stat *file_hdr, int out_des)
543 switch (archive_format)
546 return write_out_new_ascii_header ("070701", file_hdr, out_des);
549 return write_out_new_ascii_header ("070702", file_hdr, out_des);
552 return write_out_old_ascii_header (makedev (file_hdr->c_dev_maj,
553 file_hdr->c_dev_min),
554 makedev (file_hdr->c_rdev_maj,
555 file_hdr->c_rdev_min),
559 hp_compute_dev (file_hdr, &dev, &rdev);
560 return write_out_old_ascii_header (dev, rdev, file_hdr, out_des);
564 if (is_tar_filename_too_long (file_hdr->c_name))
566 error (0, 0, _("%s: file name too long"), file_hdr->c_name);
569 write_out_tar_header (file_hdr, out_des); /* FIXME: No error checking */
573 return write_out_binary_header (makedev (file_hdr->c_rdev_maj,
574 file_hdr->c_rdev_min),
578 hp_compute_dev (file_hdr, &dev, &rdev);
579 /* FIXME: dev ignored. Should it be? */
580 return write_out_binary_header (rdev, file_hdr, out_des);
588 assign_string (char **pvar, char *value)
590 char *p = xrealloc (*pvar, strlen (value) + 1);
595 /* Read a list of file names from the standard input
596 and write a cpio collection on the standard output.
597 The format of the header depends on the compatibility (-c) flag. */
602 int res; /* Result of functions. */
603 dynamic_string input_name; /* Name of file read from stdin. */
604 struct stat file_stat; /* Stat record for file. */
605 struct cpio_file_stat file_hdr; /* Output header information. */
606 int in_file_des; /* Source file descriptor. */
607 int out_file_des; /* Output file descriptor. */
608 char *orig_file_name = NULL;
610 /* Initialize the copy out. */
611 ds_init (&input_name, 128);
612 file_hdr.c_magic = 070707;
614 /* Check whether the output file might be a tape. */
615 out_file_des = archive_des;
616 if (_isrmt (out_file_des))
618 output_is_special = 1;
619 output_is_seekable = 0;
623 if (fstat (out_file_des, &file_stat))
624 error (1, errno, _("standard output is closed"));
627 S_ISBLK (file_stat.st_mode) ||
629 S_ISCHR (file_stat.st_mode);
630 output_is_seekable = S_ISREG (file_stat.st_mode);
636 prepare_append (out_file_des);
639 /* Copy files with names read from stdin. */
640 while (ds_fgetstr (stdin, &input_name, name_end) != NULL)
642 /* Check for blank line. */
643 if (input_name.ds_string[0] == 0)
645 error (0, 0, _("blank line ignored"));
649 /* Process next file. */
650 if ((*xstat) (input_name.ds_string, &file_stat) < 0)
651 stat_error (input_name.ds_string);
654 /* Set values in output header. */
655 stat_to_cpio (&file_hdr, &file_stat);
657 if (archive_format == arf_tar || archive_format == arf_ustar)
659 if (file_hdr.c_mode & CP_IFDIR)
661 int len = strlen (input_name.ds_string);
662 /* Make sure the name ends with a slash */
663 if (input_name.ds_string[len-1] != '/')
665 ds_resize (&input_name, len + 2);
666 input_name.ds_string[len] = '/';
667 input_name.ds_string[len+1] = 0;
672 switch (check_rdev (&file_hdr))
675 error (0, 0, "%s not dumped: major number would be truncated",
679 error (0, 0, "%s not dumped: minor number would be truncated",
683 error (0, 0, "%s not dumped: device number would be truncated",
688 assign_string (&orig_file_name, input_name.ds_string);
689 cpio_safer_name_suffix (input_name.ds_string, false,
690 abs_paths_flag, true);
692 file_hdr.c_name = input_name.ds_string;
693 file_hdr.c_namesize = strlen (input_name.ds_string) + 1;
695 if ( (archive_format != arf_tar) && (archive_format != arf_ustar) )
697 /* We mark CDF's in cpio files by adding a 2nd `/' after the
698 "hidden" directory name. We need to do this so we can
699 properly recreate the directory as hidden (in case the
700 files of a directory go into the archive before the
701 directory itself (e.g from "find ... -depth ... | cpio")). */
702 file_hdr.c_name = add_cdf_double_slashes (input_name.ds_string);
703 file_hdr.c_namesize = strlen (file_hdr.c_name) + 1;
707 /* We don't mark CDF's in tar files. We assume the "hidden"
708 directory will always go into the archive before any of
710 file_hdr.c_name = input_name.ds_string;
711 file_hdr.c_namesize = strlen (input_name.ds_string) + 1;
715 /* Copy the named file to the output. */
716 switch (file_hdr.c_mode & CP_IFMT)
719 if (archive_format == arf_tar || archive_format == arf_ustar)
722 if ((otherfile = find_inode_file (file_hdr.c_ino,
724 file_hdr.c_dev_min)))
726 file_hdr.c_tar_linkname = otherfile;
727 if (write_out_header (&file_hdr, out_file_des))
732 if ( (archive_format == arf_newascii || archive_format == arf_crcascii)
733 && (file_hdr.c_nlink > 1) )
735 if (last_link (&file_hdr) )
737 writeout_other_defers (&file_hdr, out_file_des);
741 add_link_defer (&file_hdr);
745 in_file_des = open (orig_file_name,
746 O_RDONLY | O_BINARY, 0);
749 open_error (orig_file_name);
753 if (archive_format == arf_crcascii)
754 file_hdr.c_chksum = read_for_checksum (in_file_des,
758 if (write_out_header (&file_hdr, out_file_des))
760 copy_files_disk_to_tape (in_file_des,
761 out_file_des, file_hdr.c_filesize,
763 warn_if_file_changed(orig_file_name, file_hdr.c_filesize,
766 if (archive_format == arf_tar || archive_format == arf_ustar)
767 add_inode (file_hdr.c_ino, orig_file_name, file_hdr.c_dev_maj,
770 tape_pad_output (out_file_des, file_hdr.c_filesize);
773 set_file_times (in_file_des,
775 file_stat.st_atime, file_stat.st_mtime);
776 if (close (in_file_des) < 0)
777 close_error (orig_file_name);
781 file_hdr.c_filesize = 0;
782 if (write_out_header (&file_hdr, out_file_des))
794 if (archive_format == arf_tar)
796 error (0, 0, _("%s not dumped: not a regular file"),
800 else if (archive_format == arf_ustar)
803 if ((otherfile = find_inode_file (file_hdr.c_ino,
805 file_hdr.c_dev_min)))
807 /* This file is linked to another file already in the
808 archive, so write it out as a hard link. */
809 file_hdr.c_mode = (file_stat.st_mode & 07777);
810 file_hdr.c_mode |= CP_IFREG;
811 file_hdr.c_tar_linkname = otherfile;
812 if (write_out_header (&file_hdr, out_file_des))
816 add_inode (file_hdr.c_ino, orig_file_name,
817 file_hdr.c_dev_maj, file_hdr.c_dev_min);
819 file_hdr.c_filesize = 0;
820 if (write_out_header (&file_hdr, out_file_des))
827 char *link_name = (char *) xmalloc (file_stat.st_size + 1);
830 link_size = readlink (orig_file_name, link_name,
834 readlink_warn (orig_file_name);
838 link_name[link_size] = 0;
839 cpio_safer_name_suffix (link_name, false,
840 abs_paths_flag, true);
841 link_size = strlen (link_name);
842 file_hdr.c_filesize = link_size;
843 if (archive_format == arf_tar || archive_format == arf_ustar)
845 if (link_size + 1 > 100)
847 error (0, 0, _("%s: symbolic link too long"),
852 link_name[link_size] = '\0';
853 file_hdr.c_tar_linkname = link_name;
854 if (write_out_header (&file_hdr, out_file_des))
860 if (write_out_header (&file_hdr, out_file_des))
862 tape_buffered_write (link_name, out_file_des, link_size);
863 tape_pad_output (out_file_des, link_size);
871 error (0, 0, _("%s: unknown file type"), orig_file_name);
875 fprintf (stderr, "%s\n", orig_file_name);
881 free (orig_file_name);
883 writeout_final_defers(out_file_des);
884 /* The collection is complete; append the trailer. */
889 file_hdr.c_nlink = 1; /* Must be 1 for crc format. */
890 file_hdr.c_dev_maj = 0;
891 file_hdr.c_dev_min = 0;
892 file_hdr.c_rdev_maj = 0;
893 file_hdr.c_rdev_min = 0;
894 file_hdr.c_mtime = 0;
895 file_hdr.c_chksum = 0;
897 file_hdr.c_filesize = 0;
898 file_hdr.c_namesize = 11;
899 file_hdr.c_name = CPIO_TRAILER_NAME;
900 if (archive_format != arf_tar && archive_format != arf_ustar)
901 write_out_header (&file_hdr, out_file_des);
903 write_nuls_to_file (1024, out_file_des, tape_buffered_write);
905 /* Fill up the output block. */
906 tape_clear_rest_of_block (out_file_des);
907 tape_empty_output_buffer (out_file_des);
909 fputc ('\n', stderr);
912 res = (output_bytes + io_block_size - 1) / io_block_size;
913 fprintf (stderr, ngettext ("%d block\n", "%d blocks\n", res), res);
918 check_rdev (file_hdr)
919 struct cpio_file_stat *file_hdr;
921 if (archive_format == arf_newascii || archive_format == arf_crcascii)
923 if ((file_hdr->c_rdev_maj & 0xFFFFFFFF) != file_hdr->c_rdev_maj)
925 if ((file_hdr->c_rdev_min & 0xFFFFFFFF) != file_hdr->c_rdev_min)
928 else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
933 rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
934 if (archive_format == arf_oldascii)
936 if ((rdev & 0xFFFF) != rdev)
941 switch (file_hdr->c_mode & CP_IFMT)
951 /* We could handle one more bit if longs are >= 33 bits. */
952 if ((rdev & 037777777777) != rdev)
956 if ((rdev & 0xFFFF) != rdev)
963 else if (archive_format == arf_tar || archive_format == arf_ustar)
965 /* The major and minor formats are limited to 7 octal digits in ustar
966 format, and to_oct () adds a gratuitous trailing blank to further
967 limit the format to 6 octal digits. */
968 if ((file_hdr->c_rdev_maj & 0777777) != file_hdr->c_rdev_maj)
970 if ((file_hdr->c_rdev_min & 0777777) != file_hdr->c_rdev_min)
978 rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
979 if (archive_format != arf_hpbinary)
981 if ((rdev & 0xFFFF) != rdev)
986 switch (file_hdr->c_mode & CP_IFMT)
996 if ((rdev & 0xFFFFFFFF) != rdev)
998 file_hdr->c_filesize = rdev;
999 rdev = makedev (0, 1);
1002 if ((rdev & 0xFFFF) != rdev)