Re: 4.6.0-pre1: cpio errors on RPMs



Hello, Moritz!

Try copying CONTENTS.cpio to a local filesystem and then open it there.

I did that now. It shows the same problem. On the other hand, "cpio
-itv < /path/to/local/CONTENTS.cpio" is okay. Am I now using mc's
internal cpio code on this local copy?

Yes, you are using the internal code, and it must have a problem, either 
because it was miscompiled on your platform, or because CONTENTS.cpio has 
something in it that mc doesn't understand.

Platform specific problem is more likely.  You have a 64-bit compiler,
right?  It seems to me that cpio.c in the mc sources uses "long" and
"unsigned long" where it should be using u32.  Whether it's your problem
or not, it should be fixed.

Please test this patch.  It can produce some compile warnings (I'll fix
them later), but it should fix reading of cpio archives on 64-bit
systems).

================================
--- vfs/cpio.c
+++ vfs/cpio.c
@@ -65,24 +65,24 @@ struct old_cpio_header
 struct new_cpio_header
 {
   unsigned short c_magic;
-  unsigned long c_ino;
-  unsigned long c_mode;
-  unsigned long c_uid;
-  unsigned long c_gid;
-  unsigned long c_nlink;
-  unsigned long c_mtime;
-  unsigned long c_filesize;
-  long c_dev;
-  long c_devmin;
-  long c_rdev;
-  long c_rdevmin;
-  unsigned long c_namesize;
-  unsigned long c_chksum;
+  unsigned int c_ino;
+  unsigned int c_mode;
+  unsigned int c_uid;
+  unsigned int c_gid;
+  unsigned int c_nlink;
+  unsigned int c_mtime;
+  unsigned int c_filesize;
+  int c_dev;
+  int c_devmin;
+  int c_rdev;
+  int c_rdevmin;
+  unsigned int c_namesize;
+  unsigned int c_chksum;
 };
 
 struct defer_inode {
     struct defer_inode *next;
-    unsigned long inumber;
+    unsigned int inumber;
     unsigned short device;
     vfs_s_inode *inode;
 };
@@ -304,7 +304,7 @@ static int cpio_read_oldc_head(vfs *me, 
     CPIO_POS(super) += len;
     buf[HEAD_LENGTH] = 0;
 
-    if(sscanf(buf, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo",
+    if(sscanf(buf, "070707%6o%6o%6o%6o%6o%6o%6o%11o%6o%11o",
              &hd.c_dev, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
              &hd.c_nlink, &hd.c_rdev, &hd.c_mtime,
              &hd.c_namesize, &hd.c_filesize) < 10) {
@@ -353,7 +353,7 @@ static int cpio_read_crc_head(vfs *me, v
     CPIO_POS(super) += len;
     buf[HEAD_LENGTH] = 0;
 
-    if(sscanf(buf, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx",
+    if(sscanf(buf, "%6ho%8x%8x%8x%8x%8x%8x%8x%8x%8x%8x%8x%8x%8x",
              &hd.c_magic, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
              &hd.c_nlink,  &hd.c_mtime, &hd.c_filesize,
              &hd.c_dev, &hd.c_devmin, &hd.c_rdev, &hd.c_rdevmin,
================================

-- 
Regards,
Pavel Roskin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]