X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/9f28e5bd03c15cbb0f9b1c534d16e065127aaeb2..f4945cfe79ad6c9ac2bfef5c6505e45cae3a709b:/tools/mtd-utils/patches/110-portability.patch diff --git a/tools/mtd-utils/patches/110-portability.patch b/tools/mtd-utils/patches/110-portability.patch index 487aec7c3..3b71231e4 100644 --- a/tools/mtd-utils/patches/110-portability.patch +++ b/tools/mtd-utils/patches/110-portability.patch @@ -10,44 +10,14 @@ #include "compr.h" --- a/compr_zlib.c +++ b/compr_zlib.c -@@ -35,7 +35,6 @@ - #include +@@ -39,7 +39,6 @@ #include + #undef crc32 #include -#include #include + #include "common.h" #include "compr.h" - ---- a/mkfs.jffs2.c -+++ b/mkfs.jffs2.c -@@ -1100,6 +1100,7 @@ static struct { - { 0, NULL, 0 } - }; - -+#ifndef NO_ACL_SUPPORT - static void formalize_posix_acl(void *xvalue, int *value_len) - { - struct posix_acl_xattr_header *pacl_header; -@@ -1151,6 +1152,7 @@ static void formalize_posix_acl(void *xv - memcpy(xvalue, buffer, offset); - *value_len = offset; - } -+#endif - - static xattr_entry_t *create_xattr_entry(int xprefix, char *xname, char *xvalue, int value_len) - { -@@ -1205,9 +1207,11 @@ static xattr_entry_t *find_xattr_entry(i - if (!xentry_hash) - xentry_hash = xcalloc(1, sizeof(xe) * XATTRENTRY_HASHSIZE); - -+#ifndef NO_ACL_SUPPORT - if (xprefix == JFFS2_XPREFIX_ACL_ACCESS - || xprefix == JFFS2_XPREFIX_ACL_DEFAULT) - formalize_posix_acl(xvalue, &value_len); -+#endif - - name_len = strlen(xname); - index = (crc32(0, xname, name_len) ^ crc32(0, xvalue, value_len)) % XATTRENTRY_HASHSIZE; --- a/rbtree.h +++ b/rbtree.h @@ -94,8 +94,7 @@ static inline struct page * rb_insert_pa @@ -60,13 +30,121 @@ struct rb_node { -@@ -131,7 +130,9 @@ static inline void rb_set_color(struct r +--- a/include/mtd/ubi-media.h ++++ b/include/mtd/ubi-media.h +@@ -30,7 +30,15 @@ + #ifndef __UBI_MEDIA_H__ + #define __UBI_MEDIA_H__ + ++#ifdef __linux__ + #include ++#else ++#include ++typedef uint8_t __u8; ++typedef uint16_t __be16; ++typedef uint32_t __be32; ++typedef uint64_t __be64; ++#endif - #define RB_ROOT (struct rb_root) { NULL, } + /* The version of UBI images supported by this implementation */ + #define UBI_VERSION 1 +--- a/mkfs.ubifs/mkfs.ubifs.h ++++ b/mkfs.ubifs/mkfs.ubifs.h +@@ -34,7 +34,14 @@ + #include + #include + #include ++#ifdef __linux__ + #include ++#else ++# ifndef O_LARGEFILE ++# define O_LARGEFILE 0 ++# endif ++# define llseek lseek ++#endif + + #include + #include +--- a/mkfs.ubifs/mkfs.ubifs.c ++++ b/mkfs.ubifs/mkfs.ubifs.c +@@ -805,8 +805,8 @@ int write_leb(int lnum, int len, void *b + if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size, dtype)) + return sys_err_msg("ubi_leb_change_start failed"); + +- if (lseek64(out_fd, pos, SEEK_SET) != pos) +- return sys_err_msg("lseek64 failed seeking %lld", ++ if (llseek(out_fd, pos, SEEK_SET) != pos) ++ return sys_err_msg("llseek failed seeking %lld", + (long long)pos); + + if (write(out_fd, buf, c->leb_size) != c->leb_size) +@@ -1063,6 +1063,7 @@ static int add_inode_with_data(struct st + + if (c->default_compr != UBIFS_COMPR_NONE) + use_flags |= UBIFS_COMPR_FL; ++#ifndef NO_NATIVE_SUPPORT + if (flags & FS_COMPR_FL) + use_flags |= UBIFS_COMPR_FL; + if (flags & FS_SYNC_FL) +@@ -1073,6 +1074,7 @@ static int add_inode_with_data(struct st + use_flags |= UBIFS_APPEND_FL; + if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode)) + use_flags |= UBIFS_DIRSYNC_FL; ++#endif -+#ifndef offsetof - #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + memset(ino, 0, UBIFS_INO_NODE_SZ); + +@@ -1142,7 +1144,9 @@ static int add_dir_inode(DIR *dir, ino_t + fd = dirfd(dir); + if (fd == -1) + return sys_err_msg("dirfd failed"); ++#ifndef NO_NATIVE_SUPPORT + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) ++#endif + flags = 0; + } + +@@ -1327,10 +1331,12 @@ static int add_file(const char *path_nam + key_write(&key, &dn->key); + dn->size = cpu_to_le32(bytes_read); + out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ; ++#ifndef NO_NATIVE_SUPPORT + if (c->default_compr == UBIFS_COMPR_NONE && + (flags & FS_COMPR_FL)) + use_compr = UBIFS_COMPR_LZO; + else +#endif + use_compr = c->default_compr; + compr_type = compress_data(buf, bytes_read, &dn->data, + &out_len, use_compr); +@@ -1372,7 +1378,9 @@ static int add_non_dir(const char *path_ + if (fd == -1) + return sys_err_msg("failed to open file '%s'", + path_name); ++#ifndef NO_NATIVE_SUPPORT + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) ++#endif + flags = 0; + if (close(fd) == -1) + return sys_err_msg("failed to close file '%s'", +--- a/mkfs.ubifs/devtable.c ++++ b/mkfs.ubifs/devtable.c +@@ -134,6 +134,7 @@ static int interpret_table_entry(const c + unsigned int mode = 0755, uid = 0, gid = 0, major = 0, minor = 0; + unsigned int start = 0, increment = 0, count = 0; + ++ buf[1023] = 0; + if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u", + buf, &type, &mode, &uid, &gid, &major, &minor, + &start, &increment, &count) < 0) +@@ -144,8 +145,8 @@ static int interpret_table_entry(const c + buf, type, mode, uid, gid, major, minor, start, + increment, count); + +- len = strnlen(buf, 1024); +- if (len == 1024) ++ len = strlen(buf); ++ if (len == 1023) + return err_msg("too long path"); - #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + if (!strcmp(buf, "/"))