110-portability.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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/mkfs.ubifs/mkfs.ubifs.h
  48. +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h
  49. @@ -32,7 +32,17 @@
  50. #include <endian.h>
  51. #include <byteswap.h>
  52. #include <linux/types.h>
  53. +#ifdef __linux__
  54. #include <linux/fs.h>
  55. +# if defined(__x86_64__) && defined(__ILP32__)
  56. +# define llseek lseek64
  57. +# endif
  58. +#else
  59. +# ifndef O_LARGEFILE
  60. +# define O_LARGEFILE 0
  61. +# endif
  62. +# define llseek lseek
  63. +#endif
  64. #include <getopt.h>
  65. #include <sys/types.h>
  66. --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  67. +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  68. @@ -1568,6 +1568,7 @@ static int add_inode(struct stat *st, in
  69. if (c->default_compr != UBIFS_COMPR_NONE)
  70. use_flags |= UBIFS_COMPR_FL;
  71. +#ifndef NO_NATIVE_SUPPORT
  72. if (flags & FS_COMPR_FL)
  73. use_flags |= UBIFS_COMPR_FL;
  74. if (flags & FS_SYNC_FL)
  75. @@ -1580,6 +1581,7 @@ static int add_inode(struct stat *st, in
  76. use_flags |= UBIFS_DIRSYNC_FL;
  77. if (fctx)
  78. use_flags |= UBIFS_CRYPT_FL;
  79. +#endif
  80. memset(ino, 0, UBIFS_INO_NODE_SZ);
  81. ino_key_init(&key, inum);
  82. @@ -1665,7 +1667,9 @@ static int add_dir_inode(const char *pat
  83. fd = dirfd(dir);
  84. if (fd == -1)
  85. return sys_err_msg("dirfd failed");
  86. +#ifndef NO_NATIVE_SUPPORT
  87. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  88. +#endif
  89. flags = 0;
  90. }
  91. @@ -1878,6 +1882,7 @@ static int add_file(const char *path_nam
  92. dn->ch.node_type = UBIFS_DATA_NODE;
  93. key_write(&key, &dn->key);
  94. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  95. +#ifndef NO_NATIVE_SUPPORT
  96. if (c->default_compr == UBIFS_COMPR_NONE &&
  97. !c->encrypted && (flags & FS_COMPR_FL))
  98. #ifdef WITH_LZO
  99. @@ -1888,6 +1893,7 @@ static int add_file(const char *path_nam
  100. use_compr = UBIFS_COMPR_NONE;
  101. #endif
  102. else
  103. +#endif
  104. use_compr = c->default_compr;
  105. compr_type = compress_data(buf, bytes_read, &dn->data,
  106. &out_len, use_compr);
  107. @@ -1947,7 +1953,9 @@ static int add_non_dir(const char *path_
  108. if (fd == -1)
  109. return sys_err_msg("failed to open file '%s'",
  110. path_name);
  111. +#ifndef NO_NATIVE_SUPPORT
  112. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  113. +#endif
  114. flags = 0;
  115. if (close(fd) == -1)
  116. return sys_err_msg("failed to close file '%s'",
  117. --- a/ubifs-utils/mkfs.ubifs/devtable.c
  118. +++ b/ubifs-utils/mkfs.ubifs/devtable.c
  119. @@ -135,6 +135,7 @@ static int interpret_table_entry(const c
  120. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  121. unsigned int start = 0, increment = 0, count = 0;
  122. + buf[1023] = 0;
  123. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  124. buf, &type, &mode, &uid, &gid, &major, &minor,
  125. &start, &increment, &count) < 0)
  126. @@ -145,10 +146,10 @@ static int interpret_table_entry(const c
  127. buf, type, mode, uid, gid, major, minor, start,
  128. increment, count);
  129. - len = strnlen(buf, 1024);
  130. + len = strlen(buf);
  131. if (len == 0)
  132. return err_msg("empty path");
  133. - if (len == 1024)
  134. + if (len == 1023)
  135. return err_msg("too long path");
  136. if (buf[0] != '/')
  137. --- a/include/common.h
  138. +++ b/include/common.h
  139. @@ -26,7 +26,6 @@
  140. #include <string.h>
  141. #include <fcntl.h>
  142. #include <errno.h>
  143. -#include <features.h>
  144. #include <inttypes.h>
  145. #include <unistd.h>
  146. #include <sys/sysmacros.h>
  147. --- a/include/mtd/ubifs-media.h
  148. +++ b/include/mtd/ubifs-media.h
  149. @@ -33,7 +33,15 @@
  150. #ifndef __UBIFS_MEDIA_H__
  151. #define __UBIFS_MEDIA_H__
  152. +#ifdef __linux__
  153. #include <asm/byteorder.h>
  154. +#else
  155. +#include <stdint.h>
  156. +typedef uint8_t __u8;
  157. +typedef uint16_t __be16;
  158. +typedef uint32_t __be32;
  159. +typedef uint64_t __be64;
  160. +#endif
  161. /* UBIFS node magic number (must not have the padding byte first or last) */
  162. #define UBIFS_NODE_MAGIC 0x06101831