[ 
https://issues.apache.org/jira/browse/COMPRESS-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12834265#action_12834265
 ] 

Stefan Bodewig commented on COMPRESS-85:
----------------------------------------

So far I've found a few places where we seem to deviate a bit from 
http://people.freebsd.org/~kientzle/libarchive/man/cpio.5.txt or our own 
description in the javadocs of CpioArchiveEntry.  Mainly:

* namelen could be wrong in non.ASCII cases - not the case with the example 
files

* dev/ino are always 0 but should be different for each entry

* nlink is always 0 but should at least be 1 for files and 2 for directories

The permissions and gid/uid are also 0 but that should be OK.  Neither of these 
things would explain why cpio would be happy with the first three entries but 
doesn't like the forth one.  Can you isolate the forth one as the one causing 
the problem?  I.e. do you get valid archives when putting only the first three 
into it, or just the forth one?

Back into hexl-mode trying to see whether there is anything fishy with the last 
entry.


> cpio archive final entry corrupt
> --------------------------------
>
>                 Key: COMPRESS-85
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-85
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Java 1.4.2 run on AIX and Linux
>            Reporter: Bill Maier
>         Attachments: archive.cpio, archive.cpio, cpio.tar, Creator.java
>
>
> The code below is called with an array of 4 file names. The cpio archive 
> archive.cpio is created with no error messages, but when I then run the Unix 
> command "cpio -ivct <archive.cpio" it reports the error "Can't read input" on 
> the last file in the archive. If I run "cpio -ivcBmu <archive.cpio" the last 
> file is incomplete, but the other files are extracted correctly. Same result 
> in AIX and Linux.
> {{
>   private void createArchive(String[] outFiles)
>   throws FileNotFoundException, IOException, ArchiveException {
>     short format = CpioArchiveOutputStream.FORMAT_OLD_ASCII;
>     final OutputStream out = new FileOutputStream("archive.cpio");
>     ArchiveOutputStream os = new CpioArchiveOutputStream(out, format);
>     for (int j = 0; j < outFiles.length; j++) {
>       System.out.println("Entry = " + outFiles[j]);
>       File f = new File(outFiles[j]);
>       CpioArchiveEntry entry = new CpioArchiveEntry(format);
>       entry.setName(outFiles[j]);
>       entry.setSize(f.length());
>       os.putArchiveEntry(entry);
>       IOUtils.copy(new FileInputStream(outFiles[j]), os);
>       os.closeArchiveEntry();
>     }
>     os.finish();
>     os.close();
>   }
> }}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to