/tools/mtd-utils/patches/110-portability.patch

https://code.google.com/ · Patch · 150 lines · 136 code · 14 blank · 0 comment · 0 complexity · 0c3bf31c4c2bf1182d50ed1ff4d93006 MD5 · raw file

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