1
0

110-portability.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. --- a/compr_lzo.c
  2. +++ b/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/compr_zlib.c
  11. +++ b/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/rbtree.h
  21. +++ b/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/mkfs.ubifs/mkfs.ubifs.h
  47. +++ b/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/mkfs.ubifs/mkfs.ubifs.c
  66. +++ b/mkfs.ubifs/mkfs.ubifs.c
  67. @@ -1010,6 +1010,7 @@ static int add_inode_with_data(struct st
  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. @@ -1020,6 +1021,7 @@ static int add_inode_with_data(struct st
  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. @@ -1089,7 +1091,9 @@ static int add_dir_inode(DIR *dir, ino_t
  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. @@ -1274,10 +1278,12 @@ 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. use_compr = UBIFS_COMPR_LZO;
  97. else
  98. +#endif
  99. use_compr = c->default_compr;
  100. compr_type = compress_data(buf, bytes_read, &dn->data,
  101. &out_len, use_compr);
  102. @@ -1319,7 +1325,9 @@ static int add_non_dir(const char *path_
  103. if (fd == -1)
  104. return sys_err_msg("failed to open file '%s'",
  105. path_name);
  106. +#ifndef NO_NATIVE_SUPPORT
  107. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  108. +#endif
  109. flags = 0;
  110. if (close(fd) == -1)
  111. return sys_err_msg("failed to close file '%s'",
  112. --- a/mkfs.ubifs/devtable.c
  113. +++ b/mkfs.ubifs/devtable.c
  114. @@ -134,6 +134,7 @@ static int interpret_table_entry(const c
  115. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  116. unsigned int start = 0, increment = 0, count = 0;
  117. + buf[1023] = 0;
  118. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  119. buf, &type, &mode, &uid, &gid, &major, &minor,
  120. &start, &increment, &count) < 0)
  121. @@ -144,8 +145,8 @@ static int interpret_table_entry(const c
  122. buf, type, mode, uid, gid, major, minor, start,
  123. increment, count);
  124. - len = strnlen(buf, 1024);
  125. - if (len == 1024)
  126. + len = strlen(buf);
  127. + if (len == 1023)
  128. return err_msg("too long path");
  129. if (!strcmp(buf, "/"))
  130. --- a/include/common.h
  131. +++ b/include/common.h
  132. @@ -26,7 +26,6 @@
  133. #include <string.h>
  134. #include <fcntl.h>
  135. #include <errno.h>
  136. -#include <features.h>
  137. #include <inttypes.h>
  138. #include "version.h"
  139. --- a/include/mtd/ubifs-media.h
  140. +++ b/include/mtd/ubifs-media.h
  141. @@ -33,7 +33,15 @@
  142. #ifndef __UBIFS_MEDIA_H__
  143. #define __UBIFS_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. /* UBIFS node magic number (must not have the padding byte first or last) */
  154. #define UBIFS_NODE_MAGIC 0x06101831