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. @@ -1219,6 +1219,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. @@ -1229,6 +1230,7 @@ static int add_inode(struct stat *st, in
  75. use_flags |= UBIFS_APPEND_FL;
  76. if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode))
  77. use_flags |= UBIFS_DIRSYNC_FL;
  78. +#endif
  79. memset(ino, 0, UBIFS_INO_NODE_SZ);
  80. @@ -1293,7 +1295,9 @@ static int add_dir_inode(const char *pat
  81. fd = dirfd(dir);
  82. if (fd == -1)
  83. return sys_err_msg("dirfd failed");
  84. +#ifndef NO_NATIVE_SUPPORT
  85. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  86. +#endif
  87. flags = 0;
  88. }
  89. @@ -1476,6 +1480,7 @@ static int add_file(const char *path_nam
  90. key_write(&key, &dn->key);
  91. dn->size = cpu_to_le32(bytes_read);
  92. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  93. +#ifndef NO_NATIVE_SUPPORT
  94. if (c->default_compr == UBIFS_COMPR_NONE &&
  95. (flags & FS_COMPR_FL))
  96. #ifdef WITHOUT_LZO
  97. @@ -1484,6 +1489,7 @@ static int add_file(const char *path_nam
  98. use_compr = UBIFS_COMPR_LZO;
  99. #endif
  100. else
  101. +#endif
  102. use_compr = c->default_compr;
  103. compr_type = compress_data(buf, bytes_read, &dn->data,
  104. &out_len, use_compr);
  105. @@ -1527,7 +1533,9 @@ static int add_non_dir(const char *path_
  106. if (fd == -1)
  107. return sys_err_msg("failed to open file '%s'",
  108. path_name);
  109. +#ifndef NO_NATIVE_SUPPORT
  110. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  111. +#endif
  112. flags = 0;
  113. if (close(fd) == -1)
  114. return sys_err_msg("failed to close file '%s'",
  115. --- a/ubifs-utils/mkfs.ubifs/devtable.c
  116. +++ b/ubifs-utils/mkfs.ubifs/devtable.c
  117. @@ -135,6 +135,7 @@ static int interpret_table_entry(const c
  118. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  119. unsigned int start = 0, increment = 0, count = 0;
  120. + buf[1023] = 0;
  121. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  122. buf, &type, &mode, &uid, &gid, &major, &minor,
  123. &start, &increment, &count) < 0)
  124. @@ -145,10 +146,10 @@ static int interpret_table_entry(const c
  125. buf, type, mode, uid, gid, major, minor, start,
  126. increment, count);
  127. - len = strnlen(buf, 1024);
  128. + len = strlen(buf);
  129. if (len == 0)
  130. return err_msg("empty path");
  131. - if (len == 1024)
  132. + if (len == 1023)
  133. return err_msg("too long path");
  134. if (buf[0] != '/')
  135. --- a/include/common.h
  136. +++ b/include/common.h
  137. @@ -26,7 +26,6 @@
  138. #include <string.h>
  139. #include <fcntl.h>
  140. #include <errno.h>
  141. -#include <features.h>
  142. #include <inttypes.h>
  143. #include <unistd.h>
  144. #include <sys/sysmacros.h>
  145. --- a/include/mtd/ubifs-media.h
  146. +++ b/include/mtd/ubifs-media.h
  147. @@ -33,7 +33,15 @@
  148. #ifndef __UBIFS_MEDIA_H__
  149. #define __UBIFS_MEDIA_H__
  150. +#ifdef __linux__
  151. #include <asm/byteorder.h>
  152. +#else
  153. +#include <stdint.h>
  154. +typedef uint8_t __u8;
  155. +typedef uint16_t __be16;
  156. +typedef uint32_t __be32;
  157. +typedef uint64_t __be64;
  158. +#endif
  159. /* UBIFS node magic number (must not have the padding byte first or last) */
  160. #define UBIFS_NODE_MAGIC 0x06101831