110-portability.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. --- 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,14 @@
  49. #include <endian.h>
  50. #include <byteswap.h>
  51. #include <linux/types.h>
  52. +#ifdef __linux__
  53. #include <linux/fs.h>
  54. +#else
  55. +# ifndef O_LARGEFILE
  56. +# define O_LARGEFILE 0
  57. +# endif
  58. +# define llseek lseek
  59. +#endif
  60. #include <getopt.h>
  61. #include <sys/types.h>
  62. --- a/mkfs.ubifs/mkfs.ubifs.c
  63. +++ b/mkfs.ubifs/mkfs.ubifs.c
  64. @@ -773,8 +773,8 @@ int write_leb(int lnum, int len, void *b
  65. if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size, dtype))
  66. return sys_err_msg("ubi_leb_change_start failed");
  67. - if (lseek64(out_fd, pos, SEEK_SET) != pos)
  68. - return sys_err_msg("lseek64 failed seeking %lld",
  69. + if (llseek(out_fd, pos, SEEK_SET) != pos)
  70. + return sys_err_msg("llseek failed seeking %lld",
  71. (long long)pos);
  72. if (write(out_fd, buf, c->leb_size) != c->leb_size)
  73. @@ -1029,6 +1029,7 @@ static int add_inode_with_data(struct st
  74. if (c->default_compr != UBIFS_COMPR_NONE)
  75. use_flags |= UBIFS_COMPR_FL;
  76. +#ifndef NO_NATIVE_SUPPORT
  77. if (flags & FS_COMPR_FL)
  78. use_flags |= UBIFS_COMPR_FL;
  79. if (flags & FS_SYNC_FL)
  80. @@ -1039,6 +1040,7 @@ static int add_inode_with_data(struct st
  81. use_flags |= UBIFS_APPEND_FL;
  82. if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode))
  83. use_flags |= UBIFS_DIRSYNC_FL;
  84. +#endif
  85. memset(ino, 0, UBIFS_INO_NODE_SZ);
  86. @@ -1108,7 +1110,9 @@ static int add_dir_inode(DIR *dir, ino_t
  87. fd = dirfd(dir);
  88. if (fd == -1)
  89. return sys_err_msg("dirfd failed");
  90. +#ifndef NO_NATIVE_SUPPORT
  91. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  92. +#endif
  93. flags = 0;
  94. }
  95. @@ -1293,10 +1297,12 @@ static int add_file(const char *path_nam
  96. key_write(&key, &dn->key);
  97. dn->size = cpu_to_le32(bytes_read);
  98. out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  99. +#ifndef NO_NATIVE_SUPPORT
  100. if (c->default_compr == UBIFS_COMPR_NONE &&
  101. (flags & FS_COMPR_FL))
  102. use_compr = UBIFS_COMPR_LZO;
  103. else
  104. +#endif
  105. use_compr = c->default_compr;
  106. compr_type = compress_data(buf, bytes_read, &dn->data,
  107. &out_len, use_compr);
  108. @@ -1338,7 +1344,9 @@ static int add_non_dir(const char *path_
  109. if (fd == -1)
  110. return sys_err_msg("failed to open file '%s'",
  111. path_name);
  112. +#ifndef NO_NATIVE_SUPPORT
  113. if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
  114. +#endif
  115. flags = 0;
  116. if (close(fd) == -1)
  117. return sys_err_msg("failed to close file '%s'",
  118. --- a/mkfs.ubifs/devtable.c
  119. +++ b/mkfs.ubifs/devtable.c
  120. @@ -134,6 +134,7 @@ static int interpret_table_entry(const c
  121. unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0;
  122. unsigned int start = 0, increment = 0, count = 0;
  123. + buf[1023] = 0;
  124. if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
  125. buf, &type, &mode, &uid, &gid, &major, &minor,
  126. &start, &increment, &count) < 0)
  127. @@ -144,8 +145,8 @@ static int interpret_table_entry(const c
  128. buf, type, mode, uid, gid, major, minor, start,
  129. increment, count);
  130. - len = strnlen(buf, 1024);
  131. - if (len == 1024)
  132. + len = strlen(buf);
  133. + if (len == 1023)
  134. return err_msg("too long path");
  135. if (!strcmp(buf, "/"))