From: Carl Miller Date: Wed, 20 Nov 2019 13:08:40 -0500 Subject: Better handle device nodes from cramfs. --- src/copyout.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) Index: cpio-2.14+dfsg/src/copyout.c =================================================================== --- cpio-2.14+dfsg.orig/src/copyout.c +++ cpio-2.14+dfsg/src/copyout.c @@ -219,7 +219,8 @@ writeout_defered_file (struct cpio_file_ header->c_name); warn_if_file_changed(header->c_name, file_hdr.c_filesize, file_hdr.c_mtime); - if (archive_format == arf_tar || archive_format == arf_ustar) + if ((archive_format == arf_tar || archive_format == arf_ustar) + && (file_hdr.c_nlink > 1)) add_inode (file_hdr.c_ino, file_hdr.c_name, file_hdr.c_dev_maj, file_hdr.c_dev_min); @@ -652,7 +653,7 @@ process_copy_out (void) if (archive_format == arf_tar || archive_format == arf_ustar) { - if (file_hdr.c_mode & CP_IFDIR) + if ((file_hdr.c_mode & CP_IFMT) == CP_IFDIR) { /* Make sure the name ends with a slash */ if (!ds_endswith (&input_name, '/')) @@ -669,7 +670,8 @@ process_copy_out (void) switch (file_hdr.c_mode & CP_IFMT) { case CP_IFREG: - if (archive_format == arf_tar || archive_format == arf_ustar) + if ((archive_format == arf_tar || archive_format == arf_ustar) + && (file_hdr.c_nlink > 1)) { char *otherfile; if ((otherfile = find_inode_file (file_hdr.c_ino, @@ -716,7 +718,8 @@ process_copy_out (void) warn_if_file_changed(orig_file_name, file_hdr.c_filesize, file_hdr.c_mtime); - if (archive_format == arf_tar || archive_format == arf_ustar) + if ((archive_format == arf_tar || archive_format == arf_ustar) + && (file_hdr.c_nlink > 1)) add_inode (file_hdr.c_ino, orig_file_name, file_hdr.c_dev_maj, file_hdr.c_dev_min); @@ -752,7 +755,7 @@ process_copy_out (void) orig_file_name); continue; } - else if (archive_format == arf_ustar) + else if ((archive_format == arf_ustar) && (file_hdr.c_nlink > 1)) { char *otherfile; if ((otherfile = find_inode_file (file_hdr.c_ino,