darwin.patch 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. diff -Nur mtd-utils-1.5.0.orig/common.mk mtd-utils-1.5.0/common.mk
  2. --- mtd-utils-1.5.0.orig/common.mk 2012-05-07 09:19:39.000000000 +0200
  3. +++ mtd-utils-1.5.0/common.mk 2014-03-22 11:25:31.000000000 +0100
  4. @@ -13,8 +13,6 @@
  5. $(call cc-option,-Wwrite-strings) \
  6. $(call cc-option,-Wno-sign-compare)
  7. CFLAGS += $(WFLAGS)
  8. -SECTION_CFLAGS := $(call cc-option,-ffunction-sections -fdata-sections -Wl$(comma)--gc-sections)
  9. -CFLAGS += $(SECTION_CFLAGS)
  10. ifneq ($(WITHOUT_LARGEFILE), 1)
  11. CPPFLAGS += -D_FILE_OFFSET_BITS=64
  12. diff -Nur mtd-utils-1.5.0.orig/compr_lzo.c mtd-utils-1.5.0/compr_lzo.c
  13. --- mtd-utils-1.5.0.orig/compr_lzo.c 2012-05-07 09:19:39.000000000 +0200
  14. +++ mtd-utils-1.5.0/compr_lzo.c 2014-03-22 11:12:06.000000000 +0100
  15. @@ -26,7 +26,6 @@
  16. #include <string.h>
  17. #ifndef WITHOUT_LZO
  18. -#include <asm/types.h>
  19. #include <linux/jffs2.h>
  20. #include <lzo/lzo1x.h>
  21. #include "compr.h"
  22. diff -Nur mtd-utils-1.5.0.orig/compr_zlib.c mtd-utils-1.5.0/compr_zlib.c
  23. --- mtd-utils-1.5.0.orig/compr_zlib.c 2012-05-07 09:19:39.000000000 +0200
  24. +++ mtd-utils-1.5.0/compr_zlib.c 2014-03-22 11:11:57.000000000 +0100
  25. @@ -39,7 +39,6 @@
  26. #include <zlib.h>
  27. #undef crc32
  28. #include <stdio.h>
  29. -#include <asm/types.h>
  30. #include <linux/jffs2.h>
  31. #include "common.h"
  32. #include "compr.h"
  33. diff -Nur mtd-utils-1.5.0.orig/include/byteswap.h mtd-utils-1.5.0/include/byteswap.h
  34. --- mtd-utils-1.5.0.orig/include/byteswap.h 1970-01-01 01:00:00.000000000 +0100
  35. +++ mtd-utils-1.5.0/include/byteswap.h 2014-03-22 10:52:15.000000000 +0100
  36. @@ -0,0 +1,25 @@
  37. +#ifndef _BYTESWAP_H
  38. +#define _BYTESWAP_H
  39. +
  40. +#include <stdint.h>
  41. +
  42. +static __inline uint16_t __bswap_16(uint16_t __x)
  43. +{
  44. + return __x<<8 | __x>>8;
  45. +}
  46. +
  47. +static __inline uint32_t __bswap_32(uint32_t __x)
  48. +{
  49. + return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
  50. +}
  51. +
  52. +static __inline uint64_t __bswap_64(uint64_t __x)
  53. +{
  54. + return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
  55. +}
  56. +
  57. +#define bswap_16(x) __bswap_16(x)
  58. +#define bswap_32(x) __bswap_32(x)
  59. +#define bswap_64(x) __bswap_64(x)
  60. +
  61. +#endif
  62. diff -Nur mtd-utils-1.5.0.orig/include/endian.h mtd-utils-1.5.0/include/endian.h
  63. --- mtd-utils-1.5.0.orig/include/endian.h 1970-01-01 01:00:00.000000000 +0100
  64. +++ mtd-utils-1.5.0/include/endian.h 2014-03-22 11:09:57.000000000 +0100
  65. @@ -0,0 +1,20 @@
  66. +#ifndef _ENDIAN_H
  67. +#define _ENDIAN_H
  68. +
  69. +#ifndef __BIG_ENDIAN
  70. +#define __BIG_ENDIAN 4321
  71. +#endif
  72. +
  73. + #ifndef __LITTLE_ENDIAN
  74. + #define __LITTLE_ENDIAN 1234
  75. + #endif
  76. +
  77. +#ifndef __BYTE_ORDER
  78. +#define __BYTE_ORDER __LITTLE_ENDIAN
  79. +#endif
  80. +
  81. +#ifndef BYTE_ORDER
  82. +#define BYTE_ORDER __LITTLE_ENDIAN
  83. +#endif
  84. +
  85. +#endif
  86. diff -Nur mtd-utils-1.5.0.orig/include/linux/types.h mtd-utils-1.5.0/include/linux/types.h
  87. --- mtd-utils-1.5.0.orig/include/linux/types.h 1970-01-01 01:00:00.000000000 +0100
  88. +++ mtd-utils-1.5.0/include/linux/types.h 2014-03-22 11:17:12.000000000 +0100
  89. @@ -0,0 +1,18 @@
  90. +#ifndef _LINUX_TYPES_H
  91. +#define _LINUX_TYPES_H
  92. +
  93. +#include <mtd/ubi-media.h>
  94. +
  95. +typedef uint16_t __u16;
  96. +typedef uint32_t __u32;
  97. +typedef uint64_t __u64;
  98. +
  99. +typedef __u16 __le16;
  100. +typedef __u32 __le32;
  101. +typedef __u64 __le64;
  102. +typedef __u64 off64_t;
  103. +
  104. +typedef __u16 __sum16;
  105. +typedef __u32 __wsum;
  106. +
  107. +#endif /* _LINUX_TYPES_H */
  108. diff -Nur mtd-utils-1.5.0.orig/include/mtd/jffs2-user.h mtd-utils-1.5.0/include/mtd/jffs2-user.h
  109. --- mtd-utils-1.5.0.orig/include/mtd/jffs2-user.h 2012-05-07 09:19:39.000000000 +0200
  110. +++ mtd-utils-1.5.0/include/mtd/jffs2-user.h 2014-03-22 11:01:37.000000000 +0100
  111. @@ -9,8 +9,13 @@
  112. /* This file is blessed for inclusion by userspace */
  113. #include <linux/jffs2.h>
  114. +#if defined(__APPLE__)
  115. +#include "endian.h"
  116. +#include "byteswap.h"
  117. +#else
  118. #include <endian.h>
  119. #include <byteswap.h>
  120. +#endif
  121. #undef cpu_to_je16
  122. #undef cpu_to_je32
  123. diff -Nur mtd-utils-1.5.0.orig/include/mtd/mtd-abi.h mtd-utils-1.5.0/include/mtd/mtd-abi.h
  124. --- mtd-utils-1.5.0.orig/include/mtd/mtd-abi.h 2012-05-07 09:19:39.000000000 +0200
  125. +++ mtd-utils-1.5.0/include/mtd/mtd-abi.h 2014-03-22 11:21:06.000000000 +0100
  126. @@ -171,9 +171,9 @@
  127. /* Get info about OOB modes (e.g., RAW, PLACE, AUTO) - legacy interface */
  128. #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
  129. /* Check if an eraseblock is bad */
  130. -#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
  131. +#define MEMGETBADBLOCK _IOW('M', 11, off_t)
  132. /* Mark an eraseblock as bad */
  133. -#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
  134. +#define MEMSETBADBLOCK _IOW('M', 12, off_t)
  135. /* Set OTP (One-Time Programmable) mode (factory vs. user) */
  136. #define OTPSELECT _IOR('M', 13, int)
  137. /* Get number of OTP (One-Time Programmable) regions */
  138. diff -Nur mtd-utils-1.5.0.orig/include/mtd/ubi-media.h mtd-utils-1.5.0/include/mtd/ubi-media.h
  139. --- mtd-utils-1.5.0.orig/include/mtd/ubi-media.h 2012-05-07 09:19:39.000000000 +0200
  140. +++ mtd-utils-1.5.0/include/mtd/ubi-media.h 2014-03-22 11:18:03.000000000 +0100
  141. @@ -30,7 +30,15 @@
  142. #ifndef __UBI_MEDIA_H__
  143. #define __UBI_MEDIA_H__
  144. +#ifdef __linux__
  145. #include <asm/byteorder.h>
  146. +#else
  147. +#include <stdint.h>
  148. +typedef uint8_t __u8;
  149. +typedef uint16_t __be16;
  150. +typedef uint32_t __be32;
  151. +typedef uint64_t __be64;
  152. +#endif
  153. /* The version of UBI images supported by this implementation */
  154. #define UBI_VERSION 1
  155. diff -Nur mtd-utils-1.5.0.orig/lib/libfec.c mtd-utils-1.5.0/lib/libfec.c
  156. --- mtd-utils-1.5.0.orig/lib/libfec.c 2012-05-07 09:19:39.000000000 +0200
  157. +++ mtd-utils-1.5.0/lib/libfec.c 2014-03-22 11:24:15.000000000 +0100
  158. @@ -61,8 +61,6 @@
  159. };
  160. #define gettimeofday(x, dummy) { (x)->ticks = clock() ; }
  161. #define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC )
  162. -typedef unsigned long u_long ;
  163. -typedef unsigned short u_short ;
  164. #else /* typically, unix systems */
  165. #include <sys/time.h>
  166. #define DIFF_T(a,b) \
  167. @@ -625,7 +623,7 @@
  168. #define FEC_MAGIC 0xFECC0DEC
  169. struct fec_parms {
  170. - u_long magic ;
  171. + unsigned long magic ;
  172. int k, n ; /* parameters of the code */
  173. gf *enc_matrix ;
  174. } ;
  175. diff -Nur mtd-utils-1.5.0.orig/lib/libmtd.c mtd-utils-1.5.0/lib/libmtd.c
  176. --- mtd-utils-1.5.0.orig/lib/libmtd.c 2012-05-07 09:19:39.000000000 +0200
  177. +++ mtd-utils-1.5.0/lib/libmtd.c 2014-03-22 11:15:49.000000000 +0100
  178. @@ -1006,7 +1006,7 @@
  179. int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb)
  180. {
  181. int ret;
  182. - loff_t seek;
  183. + off_t seek;
  184. ret = mtd_valid_erase_block(mtd, eb);
  185. if (ret)
  186. @@ -1015,7 +1015,7 @@
  187. if (!mtd->bb_allowed)
  188. return 0;
  189. - seek = (loff_t)eb * mtd->eb_size;
  190. + seek = (off_t)eb * mtd->eb_size;
  191. ret = ioctl(fd, MEMGETBADBLOCK, &seek);
  192. if (ret == -1)
  193. return mtd_ioctl_error(mtd, eb, "MEMGETBADBLOCK");
  194. @@ -1025,7 +1025,7 @@
  195. int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb)
  196. {
  197. int ret;
  198. - loff_t seek;
  199. + off_t seek;
  200. if (!mtd->bb_allowed) {
  201. errno = EINVAL;
  202. @@ -1036,7 +1036,7 @@
  203. if (ret)
  204. return ret;
  205. - seek = (loff_t)eb * mtd->eb_size;
  206. + seek = (off_t)eb * mtd->eb_size;
  207. ret = ioctl(fd, MEMSETBADBLOCK, &seek);
  208. if (ret == -1)
  209. return mtd_ioctl_error(mtd, eb, "MEMSETBADBLOCK");
  210. diff -Nur mtd-utils-1.5.0.orig/lib/libmtd_legacy.c mtd-utils-1.5.0/lib/libmtd_legacy.c
  211. --- mtd-utils-1.5.0.orig/lib/libmtd_legacy.c 2012-05-07 09:19:39.000000000 +0200
  212. +++ mtd-utils-1.5.0/lib/libmtd_legacy.c 2014-03-22 11:22:18.000000000 +0100
  213. @@ -234,7 +234,7 @@
  214. struct stat st;
  215. struct mtd_info_user ui;
  216. int fd, ret;
  217. - loff_t offs = 0;
  218. + off_t offs = 0;
  219. struct proc_parse_info pi;
  220. if (stat(node, &st)) {
  221. diff -Nur mtd-utils-1.5.0.orig/mkfs.jffs2.c mtd-utils-1.5.0/mkfs.jffs2.c
  222. --- mtd-utils-1.5.0.orig/mkfs.jffs2.c 2012-05-07 09:19:39.000000000 +0200
  223. +++ mtd-utils-1.5.0/mkfs.jffs2.c 2014-03-22 11:11:15.000000000 +0100
  224. @@ -70,7 +70,12 @@
  225. #include <sys/xattr.h>
  226. #include <sys/acl.h>
  227. #endif
  228. +#if defined(__APPLE__)
  229. +#include "endian.h"
  230. +#include "byteswap.h"
  231. +#else
  232. #include <byteswap.h>
  233. +#endif
  234. #include <crc32.h>
  235. #include <inttypes.h>
  236. diff -Nur mtd-utils-1.5.0.orig/rbtree.h mtd-utils-1.5.0/rbtree.h
  237. --- mtd-utils-1.5.0.orig/rbtree.h 2012-05-07 09:19:39.000000000 +0200
  238. +++ mtd-utils-1.5.0/rbtree.h 2014-03-22 11:07:58.000000000 +0100
  239. @@ -94,8 +94,7 @@
  240. #ifndef _LINUX_RBTREE_H
  241. #define _LINUX_RBTREE_H
  242. -#include <linux/kernel.h>
  243. -#include <linux/stddef.h>
  244. +#include <stddef.h>
  245. struct rb_node
  246. {