110-portability.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. --- a/compr_lzo.c
  2. +++ b/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/compr_zlib.c
  12. +++ b/compr_zlib.c
  13. @@ -35,7 +35,6 @@
  14. #include <stdint.h>
  15. #include <zlib.h>
  16. #include <stdio.h>
  17. -#include <asm/types.h>
  18. #include <linux/jffs2.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. @@ -131,7 +130,9 @@ static inline void rb_set_color(struct r
  31. #define RB_ROOT (struct rb_root) { NULL, }
  32. +#ifndef offsetof
  33. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  34. +#endif
  35. #define container_of(ptr, type, member) ({ \
  36. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  37. --- a/include/mtd/ubi-media.h
  38. +++ b/include/mtd/ubi-media.h
  39. @@ -30,7 +30,15 @@
  40. #ifndef __UBI_MEDIA_H__
  41. #define __UBI_MEDIA_H__
  42. +#ifdef __linux__
  43. #include <asm/byteorder.h>
  44. +#else
  45. +#include <stdint.h>
  46. +typedef uint8_t __u8;
  47. +typedef uint16_t __be16;
  48. +typedef uint32_t __be32;
  49. +typedef uint64_t __be64;
  50. +#endif
  51. /* The version of UBI images supported by this implementation */
  52. #define UBI_VERSION 1
  53. --- a/mkfs.ubifs/mkfs.ubifs.h
  54. +++ b/mkfs.ubifs/mkfs.ubifs.h
  55. @@ -34,7 +34,14 @@
  56. #include <endian.h>
  57. #include <byteswap.h>
  58. #include <linux/types.h>
  59. +#ifdef __linux__
  60. #include <linux/fs.h>
  61. +#else
  62. +# ifndef O_LARGEFILE
  63. +# define O_LARGEFILE 0
  64. +# endif
  65. +# define llseek lseek
  66. +#endif
  67. #include <getopt.h>
  68. #include <sys/types.h>
  69. --- a/mkfs.ubifs/mkfs.ubifs.c
  70. +++ b/mkfs.ubifs/mkfs.ubifs.c
  71. @@ -773,8 +773,8 @@ int write_leb(int lnum, int len, void *b
  72. if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size, dtype))
  73. return sys_err_msg("ubi_leb_change_start failed");
  74. - if (lseek64(out_fd, pos, SEEK_SET) != pos)
  75. - return sys_err_msg("lseek64 failed seeking %lld",
  76. + if (llseek(out_fd, pos, SEEK_SET) != pos)
  77. + return sys_err_msg("llseek failed seeking %lld",
  78. (long long)pos);
  79. if (write(out_fd, buf, c->leb_size) != c->leb_size)
  80. @@ -1029,6 +1029,7 @@ static int add_inode_with_data(struct st
  81. if (c->default_compr != UBIFS_COMPR_NONE)
  82. use_flags |= UBIFS_COMPR_FL;
  83. +#ifdef __linux__
  84. if (flags & FS_COMPR_FL)
  85. use_flags |= UBIFS_COMPR_FL;
  86. if (flags & FS_SYNC_FL)
  87. @@ -1039,6 +1040,7 @@ static int add_inode_with_data(struct st
  88. use_flags |= UBIFS_APPEND_FL;
  89. if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode))
  90. use_flags |= UBIFS_DIRSYNC_FL;
  91. +#endif
  92. memset(ino, 0, UBIFS_INO_NODE_SZ);
  93. @@ -1108,7 +1110,9 @@ static int add_dir_inode(DIR *dir, ino_t
  94. fd = dirfd(dir);
  95. if (fd == -1)
  96. return sys_err_msg("dirfd failed");
  97. +#ifdef __linux__
  98. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  99. +#endif
  100. flags = 0;
  101. }
  102. @@ -1293,10 +1297,12 @@ static int add_file(const char *path_nam
  103. key_write(&key, &dn->key);
  104. dn->size = cpu_to_le32(bytes_read);
  105. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  106. +#ifdef __linux__
  107. if (c->default_compr == UBIFS_COMPR_NONE &&
  108. (flags & FS_COMPR_FL))
  109. use_compr = UBIFS_COMPR_LZO;
  110. else
  111. +#endif
  112. use_compr = c->default_compr;
  113. compr_type = compress_data(buf, bytes_read, &dn->data,
  114. &out_len, use_compr);
  115. @@ -1338,7 +1344,9 @@ static int add_non_dir(const char *path_
  116. if (fd == -1)
  117. return sys_err_msg("failed to open file '%s'",
  118. path_name);
  119. +#ifdef __linux__
  120. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  121. +#endif
  122. flags = 0;
  123. if (close(fd) == -1)
  124. return sys_err_msg("failed to close file '%s'",
  125. --- a/mkfs.ubifs/devtable.c
  126. +++ b/mkfs.ubifs/devtable.c
  127. @@ -134,6 +134,7 @@ static int interpret_table_entry(const c
  128. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  129. unsigned int start = 0, increment = 0, count = 0;
  130. + buf[1023] = 0;
  131. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  132. buf, &type, &mode, &uid, &gid, &major, &minor,
  133. &start, &increment, &count) < 0)
  134. @@ -144,8 +145,8 @@ static int interpret_table_entry(const c
  135. buf, type, mode, uid, gid, major, minor, start,
  136. increment, count);
  137. - len = strnlen(buf, 1024);
  138. - if (len == 1024)
  139. + len = strlen(buf);
  140. + if (len == 1023)
  141. return err_msg("too long path");
  142. if (!strcmp(buf, "/"))