Bug 226

Summary: cpio old portable ascii (-oc) format wrong due to long long dev_t
Product: [Retired] Red Hat Linux Reporter: sra
Component: cpioAssignee: bero
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 5.2CC: dyocum, hartr, justink
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1998-12-06 01:53:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sra 1998-11-29 22:48:43 UTC
During testing of our software distribution product, I
noticed that cpio was producing archives that were
unreadable by it or other cpio programs when the -oc option
was used and when files had large inode numbers. Upon
investigation, I determined that the printf used to create
the ascii header is not properly dealing with two parameters
wich are declared as type dev_t. Since dev_t is now declared
as type "long long" the stack to the variable arguments code
is not being interpreted correctly. I fixed it for our use
by casting the dev and rdev parameters to int. I am not sure
if that is correct in the general case. My patch is below.

--- cpio-2.4.2.orig/copyout.c   Wed Jan 10 10:10:45 1996
+++ cpio-2.4.2/copyout.c        Thu Nov 19 16:08:36 1998
@@ -113,10 +113,10 @@

       sprintf (ascii_header,

"%06o%06o%06lo%06lo%06lo%06lo%06lo%06o%011lo%06lo%011lo",
-              file_hdr->c_magic & 0xFFFF, dev & 0xFFFF,
+              file_hdr->c_magic & 0xFFFF, (int) (dev &
0xFFFF),
               file_hdr->c_ino & 0xFFFF, file_hdr->c_mode &
0xFFFF,
               file_hdr->c_uid & 0xFFFF, file_hdr->c_gid &
0xFFFF,
-              file_hdr->c_nlink & 0xFFFF, rdev & 0xFFFF,
+              file_hdr->c_nlink & 0xFFFF, (int) (rdev &
0xFFFF),
               file_hdr->c_mtime, file_hdr->c_namesize &
0xFFFF,
               file_hdr->c_filesize);
       tape_buffered_write (ascii_header, out_des, 76L);

Comment 1 Preston Brown 1998-11-30 18:43:59 UTC
jeff I think this relates to the other cpio stuff...

Comment 2 Jeff Johnson 1998-12-06 01:53:59 UTC
Fixed in cpio-2.4.2-11. This problem is closely related to bug #80
and provides an alternative fix for the failure of

	find /any/dir | cpio -o -Hodc | cpio -itv -H odc

Comment 3 Jeff Johnson 1999-04-23 15:15:59 UTC
*** Bug 2336 has been marked as a duplicate of this bug. ***

Forwarded message follows from Chris Green.

Dan

******************

Hi,

Some extremely detailed work by Randy [Herber] in
determining why a Linux backup using cpio failed has found a
bug in the cpio package for any rpm below patchlevel 11
(which we have determined fixes the bug). The rpm which
comes with FRH521 [i.e., Red Hat 5.2] is at patchlevel 9,
which also has the bug.

Basically, if one uses

cpio -Hodc -o

(the most portable way to output information via cpio), then
the header information before each cpio item has the
namesize and filesize attributes missing -- effectively a
showstopper to having the backup read back in any usable
fashion.

<snip>

Thanks,
Chris.

--
Chris Green. HEP, Purdue University. CDF SVXII project.
Based at Fermilab. MAIL greenc; PHONE (630)
840-2308