b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | --- a/jffsX-utils/compr_lzo.c |
| 2 | +++ b/jffsX-utils/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/jffsX-utils/compr_zlib.c |
| 12 | +++ b/jffsX-utils/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/include/rbtree.h |
| 22 | +++ b/include/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/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h |
| 52 | +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h |
| 53 | @@ -32,7 +32,17 @@ |
| 54 | #include <endian.h> |
| 55 | #include <byteswap.h> |
| 56 | #include <linux/types.h> |
| 57 | +#ifdef __linux__ |
| 58 | #include <linux/fs.h> |
| 59 | +# if defined(__x86_64__) && defined(__ILP32__) |
| 60 | +# define llseek lseek64 |
| 61 | +# endif |
| 62 | +#else |
| 63 | +# ifndef O_LARGEFILE |
| 64 | +# define O_LARGEFILE 0 |
| 65 | +# endif |
| 66 | +# define llseek lseek |
| 67 | +#endif |
| 68 | |
| 69 | #include <getopt.h> |
| 70 | #include <sys/types.h> |
| 71 | --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c |
| 72 | +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c |
| 73 | @@ -1568,6 +1568,7 @@ static int add_inode(struct stat *st, in |
| 74 | |
| 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 | @@ -1580,6 +1581,7 @@ static int add_inode(struct stat *st, in |
| 82 | use_flags |= UBIFS_DIRSYNC_FL; |
| 83 | if (fctx) |
| 84 | use_flags |= UBIFS_CRYPT_FL; |
| 85 | +#endif |
| 86 | memset(ino, 0, UBIFS_INO_NODE_SZ); |
| 87 | |
| 88 | ino_key_init(&key, inum); |
| 89 | @@ -1665,7 +1667,9 @@ static int add_dir_inode(const char *pat |
| 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 | |
| 99 | @@ -1878,6 +1882,7 @@ static int add_file(const char *path_nam |
| 100 | dn->ch.node_type = UBIFS_DATA_NODE; |
| 101 | key_write(&key, &dn->key); |
| 102 | out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ; |
| 103 | +#ifndef NO_NATIVE_SUPPORT |
| 104 | if (c->default_compr == UBIFS_COMPR_NONE && |
| 105 | !c->encrypted && (flags & FS_COMPR_FL)) |
| 106 | #ifdef WITH_LZO |
| 107 | @@ -1888,6 +1893,7 @@ static int add_file(const char *path_nam |
| 108 | use_compr = UBIFS_COMPR_NONE; |
| 109 | #endif |
| 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 | @@ -1947,7 +1953,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 | +#ifndef NO_NATIVE_SUPPORT |
| 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/ubifs-utils/mkfs.ubifs/devtable.c |
| 126 | +++ b/ubifs-utils/mkfs.ubifs/devtable.c |
| 127 | @@ -135,6 +135,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 | |
| 131 | + buf[1023] = 0; |
| 132 | if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u", |
| 133 | buf, &type, &mode, &uid, &gid, &major, &minor, |
| 134 | &start, &increment, &count) < 0) |
| 135 | @@ -145,10 +146,10 @@ static int interpret_table_entry(const c |
| 136 | buf, type, mode, uid, gid, major, minor, start, |
| 137 | increment, count); |
| 138 | |
| 139 | - len = strnlen(buf, 1024); |
| 140 | + len = strlen(buf); |
| 141 | if (len == 0) |
| 142 | return err_msg("empty path"); |
| 143 | - if (len == 1024) |
| 144 | + if (len == 1023) |
| 145 | return err_msg("too long path"); |
| 146 | |
| 147 | if (buf[0] != '/') |
| 148 | --- a/include/common.h |
| 149 | +++ b/include/common.h |
| 150 | @@ -26,7 +26,6 @@ |
| 151 | #include <string.h> |
| 152 | #include <fcntl.h> |
| 153 | #include <errno.h> |
| 154 | -#include <features.h> |
| 155 | #include <inttypes.h> |
| 156 | #include <unistd.h> |
| 157 | #include <sys/sysmacros.h> |
| 158 | --- a/include/mtd/ubifs-media.h |
| 159 | +++ b/include/mtd/ubifs-media.h |
| 160 | @@ -33,7 +33,15 @@ |
| 161 | #ifndef __UBIFS_MEDIA_H__ |
| 162 | #define __UBIFS_MEDIA_H__ |
| 163 | |
| 164 | +#ifdef __linux__ |
| 165 | #include <asm/byteorder.h> |
| 166 | +#else |
| 167 | +#include <stdint.h> |
| 168 | +typedef uint8_t __u8; |
| 169 | +typedef uint16_t __be16; |
| 170 | +typedef uint32_t __be32; |
| 171 | +typedef uint64_t __be64; |
| 172 | +#endif |
| 173 | |
| 174 | /* UBIFS node magic number (must not have the padding byte first or last) */ |
| 175 | #define UBIFS_NODE_MAGIC 0x06101831 |