Hi, We had some issues building cpio-2.11, some of which I can see are already fixed in git.
1) Should use the Gnulib strtoumax module as strtoumax is used in rmt.c. 2) Allow compilation with c89 compilers by moving declaration after statement in makepath.c before statement. 3) One of our systems (HPPA/HPUX 10.20) has a compiler that does not know how to pack structs, however, on all the systems that we build for, the cpio structs are the correct size when naturally aligned, including hpux 10.20. To work around this, we patched am/pack.m4 to first check if packing is required using a compile time test, and then only look for a way to pack structs if needed. I tested that this works with Fedora's arm-gp2x-linux cross-compiler, and indeed cpio_cv_explicit_pack gets set to yes for that build. Patches attached. Peter -- Peter O'Gorman [email protected]
>From a5635da43c1287618107549e2128a4d2a6f03d4d Mon Sep 17 00:00:00 2001 From: Peter O'Gorman <[email protected]> Date: Mon, 6 Sep 2010 17:15:10 -0500 Subject: [PATCH 1/3] Use the Gnulib strtoumax module * gnulib.modules: strtoumax is used by rmt.c, but isn't portable. --- gnulib.modules | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gnulib.modules b/gnulib.modules index f165870..981dbb9 100644 --- a/gnulib.modules +++ b/gnulib.modules @@ -24,6 +24,7 @@ stdbool stdint stpcpy strerror +strtoumax unlocked-io utimens xalloc -- 1.7.0.1
>From 32130143e9b3e5e64c5df35266dd38a4e252eabc Mon Sep 17 00:00:00 2001 From: Peter O'Gorman <[email protected]> Date: Mon, 6 Sep 2010 17:19:03 -0500 Subject: [PATCH 2/3] Fix c99 decl after statement. * src/makepath.c (make_path): Move slash declaration. --- src/makepath.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/makepath.c b/src/makepath.c index 7631772..83f9c25 100644 --- a/src/makepath.c +++ b/src/makepath.c @@ -65,10 +65,10 @@ make_path (char *argpath, if (stat (dirpath, &stats)) { + char *slash = dirpath; tmpmode = MODE_RWX & ~ newdir_umask; invert_permissions = we_are_root ? 0 : MODE_WXUSR & ~ tmpmode; - char *slash = dirpath; while (*slash == '/') slash++; while ((slash = strchr (slash, '/'))) -- 1.7.0.1
>From 9ad02f1a789a74678d429085199e19b04e8b844a Mon Sep 17 00:00:00 2001 From: Peter O'Gorman <[email protected]> Date: Mon, 6 Sep 2010 17:20:44 -0500 Subject: [PATCH 3/3] Check if struct packing is required. * am/pack.m4: Check if naturally aligned structs are the correct size. * src/cpiohdr.h: define ATTRIB_PACKED to be empty if not using the attribute. --- am/pack.m4 | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cpiohdr.h | 2 + 2 files changed, 60 insertions(+), 0 deletions(-) diff --git a/am/pack.m4 b/am/pack.m4 index c03c948..85ee6ea 100644 --- a/am/pack.m4 +++ b/am/pack.m4 @@ -16,6 +16,63 @@ # CPIO_PACKED_STRUCTS is based on code from ClamAV AC_DEFUN([CPIO_PACKED_STRUCTS],[ + AC_MSG_CHECKING([if we need to explicitly pack some cpio structs]) + AC_CACHE_VAL([cpio_cv_explicit_pack],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +struct old_cpio_header +{ + unsigned short c_magic; + unsigned short c_dev; + unsigned short c_ino; + unsigned short c_mode; + unsigned short c_uid; + unsigned short c_gid; + unsigned short c_nlink; + unsigned short c_rdev; + unsigned short c_mtimes[2]; + unsigned short c_namesize; + unsigned short c_filesizes[2]; +}; +struct old_ascii_header +{ + char c_magic[6]; + char c_dev[6]; + char c_ino[6]; + char c_mode[6]; + char c_uid[6]; + char c_gid[6]; + char c_nlink[6]; + char c_rdev[6]; + char c_mtime[11]; + char c_namesize[6]; + char c_filesize[11]; +}; +struct new_ascii_header +{ + char c_magic[6]; + char c_ino[8]; + char c_mode[8]; + char c_uid[8]; + char c_gid[8]; + char c_nlink[8]; + char c_mtime[8]; + char c_filesize[8]; + char c_dev_maj[8]; + char c_dev_min[8]; + char c_rdev_maj[8]; + char c_rdev_min[8]; + char c_namesize[8]; + char c_chksum[8]; +}; +]],[[ +char a[sizeof(struct new_ascii_header)==110?1:-1]; +char b[sizeof(struct old_ascii_header)==76?1:-1]; +char c[sizeof(struct old_cpio_header)==26?1:-1]; +return sizeof(a) + sizeof(b) + sizeof(c) == 3?0:1; +]])],[cpio_cv_explicit_pack=no],[cpio_cv_explicit_pack=yes])]) +AC_MSG_RESULT($cpio_cv_explicit_pack) + +if test "$cpio_cv_explicit_pack" = yes; then dnl check for __attribute__((packed)) AC_MSG_CHECKING([for structure packing via __attribute__((packed))]) AC_CACHE_VAL(cpio_cv_have_attrib_packed,[ @@ -64,4 +121,5 @@ AC_DEFUN([CPIO_PACKED_STRUCTS],[ if test "$have_attrib_packed" = yes; then AC_DEFINE(HAVE_ATTRIB_PACKED, 1, [attrib packed]) fi +fi ]) diff --git a/src/cpiohdr.h b/src/cpiohdr.h index 86ec988..5367fe9 100644 --- a/src/cpiohdr.h +++ b/src/cpiohdr.h @@ -24,6 +24,8 @@ # ifdef HAVE_ATTRIB_PACKED # define ATTRIB_PACKED __attribute__((packed)) +# else +# define ATTRIB_PACKED # endif # ifdef HAVE_PRAGMA_PACK -- 1.7.0.1
