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