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

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

Archive Download this file



interactive