This one time, at band camp, Aurelien Jarno said: > > cpio uses structures to map the file header, and the whole structure is > read at once. This does not work on all architectures (like ARM), as > they may use padding. The structures should be declared as packed to > avoid padding. > > You will find a patch below to fix the problem.
(disclaimer: not related to cpio in any way) This patch certainly looks good enough to be a dpatch or whatever system is in use, but I just wanted to mention that before pushing this upstream, you might want to add tests for how to pack the structures depending on compiler capabilities. This is the first example I happened on (clamav, from configure.in) dnl check for __attribute__((packed)) AC_MSG_CHECKING([for structure packing via __attribute__((packed))]) AC_CACHE_VAL(have_attrib_packed,[ AC_TRY_COMPILE(, [struct { int i __attribute__((packed)); } s; ], [have_attrib_packed=yes], [have_attrib_packed=no]) ]) AC_MSG_RESULT($have_attrib_packed) if test "$have_attrib_packed" = no; then AC_MSG_CHECKING(for structure packing via pragma) AC_CACHE_VAL(have_pragma_pack,[ AC_TRY_RUN([int main(int argc, char **argv) { #pragma pack(1) /* has to be in column 1 ! */ struct { char c; long l; } s; return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ], [have_pragma_pack=yes], [have_pragma_pack=no]) ]) AC_MSG_RESULT($have_pragma_pack) if test "$have_pragma_pack" = yes; then AC_DEFINE(HAVE_PRAGMA_PACK, 1, "pragma pack") else AC_MSG_CHECKING(for structure packing via hppa/hp-ux pragma) AC_CACHE_VAL(have_pragma_pack_hpux,[ AC_TRY_RUN([ /* hppa/hp-ux wants pragma outside of function */ #pragma pack 1 /* has to be in column 1 ! */ struct { char c; long l; } s; int main(int argc, char **argv) { return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ], [have_pragma_pack_hpux=yes], [have_pragma_pack_hpux=no]) ]) AC_MSG_RESULT($have_pragma_pack_hpux) AC_DEFINE(HAVE_PRAGMA_PACK_HPPA, 1, "pragma pack hppa/hp-ux style") fi fi if test "$have_attrib_packed" = no -a "$have_pragma_pack" = no -a "$have_pragma_pack_hpux" = no; then AC_MSG_ERROR(Need to know how to pack structures with this compiler) fi if test "$have_attrib_packed" = yes; then AC_DEFINE(HAVE_ATTRIB_PACKED, 1, [attrib packed]) fi And then later test for HAVE_ATTRIB_PACKED, HAVE_PRAGMA_PACK or HAVE_PRAGMA_PACK_HPPA. Take care, -- ----------------------------------------------------------------- | ,''`. Stephen Gran | | : :' : [EMAIL PROTECTED] | | `. `' Debian user, admin, and developer | | `- http://www.debian.org | -----------------------------------------------------------------
signature.asc
Description: Digital signature