110-portability.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. --- a/jffsX-utils/compr_lzo.c
  2. +++ b/jffsX-utils/compr_lzo.c
  3. @@ -24,7 +24,6 @@
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. -#include <asm/types.h>
  8. #include <linux/jffs2.h>
  9. #include <lzo/lzo1x.h>
  10. #include "compr.h"
  11. --- a/jffsX-utils/compr_zlib.c
  12. +++ b/jffsX-utils/compr_zlib.c
  13. @@ -39,7 +39,6 @@
  14. #include <zlib.h>
  15. #undef crc32
  16. #include <stdio.h>
  17. -#include <asm/types.h>
  18. #include <linux/jffs2.h>
  19. #include "common.h"
  20. #include "compr.h"
  21. --- a/include/rbtree.h
  22. +++ b/include/rbtree.h
  23. @@ -94,8 +94,7 @@ static inline struct page * rb_insert_pa
  24. #ifndef _LINUX_RBTREE_H
  25. #define _LINUX_RBTREE_H
  26. -#include <linux/kernel.h>
  27. -#include <linux/stddef.h>
  28. +#include <stddef.h>
  29. struct rb_node
  30. {
  31. --- a/include/mtd/ubi-media.h
  32. +++ b/include/mtd/ubi-media.h
  33. @@ -30,7 +30,15 @@
  34. #ifndef __UBI_MEDIA_H__
  35. #define __UBI_MEDIA_H__
  36. +#ifdef __linux__
  37. #include <asm/byteorder.h>
  38. +#else
  39. +#include <stdint.h>
  40. +typedef uint8_t __u8;
  41. +typedef uint16_t __be16;
  42. +typedef uint32_t __be32;
  43. +typedef uint64_t __be64;
  44. +#endif
  45. /* The version of UBI images supported by this implementation */
  46. #define UBI_VERSION 1
  47. --- a/ubifs-utils/common/compiler_attributes.h
  48. +++ b/ubifs-utils/common/compiler_attributes.h
  49. @@ -1,6 +1,12 @@
  50. #ifndef __COMPILER_ATTRIBUTES_H__
  51. #define __COMPILER_ATTRIBUTES_H__
  52. +#if HAVE_EXECINFO_H
  53. +#include <execinfo.h>
  54. +#else
  55. +#include "libmissing.h"
  56. +#endif
  57. +
  58. #if __has_attribute(__fallthrough__)
  59. #define fallthrough __attribute__((__fallthrough__))
  60. #else
  61. @@ -11,6 +17,7 @@
  62. #define __unused __attribute__((__unused__))
  63. #define __const __attribute__((__const__))
  64. #define __must_check __attribute__((__warn_unused_result__))
  65. +#define __always_inline inline __attribute__((__always_inline__))
  66. #ifndef __force
  67. #define __force
  68. #endif
  69. --- a/ubifs-utils/common/linux_types.h
  70. +++ b/ubifs-utils/common/linux_types.h
  71. @@ -14,7 +14,11 @@ typedef __u16 u16;
  72. typedef __u32 u32;
  73. typedef __u64 u64;
  74. +#ifdef __linux__
  75. typedef __s64 time64_t;
  76. +#else
  77. +typedef int64_t time64_t;
  78. +#endif
  79. struct qstr {
  80. const char *name;
  81. @@ -89,4 +93,8 @@ static inline int int_log2(unsigned int
  82. #undef PAGE_SHIFT
  83. #define PAGE_SHIFT (int_log2(PAGE_SIZE))
  84. +#ifndef EUCLEAN
  85. +#define EUCLEAN 117 /* Structure needs cleaning */
  86. +#endif
  87. +
  88. #endif
  89. --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  90. +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  91. @@ -29,7 +29,17 @@
  92. #include <dirent.h>
  93. #include <crc32.h>
  94. #include <uuid.h>
  95. +#ifdef __linux__
  96. #include <linux/fs.h>
  97. +# if defined(__x86_64__) && defined(__ILP32__)
  98. +# define llseek lseek64
  99. +# endif
  100. +#else
  101. +# ifndef O_LARGEFILE
  102. +# define O_LARGEFILE 0
  103. +# endif
  104. +# define llseek lseek
  105. +#endif
  106. #include <sys/types.h>
  107. #include <sys/stat.h>
  108. #include <sys/ioctl.h>
  109. @@ -1459,6 +1469,7 @@ static int add_inode(struct stat *st, in
  110. if (c->default_compr != UBIFS_COMPR_NONE)
  111. use_flags |= UBIFS_COMPR_FL;
  112. +#ifndef NO_NATIVE_SUPPORT
  113. if (flags & FS_COMPR_FL)
  114. use_flags |= UBIFS_COMPR_FL;
  115. if (flags & FS_SYNC_FL)
  116. @@ -1471,6 +1482,7 @@ static int add_inode(struct stat *st, in
  117. use_flags |= UBIFS_DIRSYNC_FL;
  118. if (fctx)
  119. use_flags |= UBIFS_CRYPT_FL;
  120. +#endif
  121. memset(ino, 0, UBIFS_INO_NODE_SZ);
  122. ino_key_init(c, &key, inum);
  123. @@ -1556,7 +1568,9 @@ static int add_dir_inode(const char *pat
  124. fd = dirfd(dir);
  125. if (fd == -1)
  126. return sys_errmsg("dirfd failed");
  127. +#ifndef NO_NATIVE_SUPPORT
  128. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  129. +#endif
  130. flags = 0;
  131. }
  132. @@ -1772,6 +1786,7 @@ static int add_file(const char *path_nam
  133. dn->ch.node_type = UBIFS_DATA_NODE;
  134. key_write(c, &key, &dn->key);
  135. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  136. +#ifndef NO_NATIVE_SUPPORT
  137. if (c->default_compr == UBIFS_COMPR_NONE &&
  138. !c->encrypted && (flags & FS_COMPR_FL))
  139. #ifdef WITH_LZO
  140. @@ -1782,6 +1797,7 @@ static int add_file(const char *path_nam
  141. use_compr = UBIFS_COMPR_NONE;
  142. #endif
  143. else
  144. +#endif
  145. use_compr = c->default_compr;
  146. compr_type = compress_data(buf, bytes_read, &dn->data,
  147. &out_len, use_compr);
  148. @@ -1841,7 +1857,9 @@ static int add_non_dir(const char *path_
  149. if (fd == -1)
  150. return sys_errmsg("failed to open file '%s'",
  151. path_name);
  152. +#ifndef NO_NATIVE_SUPPORT
  153. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  154. +#endif
  155. flags = 0;
  156. if (close(fd) == -1)
  157. return sys_errmsg("failed to close file '%s'",
  158. --- a/include/common.h
  159. +++ b/include/common.h
  160. @@ -26,7 +26,6 @@
  161. #include <string.h>
  162. #include <fcntl.h>
  163. #include <errno.h>
  164. -#include <features.h>
  165. #include <inttypes.h>
  166. #include <unistd.h>
  167. #include <sys/sysmacros.h>
  168. --- a/ubifs-utils/libubifs/ubifs-media.h
  169. +++ b/ubifs-utils/libubifs/ubifs-media.h
  170. @@ -33,7 +33,11 @@
  171. #ifndef __UBIFS_MEDIA_H__
  172. #define __UBIFS_MEDIA_H__
  173. +#ifdef __linux__
  174. #include <asm/byteorder.h>
  175. +#else
  176. +#include <stdint.h>
  177. +#endif
  178. /* UBIFS node magic number (must not have the padding byte first or last) */
  179. #define UBIFS_NODE_MAGIC 0x06101831