110-portability.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. @@ -34,7 +34,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. @@ -821,8 +821,8 @@ int write_leb(int lnum, int len, void *b
  68. if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size, dtype))
  69. return sys_err_msg("ubi_leb_change_start failed");
  70. - if (lseek64(out_fd, pos, SEEK_SET) != pos)
  71. - return sys_err_msg("lseek64 failed seeking %lld",
  72. + if (llseek(out_fd, pos, SEEK_SET) != pos)
  73. + return sys_err_msg("llseek failed seeking %lld",
  74. (long long)pos);
  75. if (write(out_fd, buf, c->leb_size) != c->leb_size)
  76. @@ -1079,6 +1079,7 @@ static int add_inode_with_data(struct st
  77. if (c->default_compr != UBIFS_COMPR_NONE)
  78. use_flags |= UBIFS_COMPR_FL;
  79. +#ifndef NO_NATIVE_SUPPORT
  80. if (flags & FS_COMPR_FL)
  81. use_flags |= UBIFS_COMPR_FL;
  82. if (flags & FS_SYNC_FL)
  83. @@ -1089,6 +1090,7 @@ static int add_inode_with_data(struct st
  84. use_flags |= UBIFS_APPEND_FL;
  85. if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode))
  86. use_flags |= UBIFS_DIRSYNC_FL;
  87. +#endif
  88. memset(ino, 0, UBIFS_INO_NODE_SZ);
  89. @@ -1158,7 +1160,9 @@ static int add_dir_inode(DIR *dir, ino_t
  90. fd = dirfd(dir);
  91. if (fd == -1)
  92. return sys_err_msg("dirfd failed");
  93. +#ifndef NO_NATIVE_SUPPORT
  94. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  95. +#endif
  96. flags = 0;
  97. }
  98. @@ -1343,10 +1347,12 @@ static int add_file(const char *path_nam
  99. key_write(&key, &dn->key);
  100. dn->size = cpu_to_le32(bytes_read);
  101. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  102. +#ifndef NO_NATIVE_SUPPORT
  103. if (c->default_compr == UBIFS_COMPR_NONE &&
  104. (flags & FS_COMPR_FL))
  105. use_compr = UBIFS_COMPR_LZO;
  106. else
  107. +#endif
  108. use_compr = c->default_compr;
  109. compr_type = compress_data(buf, bytes_read, &dn->data,
  110. &out_len, use_compr);
  111. @@ -1388,7 +1394,9 @@ static int add_non_dir(const char *path_
  112. if (fd == -1)
  113. return sys_err_msg("failed to open file '%s'",
  114. path_name);
  115. +#ifndef NO_NATIVE_SUPPORT
  116. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  117. +#endif
  118. flags = 0;
  119. if (close(fd) == -1)
  120. return sys_err_msg("failed to close file '%s'",
  121. --- a/mkfs.ubifs/devtable.c
  122. +++ b/mkfs.ubifs/devtable.c
  123. @@ -134,6 +134,7 @@ static int interpret_table_entry(const c
  124. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  125. unsigned int start = 0, increment = 0, count = 0;
  126. + buf[1023] = 0;
  127. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  128. buf, &type, &mode, &uid, &gid, &major, &minor,
  129. &start, &increment, &count) < 0)
  130. @@ -144,8 +145,8 @@ static int interpret_table_entry(const c
  131. buf, type, mode, uid, gid, major, minor, start,
  132. increment, count);
  133. - len = strnlen(buf, 1024);
  134. - if (len == 1024)
  135. + len = strlen(buf);
  136. + if (len == 1023)
  137. return err_msg("too long path");
  138. if (!strcmp(buf, "/"))