110-portability.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. --- a/jffsX-utils/compr_lzo.c
  2. +++ b/jffsX-utils/compr_lzo.c
  3. @@ -26,7 +26,6 @@
  4. #include <string.h>
  5. #ifndef WITHOUT_LZO
  6. -#include <asm/types.h>
  7. #include <linux/jffs2.h>
  8. #include <lzo/lzo1x.h>
  9. #include "compr.h"
  10. --- a/jffsX-utils/compr_zlib.c
  11. +++ b/jffsX-utils/compr_zlib.c
  12. @@ -39,7 +39,6 @@
  13. #include <zlib.h>
  14. #undef crc32
  15. #include <stdio.h>
  16. -#include <asm/types.h>
  17. #include <linux/jffs2.h>
  18. #include "common.h"
  19. #include "compr.h"
  20. --- a/jffsX-utils/rbtree.h
  21. +++ b/jffsX-utils/rbtree.h
  22. @@ -94,8 +94,7 @@ static inline struct page * rb_insert_pa
  23. #ifndef _LINUX_RBTREE_H
  24. #define _LINUX_RBTREE_H
  25. -#include <linux/kernel.h>
  26. -#include <linux/stddef.h>
  27. +#include <stddef.h>
  28. struct rb_node
  29. {
  30. --- a/include/mtd/ubi-media.h
  31. +++ b/include/mtd/ubi-media.h
  32. @@ -30,7 +30,15 @@
  33. #ifndef __UBI_MEDIA_H__
  34. #define __UBI_MEDIA_H__
  35. +#ifdef __linux__
  36. #include <asm/byteorder.h>
  37. +#else
  38. +#include <stdint.h>
  39. +typedef uint8_t __u8;
  40. +typedef uint16_t __be16;
  41. +typedef uint32_t __be32;
  42. +typedef uint64_t __be64;
  43. +#endif
  44. /* The version of UBI images supported by this implementation */
  45. #define UBI_VERSION 1
  46. --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h
  47. +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h
  48. @@ -32,7 +32,17 @@
  49. #include <endian.h>
  50. #include <byteswap.h>
  51. #include <linux/types.h>
  52. +#ifdef __linux__
  53. #include <linux/fs.h>
  54. +# if defined(__x86_64__) && defined(__ILP32__)
  55. +# define llseek lseek64
  56. +# endif
  57. +#else
  58. +# ifndef O_LARGEFILE
  59. +# define O_LARGEFILE 0
  60. +# endif
  61. +# define llseek lseek
  62. +#endif
  63. #include <getopt.h>
  64. #include <sys/types.h>
  65. --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  66. +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
  67. @@ -1503,6 +1503,7 @@ static int add_inode(struct stat *st, in
  68. if (c->default_compr != UBIFS_COMPR_NONE)
  69. use_flags |= UBIFS_COMPR_FL;
  70. +#ifndef NO_NATIVE_SUPPORT
  71. if (flags & FS_COMPR_FL)
  72. use_flags |= UBIFS_COMPR_FL;
  73. if (flags & FS_SYNC_FL)
  74. @@ -1515,6 +1516,7 @@ static int add_inode(struct stat *st, in
  75. use_flags |= UBIFS_DIRSYNC_FL;
  76. if (fctx)
  77. use_flags |= UBIFS_CRYPT_FL;
  78. +#endif
  79. memset(ino, 0, UBIFS_INO_NODE_SZ);
  80. ino_key_init(&key, inum);
  81. @@ -1600,7 +1602,9 @@ static int add_dir_inode(const char *pat
  82. fd = dirfd(dir);
  83. if (fd == -1)
  84. return sys_err_msg("dirfd failed");
  85. +#ifndef NO_NATIVE_SUPPORT
  86. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  87. +#endif
  88. flags = 0;
  89. }
  90. @@ -1811,6 +1815,7 @@ static int add_file(const char *path_nam
  91. dn->ch.node_type = UBIFS_DATA_NODE;
  92. key_write(&key, &dn->key);
  93. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  94. +#ifndef NO_NATIVE_SUPPORT
  95. if (c->default_compr == UBIFS_COMPR_NONE &&
  96. !c->encrypted && (flags & FS_COMPR_FL))
  97. #ifdef WITHOUT_LZO
  98. @@ -1819,6 +1824,7 @@ static int add_file(const char *path_nam
  99. use_compr = UBIFS_COMPR_LZO;
  100. #endif
  101. else
  102. +#endif
  103. use_compr = c->default_compr;
  104. compr_type = compress_data(buf, bytes_read, &dn->data,
  105. &out_len, use_compr);
  106. @@ -1876,7 +1882,9 @@ static int add_non_dir(const char *path_
  107. if (fd == -1)
  108. return sys_err_msg("failed to open file '%s'",
  109. path_name);
  110. +#ifndef NO_NATIVE_SUPPORT
  111. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  112. +#endif
  113. flags = 0;
  114. if (close(fd) == -1)
  115. return sys_err_msg("failed to close file '%s'",
  116. --- a/ubifs-utils/mkfs.ubifs/devtable.c
  117. +++ b/ubifs-utils/mkfs.ubifs/devtable.c
  118. @@ -135,6 +135,7 @@ static int interpret_table_entry(const c
  119. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  120. unsigned int start = 0, increment = 0, count = 0;
  121. + buf[1023] = 0;
  122. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  123. buf, &type, &mode, &uid, &gid, &major, &minor,
  124. &start, &increment, &count) < 0)
  125. @@ -145,10 +146,10 @@ static int interpret_table_entry(const c
  126. buf, type, mode, uid, gid, major, minor, start,
  127. increment, count);
  128. - len = strnlen(buf, 1024);
  129. + len = strlen(buf);
  130. if (len == 0)
  131. return err_msg("empty path");
  132. - if (len == 1024)
  133. + if (len == 1023)
  134. return err_msg("too long path");
  135. if (buf[0] != '/')
  136. --- a/include/common.h
  137. +++ b/include/common.h
  138. @@ -26,7 +26,6 @@
  139. #include <string.h>
  140. #include <fcntl.h>
  141. #include <errno.h>
  142. -#include <features.h>
  143. #include <inttypes.h>
  144. #include <unistd.h>
  145. #include <sys/sysmacros.h>
  146. --- a/include/mtd/ubifs-media.h
  147. +++ b/include/mtd/ubifs-media.h
  148. @@ -33,7 +33,15 @@
  149. #ifndef __UBIFS_MEDIA_H__
  150. #define __UBIFS_MEDIA_H__
  151. +#ifdef __linux__
  152. #include <asm/byteorder.h>
  153. +#else
  154. +#include <stdint.h>
  155. +typedef uint8_t __u8;
  156. +typedef uint16_t __be16;
  157. +typedef uint32_t __be32;
  158. +typedef uint64_t __be64;
  159. +#endif
  160. /* UBIFS node magic number (must not have the padding byte first or last) */
  161. #define UBIFS_NODE_MAGIC 0x06101831