pax-3.4_fix_for_x32.patch 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. Upstream-Status: Pending
  2. Author: H.J. Lu <hjl.tools@gmail.com>
  3. Date: Tue Dec 6 10:34:53 2011 -0800
  4. Fix pax-3.4 build for x32
  5. off_t is 8byte for x32. We need to check both _FILE_OFFSET_BITS and
  6. size of off_t to see if file offset is 64bit. This patch adds
  7. AC_CHECK_SIZEOF(off_t) and checks SIZEOF_OFF_T == 8.
  8. Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com> 2011/12/06
  9. Index: pax-3.4/configure.in
  10. ===================================================================
  11. --- pax-3.4.orig/configure.in
  12. +++ pax-3.4/configure.in
  13. @@ -33,4 +33,7 @@ dnl Checks for header files.
  14. dnl Checks for typedefs, structures, and compiler characteristics.
  15. AC_C_CONST
  16. +AC_CHECK_SIZEOF(off_t)
  17. +AC_CHECK_SIZEOF(long)
  18. +
  19. AC_OUTPUT([Makefile lib/Makefile src/Makefile])
  20. Index: pax-3.4/src/ar_io.c
  21. ===================================================================
  22. --- pax-3.4.orig/src/ar_io.c
  23. +++ pax-3.4/src/ar_io.c
  24. @@ -378,7 +378,8 @@ ar_close(void)
  25. * could have written anything yet.
  26. */
  27. if (frmt == NULL) {
  28. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  29. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  30. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  31. (void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n",
  32. #else
  33. (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",
  34. @@ -391,7 +392,8 @@ ar_close(void)
  35. if (strcmp(NM_CPIO, argv0) == 0)
  36. (void)fprintf(listf,
  37. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  38. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  39. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  40. "%qu blocks\n",
  41. #else
  42. "%lu blocks\n",
  43. @@ -399,7 +401,8 @@ ar_close(void)
  44. (rdcnt ? rdcnt : wrcnt) / 5120);
  45. else if (strcmp(NM_TAR, argv0) != 0)
  46. (void)fprintf(listf,
  47. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  48. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  49. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  50. "%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n",
  51. #else
  52. "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",
  53. Index: pax-3.4/src/cpio.c
  54. ===================================================================
  55. --- pax-3.4.orig/src/cpio.c
  56. +++ pax-3.4/src/cpio.c
  57. @@ -218,7 +218,8 @@ rd_ln_nm (ARCHD *arcn)
  58. */
  59. if ((arcn->sb.st_size == 0) ||
  60. (arcn->sb.st_size >= (off_t) sizeof(arcn->ln_name))) {
  61. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  62. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  63. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  64. paxwarn (1, "Cpio link name length is invalid: %qu",
  65. arcn->sb.st_size);
  66. #else
  67. Index: pax-3.4/src/gen_subs.c
  68. ===================================================================
  69. --- pax-3.4.orig/src/gen_subs.c
  70. +++ pax-3.4/src/gen_subs.c
  71. @@ -133,7 +133,8 @@ ls_list (ARCHD *arcn, time_t now, FILE *
  72. * print device id's for devices, or sizes for other nodes
  73. */
  74. if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
  75. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  76. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  77. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  78. (void) fprintf (fp, "%4lu,%4lu ", (unsigned long) MAJOR (sbp->st_rdev),
  79. (unsigned long) MINOR (sbp->st_rdev));
  80. #else
  81. @@ -142,7 +143,8 @@ ls_list (ARCHD *arcn, time_t now, FILE *
  82. #endif
  83. else
  84. {
  85. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  86. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  87. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  88. (void) fprintf (fp, "%9qu ", sbp->st_size);
  89. #else
  90. (void) fprintf (fp, "%9lu ", sbp->st_size);
  91. @@ -334,7 +336,8 @@ ul_asc (u_long val, char *str, int len,
  92. return (0);
  93. }
  94. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  95. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  96. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  97. /*
  98. * asc_uqd()
  99. * convert hex/octal character string into a u_quad_t. We do not have to
  100. Index: pax-3.4/src/options.c
  101. ===================================================================
  102. --- pax-3.4.orig/src/options.c
  103. +++ pax-3.4/src/options.c
  104. @@ -1545,7 +1545,8 @@ str_offt (char *val)
  105. char *expr;
  106. off_t num, t;
  107. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  108. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  109. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  110. num = strtoq (val, &expr, 0);
  111. if ((num == LONG_LONG_MAX) || (num <= 0) || (expr == val))
  112. #else
  113. Index: pax-3.4/src/tar.c
  114. ===================================================================
  115. --- pax-3.4.orig/src/tar.c
  116. +++ pax-3.4/src/tar.c
  117. @@ -58,7 +58,8 @@
  118. static unsigned long tar_chksm (char *, int);
  119. static char *name_split (char *, int);
  120. static int ul_oct (u_long, char *, int, int);
  121. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  122. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  123. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  124. static int uqd_oct (u_quad_t, char *, int, int);
  125. #endif
  126. @@ -196,7 +197,8 @@ ul_oct (u_long val, register char *str,
  127. return (0);
  128. }
  129. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  130. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  131. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  132. /*
  133. * uqd_oct()
  134. * convert an u_quad_t to an octal string. one of many oddball field
  135. @@ -427,7 +429,8 @@ tar_rd (ARCHD *arcn, char *buf)
  136. 0xfff);
  137. arcn->sb.st_uid = (uid_t) asc_ul (hd->uid, sizeof (hd->uid), OCT);
  138. arcn->sb.st_gid = (gid_t) asc_ul (hd->gid, sizeof (hd->gid), OCT);
  139. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  140. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  141. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  142. arcn->sb.st_size = (off_t) asc_uqd (hd->size, sizeof (hd->size), OCT);
  143. #else
  144. arcn->sb.st_size = (off_t) asc_ul (hd->size, sizeof (hd->size), OCT);
  145. @@ -659,7 +662,8 @@ tar_wr (register ARCHD * arcn)
  146. * data follows this file, so set the pad
  147. */
  148. hd->linkflag = AREGTYPE;
  149. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  150. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  151. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  152. if (uqd_oct ((u_quad_t) arcn->sb.st_size, hd->size,
  153. sizeof (hd->size), 1))
  154. #else
  155. @@ -834,7 +838,8 @@ ustar_rd (ARCHD *arcn, char *buf)
  156. */
  157. arcn->sb.st_mode = (mode_t) (asc_ul (hd->mode, sizeof (hd->mode), OCT) &
  158. 0xfff);
  159. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  160. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  161. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  162. arcn->sb.st_size = (off_t) asc_uqd (hd->size, sizeof (hd->size), OCT);
  163. #else
  164. arcn->sb.st_size = (off_t) asc_ul (hd->size, sizeof (hd->size), OCT);
  165. @@ -1081,7 +1086,8 @@ ustar_wr (register ARCHD * arcn)
  166. else
  167. hd->typeflag = REGTYPE;
  168. arcn->pad = TAR_PAD (arcn->sb.st_size);
  169. -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
  170. +#if (SIZEOF_LONG == 4 && SIZEOF_OFF_T == 8) \
  171. + || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  172. if (uqd_oct ((u_quad_t) arcn->sb.st_size, hd->size,
  173. sizeof (hd->size), 3))
  174. {