squashfs-bsd.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. --- squashfs4.0~/squashfs-tools/mksquashfs.c Sun Apr 5 21:22:24 2009
  2. +++ squashfs4.0/squashfs-tools/mksquashfs.c Fri Jan 7 20:36:08 2011
  3. @@ -24,6 +24,7 @@
  4. #define FALSE 0
  5. #define TRUE 1
  6. +#include <sys/param.h>
  7. #include <pwd.h>
  8. #include <grp.h>
  9. #include <time.h>
  10. @@ -3688,23 +3689,9 @@ void initialise_threads()
  11. signal(SIGUSR1, sigusr1_handler);
  12. if(processors == -1) {
  13. -#ifndef linux
  14. - int mib[2];
  15. - size_t len = sizeof(processors);
  16. -
  17. - mib[0] = CTL_HW;
  18. -#ifdef HW_AVAILCPU
  19. - mib[1] = HW_AVAILCPU;
  20. +#if defined(BSD)
  21. + processors = 1;
  22. #else
  23. - mib[1] = HW_NCPU;
  24. -#endif
  25. -
  26. - if(sysctl(mib, 2, &processors, &len, NULL, 0) == -1) {
  27. - ERROR("Failed to get number of available processors. "
  28. - "Defaulting to 1\n");
  29. - processors = 1;
  30. - }
  31. -#else
  32. processors = get_nprocs();
  33. #endif
  34. }
  35. @@ -3974,9 +3961,15 @@ int excluded(struct pathnames *paths, ch
  36. int match = use_regex ?
  37. regexec(path->name[i].preg, name, (size_t) 0,
  38. NULL, 0) == 0 :
  39. +#if defined(BSD)
  40. fnmatch(path->name[i].name, name,
  41. + FNM_PATHNAME|FNM_PERIOD) ==
  42. + 0;
  43. +#else
  44. + fnmatch(path->name[i].name, name,
  45. FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) ==
  46. 0;
  47. +#endif
  48. if(match && path->name[i].paths == NULL) {
  49. /* match on a leaf component, any subdirectories
  50. --- squashfs4.0~/squashfs-tools/mksquashfs.h Thu Feb 19 18:30:44 2009
  51. +++ squashfs4.0/squashfs-tools/mksquashfs.h Fri Jan 7 20:40:01 2011
  52. @@ -24,7 +24,9 @@
  53. *
  54. */
  55. -#if __BYTE_ORDER == __BIG_ENDIAN
  56. +#ifndef __BYTE_ORDER
  57. +#error Which endianness? __BYTE_ORDER is not defined.
  58. +#elif __BYTE_ORDER == __BIG_ENDIAN
  59. #define SQUASHFS_SWAP_SHORTS(s, d, n) swap_le16_num(s, d, n)
  60. #define SQUASHFS_SWAP_INTS(s, d, n) swap_le32_num(s, d, n)
  61. #define SQUASHFS_SWAP_LONG_LONGS(s, d, n) swap_le64_num(s, d, n)
  62. @@ -34,11 +36,13 @@
  63. #define SWAP_LE64(s, d, field) swap_le64(&((s)->field), &((d)->field))
  64. #define SWAP_LES16(s, d, field) swap_le16((unsigned short *) &((s)->field), \
  65. (unsigned short *) &((d)->field))
  66. -#else
  67. +#elif __BYTE_ORDER == __LITTLE_ENDIAN
  68. #define SQUASHFS_MEMCPY(s, d, n) memcpy(d, s, n)
  69. #define SQUASHFS_SWAP_SHORTS(s, d, n) memcpy(d, s, n * sizeof(short))
  70. #define SQUASHFS_SWAP_INTS(s, d, n) memcpy(d, s, n * sizeof(int))
  71. #define SQUASHFS_SWAP_LONG_LONGS(s, d, n) \
  72. memcpy(d, s, n * sizeof(long long))
  73. +#else
  74. +#error Which endianness (PDP endian? Worse?)
  75. #endif
  76. #endif
  77. --- squashfs4.0~/squashfs-tools/pseudo.c Sun Apr 5 02:01:34 2009
  78. +++ squashfs4.0/squashfs-tools/pseudo.c Fri Jan 7 20:35:31 2011
  79. @@ -30,6 +30,11 @@
  80. #include <string.h>
  81. #include <stdlib.h>
  82. #include <sys/types.h>
  83. +#include <sys/param.h>
  84. +
  85. +#if defined(BSD)
  86. +#include <sys/stat.h>
  87. +#endif
  88. #include "pseudo.h"
  89. --- squashfs4.0~/squashfs-tools/read_fs.h Thu Feb 19 18:28:56 2009
  90. +++ squashfs4.0/squashfs-tools/read_fs.h Fri Jan 7 20:40:00 2011
  91. @@ -24,7 +24,9 @@
  92. *
  93. */
  94. -#if __BYTE_ORDER == __BIG_ENDIAN
  95. +#ifndef __BYTE_ORDER
  96. +#error Which endianness? __BYTE_ORDER is not defined.
  97. +#elif __BYTE_ORDER == __BIG_ENDIAN
  98. #define SQUASHFS_SWAP_SHORTS(d, s, n) swap_le16_num(s, d, n)
  99. #define SQUASHFS_SWAP_INTS(d, s, n) swap_le32_num(s, d, n)
  100. #define SQUASHFS_SWAP_LONG_LONGS(d, s, n) swap_le64_num(s, d, n)
  101. @@ -34,11 +36,13 @@
  102. #define SWAP_LE64(d, s, field) swap_le64(&((s)->field), &((d)->field))
  103. #define SWAP_LES16(d, s, field) swap_le16((unsigned short *) &((s)->field), \
  104. (unsigned short *) &((d)->field))
  105. -#else
  106. +#elif __BYTE_ORDER == __LITTLE_ENDIAN
  107. #define SQUASHFS_MEMCPY(d, s, n) memcpy(d, s, n)
  108. #define SQUASHFS_SWAP_SHORTS(d, s, n) memcpy(d, s, n * sizeof(short))
  109. #define SQUASHFS_SWAP_INTS(d, s, n) memcpy(d, s, n * sizeof(int))
  110. #define SQUASHFS_SWAP_LONG_LONGS(d, s, n) \
  111. memcpy(d, s, n * sizeof(long long))
  112. +#else
  113. +#error Which endianness (PDP endian? Worse?)
  114. #endif
  115. #endif
  116. --- squashfs4.0~/squashfs-tools/squashfs_compat.h Mon Mar 16 04:27:03 2009
  117. +++ squashfs4.0/squashfs-tools/squashfs_compat.h Fri Jan 7 20:39:59 2011
  118. @@ -768,12 +768,16 @@ typedef union squashfs_inode_header_2 sq
  119. * macros used to swap each structure entry, taking into account
  120. * bitfields and different bitfield placing conventions on differing architectures
  121. */
  122. -#if __BYTE_ORDER == __BIG_ENDIAN
  123. +#ifndef __BYTE_ORDER
  124. +#error Which endianness? __BYTE_ORDER is not defined.
  125. +#elif __BYTE_ORDER == __BIG_ENDIAN
  126. /* convert from big endian to little endian */
  127. #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
  128. -#else
  129. +#elif __BYTE_ORDER == __LITTLE_ENDIAN
  130. /* convert from little endian to big endian */
  131. #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
  132. +#else
  133. +#error Which endianness (PDP endian? Worse?)
  134. #endif
  135. #define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
  136. --- squashfs4.0~/squashfs-tools/squashfs_swap.h Fri Feb 20 19:41:56 2009
  137. +++ squashfs4.0/squashfs-tools/squashfs_swap.h Fri Jan 7 20:39:59 2011
  138. @@ -27,7 +27,9 @@
  139. * macros to convert each stucture from big endian to little endian
  140. */
  141. -#if __BYTE_ORDER == __BIG_ENDIAN
  142. +#ifndef __BYTE_ORDER
  143. +#error Which endianness? __BYTE_ORDER is not defined.
  144. +#elif __BYTE_ORDER == __BIG_ENDIAN
  145. extern void swap_le16(unsigned short *, unsigned short *);
  146. extern void swap_le32(unsigned int *, unsigned int *);
  147. extern void swap_le64(long long *, long long *);
  148. @@ -256,7 +258,7 @@ extern void inswap_le64_num(long long *,
  149. #define SQUASHFS_INSWAP_SHORTS(s, n) inswap_le16_num(s, n)
  150. #define SQUASHFS_INSWAP_INTS(s, n) inswap_le32_num(s, n)
  151. #define SQUASHFS_INSWAP_LONG_LONGS(s, n) inswap_le64_num(s, n)
  152. -#else
  153. +#elif __BYTE_ORDER == __LITTLE_ENDIAN
  154. #define SQUASHFS_SWAP_SUPER_BLOCK(s, d) \
  155. SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
  156. #define SQUASHFS_SWAP_DIR_INDEX(s, d) \
  157. @@ -308,5 +310,7 @@ extern void inswap_le64_num(long long *,
  158. #define SQUASHFS_INSWAP_SHORTS(s, n)
  159. #define SQUASHFS_INSWAP_INTS(s, n)
  160. #define SQUASHFS_INSWAP_LONG_LONGS(s, n)
  161. +#else
  162. +#error Which endianness (PDP endian? Worse?)
  163. #endif
  164. #endif
  165. --- squashfs4.0~/squashfs-tools/swap.c Thu Mar 26 04:39:52 2009
  166. +++ squashfs4.0/squashfs-tools/swap.c Fri Jan 7 20:40:00 2011
  167. @@ -27,7 +27,9 @@
  168. #include <endian.h>
  169. #endif
  170. -#if __BYTE_ORDER == __BIG_ENDIAN
  171. +#ifndef __BYTE_ORDER
  172. +#error Which endianness? __BYTE_ORDER is not defined.
  173. +#elif __BYTE_ORDER == __BIG_ENDIAN
  174. void swap_le16(unsigned short *src, unsigned short *dest)
  175. {
  176. unsigned char *s = (unsigned char *) src;
  177. @@ -120,4 +122,6 @@ void inswap_le##BITS##_num(TYPE *s, int
  178. INSWAP_LE_NUM(16, unsigned short)
  179. INSWAP_LE_NUM(32, unsigned int)
  180. INSWAP_LE_NUM(64, long long)
  181. +#elif __BYTE_ORDER != __LITTLE_ENDIAN
  182. +#error Which endianness (PDP endian? Worse?)
  183. #endif
  184. --- squashfs4.0~/squashfs-tools/unsquashfs.c Sun Apr 5 21:22:42 2009
  185. +++ squashfs4.0/squashfs-tools/unsquashfs.c Fri Jan 7 20:35:31 2011
  186. @@ -21,6 +21,8 @@
  187. * unsquashfs.c
  188. */
  189. +#include <sys/param.h>
  190. +
  191. #include "unsquashfs.h"
  192. #include "squashfs_swap.h"
  193. #include "squashfs_compat.h"
  194. @@ -1193,10 +1195,17 @@ int matches(struct pathnames *paths, cha
  195. struct pathname *path = paths->path[n];
  196. for(i = 0; i < path->names; i++) {
  197. int match = use_regex ?
  198. +#if defined(BSD)
  199. regexec(path->name[i].preg, name, (size_t) 0,
  200. NULL, 0) == 0 : fnmatch(path->name[i].name,
  201. + name, FNM_PATHNAME|FNM_PERIOD) ==
  202. + 0;
  203. +#else
  204. + regexec(path->name[i].preg, name, (size_t) 0,
  205. + NULL, 0) == 0 : fnmatch(path->name[i].name,
  206. name, FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) ==
  207. 0;
  208. +#endif
  209. if(match && path->name[i].paths == NULL)
  210. /*
  211. * match on a leaf component, any subdirectories
  212. @@ -1795,21 +1804,7 @@ void initialise_threads(int fragment_buf
  213. if(processors == -1) {
  214. #ifndef linux
  215. - int mib[2];
  216. - size_t len = sizeof(processors);
  217. -
  218. - mib[0] = CTL_HW;
  219. -#ifdef HW_AVAILCPU
  220. - mib[1] = HW_AVAILCPU;
  221. -#else
  222. - mib[1] = HW_NCPU;
  223. -#endif
  224. -
  225. - if(sysctl(mib, 2, &processors, &len, NULL, 0) == -1) {
  226. - ERROR("Failed to get number of available processors. "
  227. - "Defaulting to 1\n");
  228. - processors = 1;
  229. - }
  230. + processors = 1;
  231. #else
  232. processors = get_nprocs();
  233. #endif