From patchwork Wed Aug 6 19:17:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Diorcet X-Patchwork-Id: 377370 X-Patchwork-Delegate: kiho@prevas.dk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hugin.dotsrc.org (hugin.dotsrc.org [IPv6:2001:878:346::102]) by ozlabs.org (Postfix) with ESMTP id 9C4B41400AA for ; Thu, 7 Aug 2014 05:18:31 +1000 (EST) Received: from hugin.dotsrc.org (localhost [127.0.0.1]) by hugin.dotsrc.org (Postfix) with ESMTP id 506643F9B1 for ; Wed, 6 Aug 2014 21:18:30 +0200 (CEST) X-Original-To: dev@oe-lite.org Delivered-To: dev@oe-lite.org Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by hugin.dotsrc.org (Postfix) with ESMTPS id 2AA033FD91 for ; Wed, 6 Aug 2014 21:18:28 +0200 (CEST) Received: by mail-wi0-f177.google.com with SMTP id ho1so3817197wib.4 for ; Wed, 06 Aug 2014 12:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LlFIUeEk97N1xH20GJrft8D9hhlfTgyvsdmZ7lmfKik=; b=J1J1FuRe7QV2iocDIKDp1u/eEiP/prbFcltFs5ShccI+194YfvsGNdzi8WGV7dCQ92 RaXPJ0PKHrQb3P+s/B8+1Dn7Pm4edaLfS7PkzgO1M+3WOnRLrHAzB7njinI6rqeNrpm1 JMpBFjZXsBpBk5zdmbHTn0aSltz5ot30U/nb55j9R0ylHawMWK45ldC85wqKe+z0f5Ul bAwFE5v9NbEoQFPWpD6wvVnY0sG80p4O7Ucl3B3PLuej6/HhW+AqUzvCPLEHlrzlXcGj Zr1dwEnyT8MvOVuCm72CYsz/lJNlLQtrpydd3P3czJc/Qy9uLzDxWLz0QcGwBHysQQhh VLLQ== X-Received: by 10.180.92.104 with SMTP id cl8mr51394614wib.43.1407352707566; Wed, 06 Aug 2014 12:18:27 -0700 (PDT) Received: from localhost.localdomain (mut38-h01-31-33-249-220.dsl.sta.abo.bbox.fr. [31.33.249.220]) by mx.google.com with ESMTPSA id b9sm21033538wic.23.2014.08.06.12.18.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Aug 2014 12:18:26 -0700 (PDT) From: Yann Diorcet To: dev@oe-lite.org Subject: [PATCH 08/18] mtd-utils: (Better) Darwin support Date: Wed, 6 Aug 2014 21:17:54 +0200 Message-Id: <1407352684-7837-8-git-send-email-diorcet.yann@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407352684-7837-1-git-send-email-diorcet.yann@gmail.com> References: <1407352684-7837-1-git-send-email-diorcet.yann@gmail.com> X-BeenThere: dev@oe-lite.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: OE-lite development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dev-bounces@oe-lite.org Errors-To: dev-bounces@oe-lite.org --- recipes/mtd/mtd-utils-1.4.6/osx.patch | 931 ++++++++++++++++++++++++++++++++++ recipes/mtd/mtd-utils.inc | 3 +- 2 files changed, 933 insertions(+), 1 deletion(-) create mode 100644 recipes/mtd/mtd-utils-1.4.6/osx.patch diff --git a/recipes/mtd/mtd-utils-1.4.6/osx.patch b/recipes/mtd/mtd-utils-1.4.6/osx.patch new file mode 100644 index 0000000..96ad077 --- /dev/null +++ b/recipes/mtd/mtd-utils-1.4.6/osx.patch @@ -0,0 +1,931 @@ +diff -urN mtd-utils/compr_lzo.c mtd-utils.2/compr_lzo.c +--- mtd-utils/compr_lzo.c 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/compr_lzo.c 2012-10-04 17:22:23.000000000 +0200 +@@ -26,7 +26,9 @@ + #include + + #ifndef WITHOUT_LZO ++#ifndef __APPLE__ + #include ++#endif + #include + #include + #include "compr.h" +diff -urN mtd-utils/compr_zlib.c mtd-utils.2/compr_zlib.c +--- mtd-utils/compr_zlib.c 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/compr_zlib.c 2012-10-04 17:21:41.000000000 +0200 +@@ -39,7 +39,9 @@ + #include + #undef crc32 + #include ++#ifndef __APPLE__ + #include ++#endif + #include + #include "common.h" + #include "compr.h" +diff -urN mtd-utils/docfdisk.c mtd-utils.2/docfdisk.c +--- mtd-utils/docfdisk.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/docfdisk.c 2012-10-04 17:41:00.000000000 +0200 +@@ -24,13 +24,19 @@ + #include + #include + #include ++#ifdef __APPLE__ ++#define _DARWIN_C_SOURCE ++#include ++#endif + #include + #include + #include + #include + #include + ++#ifndef __APPLE__ + #include ++#endif + #include + #include + #include +diff -urN mtd-utils/flash_erase.c mtd-utils.2/flash_erase.c +--- mtd-utils/flash_erase.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/flash_erase.c 2012-10-04 17:13:48.000000000 +0200 +@@ -36,7 +36,11 @@ + #include + #include + #include +- ++#ifdef __APPLE__ ++#define __BYTE_ORDER BYTE_ORDER ++#define bswap_16(x) OSSwapInt16(x) ++#define bswap_32(x) OSSwapInt32(x) ++#endif + #include + #include + +diff -urN mtd-utils/ftl_check.c mtd-utils.2/ftl_check.c +--- mtd-utils/ftl_check.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/ftl_check.c 2012-10-04 17:14:11.000000000 +0200 +@@ -51,8 +51,12 @@ + #include + #include + ++#ifndef __APPLE__ + #include + #include ++#else ++#include ++#endif + + #if __BYTE_ORDER == __LITTLE_ENDIAN + # define TO_LE32(x) (x) +diff -urN mtd-utils/ftl_check.c.orig mtd-utils.2/ftl_check.c.orig +--- mtd-utils/ftl_check.c.orig 1970-01-01 01:00:00.000000000 +0100 ++++ mtd-utils.2/ftl_check.c.orig 2012-10-04 17:13:57.000000000 +0200 +@@ -0,0 +1,237 @@ ++/* Ported to MTD system. ++ * Based on: ++ */ ++/*====================================================================== ++ ++ Utility to create an FTL partition in a memory region ++ ++ ftl_check.c 1.10 1999/10/25 20:01:35 ++ ++ The contents of this file are subject to the Mozilla Public ++ License Version 1.1 (the "License"); you may not use this file ++ except in compliance with the License. You may obtain a copy of ++ the License at http://www.mozilla.org/MPL/ ++ ++ Software distributed under the License is distributed on an "AS ++ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or ++ implied. See the License for the specific language governing ++ rights and limitations under the License. ++ ++ The initial developer of the original code is David A. Hinds ++ . Portions created by David A. Hinds ++ are Copyright (C) 1999 David A. Hinds. All Rights Reserved. ++ ++ Alternatively, the contents of this file may be used under the ++ terms of the GNU Public License version 2 (the "GPL"), in which ++ case the provisions of the GPL are applicable instead of the ++ above. If you wish to allow the use of your version of this file ++ only under the terms of the GPL and not to allow others to use ++ your version of this file under the MPL, indicate your decision ++ by deleting the provisions above and replace them with the notice ++ and other provisions required by the GPL. If you do not delete ++ the provisions above, a recipient may use your version of this ++ file under either the MPL or the GPL. ++ ++ ======================================================================*/ ++ ++#define PROGRAM_NAME "ftl_check" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#ifndef __APPLE__ ++#include ++#include ++<<<<<<< Updated upstream ++======= ++#else ++#include ++#endif ++#include "common.h" ++>>>>>>> Stashed changes ++ ++#if __BYTE_ORDER == __LITTLE_ENDIAN ++# define TO_LE32(x) (x) ++# define TO_LE16(x) (x) ++#elif __BYTE_ORDER == __BIG_ENDIAN ++# define TO_LE32(x) (bswap_32(x)) ++# define TO_LE16(x) (bswap_16(x)) ++#else ++# error cannot detect endianess ++#endif ++ ++#define FROM_LE32(x) TO_LE32(x) ++#define FROM_LE16(x) TO_LE16(x) ++ ++/*====================================================================*/ ++ ++static void print_size(u_int s) ++{ ++ if ((s > 0x100000) && ((s % 0x100000) == 0)) ++ printf("%d mb", s / 0x100000); ++ else if ((s > 0x400) && ((s % 0x400) == 0)) ++ printf("%d kb", s / 0x400); ++ else ++ printf("%d bytes", s); ++} ++ ++/*====================================================================*/ ++ ++static void check_partition(int fd) ++{ ++ mtd_info_t mtd; ++ erase_unit_header_t hdr, hdr2; ++ u_int i, j, nbam, *bam; ++ int control, data, free, deleted; ++ ++ /* Get partition size, block size */ ++ if (ioctl(fd, MEMGETINFO, &mtd) != 0) { ++ perror("get info failed"); ++ return; ++ } ++ ++ printf("Memory region info:\n"); ++ printf(" Region size = "); ++ print_size(mtd.size); ++ printf(" Erase block size = "); ++ print_size(mtd.erasesize); ++ printf("\n\n"); ++ ++ for (i = 0; i < mtd.size/mtd.erasesize; i++) { ++ if (lseek(fd, (i * mtd.erasesize), SEEK_SET) == -1) { ++ perror("seek failed"); ++ break; ++ } ++ read(fd, &hdr, sizeof(hdr)); ++ if ((FROM_LE32(hdr.FormattedSize) > 0) && ++ (FROM_LE32(hdr.FormattedSize) <= mtd.size) && ++ (FROM_LE16(hdr.NumEraseUnits) > 0) && ++ (FROM_LE16(hdr.NumEraseUnits) <= mtd.size/mtd.erasesize)) ++ break; ++ } ++ if (i == mtd.size/mtd.erasesize) { ++ fprintf(stderr, "No valid erase unit headers!\n"); ++ return; ++ } ++ ++ printf("Partition header:\n"); ++ printf(" Formatted size = "); ++ print_size(FROM_LE32(hdr.FormattedSize)); ++ printf(", erase units = %d, transfer units = %d\n", ++ FROM_LE16(hdr.NumEraseUnits), hdr.NumTransferUnits); ++ printf(" Erase unit size = "); ++ print_size(1 << hdr.EraseUnitSize); ++ printf(", virtual block size = "); ++ print_size(1 << hdr.BlockSize); ++ printf("\n"); ++ ++ /* Create basic block allocation table for control blocks */ ++ nbam = (mtd.erasesize >> hdr.BlockSize); ++ bam = malloc(nbam * sizeof(u_int)); ++ ++ for (i = 0; i < FROM_LE16(hdr.NumEraseUnits); i++) { ++ if (lseek(fd, (i << hdr.EraseUnitSize), SEEK_SET) == -1) { ++ perror("seek failed"); ++ break; ++ } ++ if (read(fd, &hdr2, sizeof(hdr2)) == -1) { ++ perror("read failed"); ++ break; ++ } ++ printf("\nErase unit %d:\n", i); ++ if ((hdr2.FormattedSize != hdr.FormattedSize) || ++ (hdr2.NumEraseUnits != hdr.NumEraseUnits) || ++ (hdr2.SerialNumber != hdr.SerialNumber)) ++ printf(" Erase unit header is corrupt.\n"); ++ else if (FROM_LE16(hdr2.LogicalEUN) == 0xffff) ++ printf(" Transfer unit, erase count = %d\n", FROM_LE32(hdr2.EraseCount)); ++ else { ++ printf(" Logical unit %d, erase count = %d\n", ++ FROM_LE16(hdr2.LogicalEUN), FROM_LE32(hdr2.EraseCount)); ++ if (lseek(fd, (i << hdr.EraseUnitSize)+FROM_LE32(hdr.BAMOffset), ++ SEEK_SET) == -1) { ++ perror("seek failed"); ++ break; ++ } ++ if (read(fd, bam, nbam * sizeof(u_int)) == -1) { ++ perror("read failed"); ++ break; ++ } ++ free = deleted = control = data = 0; ++ for (j = 0; j < nbam; j++) { ++ if (BLOCK_FREE(FROM_LE32(bam[j]))) ++ free++; ++ else if (BLOCK_DELETED(FROM_LE32(bam[j]))) ++ deleted++; ++ else switch (BLOCK_TYPE(FROM_LE32(bam[j]))) { ++ case BLOCK_CONTROL: control++; break; ++ case BLOCK_DATA: data++; break; ++ default: break; ++ } ++ } ++ printf(" Block allocation: %d control, %d data, %d free," ++ " %d deleted\n", control, data, free, deleted); ++ } ++ } ++} /* format_partition */ ++ ++/* Show usage information */ ++void showusage(void) ++{ ++ fprintf(stderr, "usage: %s device\n", PROGRAM_NAME); ++} ++ ++/*====================================================================*/ ++ ++int main(int argc, char *argv[]) ++{ ++ int optch, errflg, fd; ++ struct stat buf; ++ ++ errflg = 0; ++ while ((optch = getopt(argc, argv, "h")) != -1) { ++ switch (optch) { ++ case 'h': ++ errflg = 1; break; ++ default: ++ errflg = -1; break; ++ } ++ } ++ if (errflg || (optind != argc-1)) { ++ showusage(); ++ exit(errflg > 0 ? 0 : EXIT_FAILURE); ++ } ++ ++ if (stat(argv[optind], &buf) != 0) { ++ perror("status check failed"); ++ exit(EXIT_FAILURE); ++ } ++ if (!(buf.st_mode & S_IFCHR)) { ++ fprintf(stderr, "%s is not a character special device\n", ++ argv[optind]); ++ exit(EXIT_FAILURE); ++ } ++ fd = open(argv[optind], O_RDONLY); ++ if (fd == -1) { ++ perror("open failed"); ++ exit(EXIT_FAILURE); ++ } ++ ++ check_partition(fd); ++ close(fd); ++ ++ exit(EXIT_SUCCESS); ++ return 0; ++} +diff -urN mtd-utils/ftl_format.c mtd-utils.2/ftl_format.c +--- mtd-utils/ftl_format.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/ftl_format.c 2012-10-04 17:13:48.000000000 +0200 +@@ -51,8 +51,12 @@ + #include + #include + ++#ifndef __APPLE__ + #include + #include ++#else ++#include ++#endif + + #if __BYTE_ORDER == __LITTLE_ENDIAN + # define TO_LE32(x) (x) +diff -urN mtd-utils/include/mtd/jffs2-user.h mtd-utils.2/include/mtd/jffs2-user.h +--- mtd-utils/include/mtd/jffs2-user.h 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/include/mtd/jffs2-user.h 2012-10-04 17:13:48.000000000 +0200 +@@ -9,8 +9,13 @@ + + /* This file is blessed for inclusion by userspace */ + #include +-#include ++ ++#ifndef __APPLE__ + #include ++#include ++#else ++#include ++#endif + + #undef cpu_to_je16 + #undef cpu_to_je32 +diff -urN mtd-utils/include/mtd/mtd-abi.h mtd-utils.2/include/mtd/mtd-abi.h +--- mtd-utils/include/mtd/mtd-abi.h 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/include/mtd/mtd-abi.h 2012-10-04 18:06:14.000000000 +0200 +@@ -20,7 +20,32 @@ + #ifndef __MTD_ABI_H__ + #define __MTD_ABI_H__ + ++#ifndef __APPLE__ + #include ++#else ++#ifndef CUSTOM_OSX_TYPES ++#define CUSTOM_OSX_TYPES ++#include ++#include ++typedef uint16_t __be16; ++typedef uint32_t __be32; ++typedef uint64_t __be64; ++typedef signed char __s8; ++typedef unsigned char __u8; ++typedef signed short __s16; ++typedef unsigned short __u16; ++typedef signed int __s32; ++typedef unsigned int __u32; ++typedef signed long __s64; ++typedef unsigned long __u64; ++ ++typedef unsigned short __le16; ++typedef unsigned int __le32; ++typedef unsigned long __le64; ++typedef long long __kernel_loff_t; ++typedef __kernel_loff_t loff_t; ++#endif ++#endif + + struct erase_info_user { + __u32 start; +diff -urN mtd-utils/include/mtd/ubi-media.h mtd-utils.2/include/mtd/ubi-media.h +--- mtd-utils/include/mtd/ubi-media.h 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/include/mtd/ubi-media.h 2012-10-04 18:06:00.000000000 +0200 +@@ -30,7 +30,32 @@ + #ifndef __UBI_MEDIA_H__ + #define __UBI_MEDIA_H__ + ++#ifdef __APPLE__ ++#ifndef CUSTOM_OSX_TYPES ++#define CUSTOM_OSX_TYPES ++#include ++#include ++typedef uint16_t __be16; ++typedef uint32_t __be32; ++typedef uint64_t __be64; ++typedef signed char __s8; ++typedef unsigned char __u8; ++typedef signed short __s16; ++typedef unsigned short __u16; ++typedef signed int __s32; ++typedef unsigned int __u32; ++typedef signed long __s64; ++typedef unsigned long __u64; ++ ++typedef unsigned short __le16; ++typedef unsigned int __le32; ++typedef unsigned long __le64; ++typedef long long __kernel_loff_t; ++typedef __kernel_loff_t loff_t; ++#endif ++#else + #include ++#endif + + /* The version of UBI images supported by this implementation */ + #define UBI_VERSION 1 +diff -urN mtd-utils/include/mtd_swab.h mtd-utils.2/include/mtd_swab.h +--- mtd-utils/include/mtd_swab.h 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/include/mtd_swab.h 2012-10-04 17:31:46.000000000 +0200 +@@ -1,7 +1,14 @@ + #ifndef MTD_SWAB_H + #define MTD_SWAB_H + ++#ifndef __APPLE__ + #include ++#else ++#define __BYTE_ORDER BYTE_ORDER ++#define __LITTLE_ENDIAN LITTLE_ENDIAN ++#define __BIG_ENDIAN BIG_ENDIAN ++#include ++#endif + + #define swab16(x) \ + ((uint16_t)( \ +diff -urN mtd-utils/jffs-dump.c mtd-utils.2/jffs-dump.c +--- mtd-utils/jffs-dump.c 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/jffs-dump.c 2012-10-04 17:13:48.000000000 +0200 +@@ -11,7 +11,25 @@ + #include + #include + #include ++#ifndef __APPLE__ + #include ++#else ++#include ++typedef signed char __s8; ++typedef unsigned char __u8; ++typedef signed short __s16; ++typedef unsigned short __u16; ++typedef signed int __s32; ++typedef unsigned int __u32; ++typedef signed long __s64; ++typedef unsigned long __u64; ++ ++typedef unsigned short __le16; ++typedef unsigned int __le32; ++typedef unsigned long __le64; ++typedef long long __kernel_loff_t; ++typedef __kernel_loff_t loff_t; ++#endif + #include + + #include "common.h" +diff -urN mtd-utils/jffs2dump.c mtd-utils.2/jffs2dump.c +--- mtd-utils/jffs2dump.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/jffs2dump.c 2012-10-04 17:28:25.000000000 +0200 +@@ -28,11 +28,22 @@ + #include + #include + #include ++#ifndef __APPLE__ + #include ++#endif + #include + #include +-#include ++#ifndef __APPLE__ + #include ++#include ++#else ++#define __BYTE_ORDER BYTE_ORDER ++#define __LITTLE_ENDIAN LITTLE_ENDIAN ++#define __BIG_ENDIAN BIG_ENDIAN ++#include ++#define bswap_16(x) OSSwapInt16(x) ++#define bswap_32(x) OSSwapInt32(x) ++#endif + #include + #include + #include "summary.h" +diff -urN mtd-utils/lib/libfec.c mtd-utils.2/lib/libfec.c +--- mtd-utils/lib/libfec.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/lib/libfec.c 2012-10-04 17:13:48.000000000 +0200 +@@ -45,6 +45,9 @@ + #include + #include + #include ++#ifdef __APPLE__ ++#include ++#endif + + /* + * stuff used for testing purposes only +@@ -54,7 +57,7 @@ + #define DEB(x) + #define DDB(x) x + #define DEBUG 0 /* minimal debugging */ +-#ifdef MSDOS ++#if defined(MSDOS) || defined(__APPLE__) + #include + struct timeval { + unsigned long ticks; +diff -urN mtd-utils/mkfs.jffs2.c mtd-utils.2/mkfs.jffs2.c +--- mtd-utils/mkfs.jffs2.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/mkfs.jffs2.c 2012-10-04 17:23:11.000000000 +0200 +@@ -70,7 +70,16 @@ + #include + #include + #endif ++#ifndef __APPLE__ + #include ++#else ++#define __BYTE_ORDER BYTE_ORDER ++#define __LITTLE_ENDIAN LITTLE_ENDIAN ++#define __BIG_ENDIAN BIG_ENDIAN ++#include ++#define bswap_16(x) OSSwapInt16(x) ++#define bswap_32(x) OSSwapInt32(x) ++#endif + #include + #include + +diff -urN mtd-utils/mkfs.ubifs/compr.c mtd-utils.2/mkfs.ubifs/compr.c +--- mtd-utils/mkfs.ubifs/compr.c 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/mkfs.ubifs/compr.c 2012-10-04 18:12:47.000000000 +0200 +@@ -25,7 +25,9 @@ + #include + #include + #include ++#ifndef __APPLE__ + #include ++#endif + + #define crc32 __zlib_crc32 + #include +diff -urN mtd-utils/mkfs.ubifs/defs.h mtd-utils.2/mkfs.ubifs/defs.h +--- mtd-utils/mkfs.ubifs/defs.h 2012-10-04 16:25:48.000000000 +0200 ++++ mtd-utils.2/mkfs.ubifs/defs.h 2012-10-04 18:11:18.000000000 +0200 +@@ -54,6 +54,8 @@ + size_t len; + }; + ++ ++#ifndef __APPLE__ + /** + * fls - find last (most-significant) bit set + * @x: the word to search +@@ -89,6 +91,7 @@ + } + return r; + } ++#endif + + #define do_div(n,base) ({ \ + int __res; \ +diff -urN mtd-utils/mkfs.ubifs/mkfs.ubifs.c mtd-utils.2/mkfs.ubifs/mkfs.ubifs.c +--- mtd-utils/mkfs.ubifs/mkfs.ubifs.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/mkfs.ubifs/mkfs.ubifs.c 2012-10-04 18:21:56.000000000 +0200 +@@ -23,6 +23,14 @@ + #include "mkfs.ubifs.h" + #include + ++#ifdef __APPLE__ ++#define llseek lseek ++#define off64_t off_t ++# ifndef O_LARGEFILE ++# define O_LARGEFILE 0 ++# endif ++#endif ++ + #define PROGRAM_VERSION "1.5" + + /* Size (prime number) of hash table for link counting */ +@@ -821,7 +829,7 @@ + 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) ++ if (llseek(out_fd, pos, SEEK_SET) != pos) + return sys_err_msg("lseek64 failed seeking %lld", + (long long)pos); + +@@ -1079,6 +1087,7 @@ + + if (c->default_compr != UBIFS_COMPR_NONE) + use_flags |= UBIFS_COMPR_FL; ++#ifndef __APPLE__ + if (flags & FS_COMPR_FL) + use_flags |= UBIFS_COMPR_FL; + if (flags & FS_SYNC_FL) +@@ -1089,7 +1098,7 @@ + use_flags |= UBIFS_APPEND_FL; + if (flags & FS_DIRSYNC_FL && S_ISDIR(st->st_mode)) + use_flags |= UBIFS_DIRSYNC_FL; +- ++#endif + memset(ino, 0, UBIFS_INO_NODE_SZ); + + ino_key_init(&key, inum); +@@ -1158,8 +1167,10 @@ + fd = dirfd(dir); + if (fd == -1) + return sys_err_msg("dirfd failed"); ++#ifndef __APPLE__ + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) + flags = 0; ++#endif + } + + return add_inode(st, inum, flags); +@@ -1343,10 +1354,12 @@ + key_write(&key, &dn->key); + dn->size = cpu_to_le32(bytes_read); + out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ; ++#ifndef __APPLE__ + 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); +@@ -1388,8 +1401,10 @@ + if (fd == -1) + return sys_err_msg("failed to open file '%s'", + path_name); ++#ifndef __APPLE__ + if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) + flags = 0; ++#endif + if (close(fd) == -1) + return sys_err_msg("failed to close file '%s'", + path_name); +diff -urN mtd-utils/mkfs.ubifs/mkfs.ubifs.h mtd-utils.2/mkfs.ubifs/mkfs.ubifs.h +--- mtd-utils/mkfs.ubifs/mkfs.ubifs.h 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/mkfs.ubifs/mkfs.ubifs.h 2012-10-04 18:08:35.000000000 +0200 +@@ -31,10 +31,46 @@ + #include + #include + #include +-#include ++#ifndef __APPLE__ + #include ++#include ++#else ++#define __BYTE_ORDER BYTE_ORDER ++#define __LITTLE_ENDIAN LITTLE_ENDIAN ++#define __BIG_ENDIAN BIG_ENDIAN ++#include ++#define bswap_16(x) OSSwapInt16(x) ++#define bswap_32(x) OSSwapInt32(x) ++#endif ++#ifndef __APPLE__ + #include ++#else ++#ifndef CUSTOM_OSX_TYPES ++#define CUSTOM_OSX_TYPES ++#include ++#include ++typedef uint16_t __be16; ++typedef uint32_t __be32; ++typedef uint64_t __be64; ++typedef signed char __s8; ++typedef unsigned char __u8; ++typedef signed short __s16; ++typedef unsigned short __u16; ++typedef signed int __s32; ++typedef unsigned int __u32; ++typedef signed long __s64; ++typedef unsigned long __u64; ++ ++typedef unsigned short __le16; ++typedef unsigned int __le32; ++typedef unsigned long __le64; ++typedef long long __kernel_loff_t; ++typedef __kernel_loff_t loff_t; ++#endif ++#endif ++#ifndef __APPLE__ + #include ++#endif + + #include + #include +diff -urN mtd-utils/mkfs.ubifs/ubifs-media.h mtd-utils.2/mkfs.ubifs/ubifs-media.h +--- mtd-utils/mkfs.ubifs/ubifs-media.h 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/mkfs.ubifs/ubifs-media.h 2012-10-04 18:14:11.000000000 +0200 +@@ -33,6 +33,32 @@ + #ifndef __UBIFS_MEDIA_H__ + #define __UBIFS_MEDIA_H__ + ++#ifdef __APPLE__ ++#ifndef CUSTOM_OSX_TYPES ++#define CUSTOM_OSX_TYPES ++#include ++#include ++typedef uint16_t __be16; ++typedef uint32_t __be32; ++typedef uint64_t __be64; ++typedef signed char __s8; ++typedef unsigned char __u8; ++typedef signed short __s16; ++typedef unsigned short __u16; ++typedef signed int __s32; ++typedef unsigned int __u32; ++typedef signed long __s64; ++typedef unsigned long __u64; ++ ++typedef unsigned short __le16; ++typedef unsigned int __le32; ++typedef unsigned long __le64; ++typedef long long __kernel_loff_t; ++typedef __kernel_loff_t loff_t; ++#endif ++#endif ++ ++ + /* UBIFS node magic number (must not have the padding byte first or last) */ + #define UBIFS_NODE_MAGIC 0x06101831 + +diff -urN mtd-utils/nanddump.c mtd-utils.2/nanddump.c +--- mtd-utils/nanddump.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/nanddump.c 2012-10-04 17:13:48.000000000 +0200 +@@ -30,7 +30,9 @@ + #include + #include + ++#ifndef __APPLE__ + #include ++#endif + #include + #include "common.h" + #include +diff -urN mtd-utils/nandtest.c mtd-utils.2/nandtest.c +--- mtd-utils/nandtest.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/nandtest.c 2012-10-04 17:24:34.000000000 +0200 +@@ -14,7 +14,9 @@ + #include + #include + ++#ifndef __APPLE__ + #include ++#endif + #include "mtd/mtd-user.h" + + void usage(void) +diff -urN mtd-utils/nandwrite.c mtd-utils.2/nandwrite.c +--- mtd-utils/nandwrite.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/nandwrite.c 2012-10-04 17:23:54.000000000 +0200 +@@ -39,7 +39,9 @@ + #include + #include + ++#ifndef __APPLE__ + #include ++#endif + #include "mtd/mtd-user.h" + #include "common.h" + #include +diff -urN mtd-utils/nftl_format.c mtd-utils.2/nftl_format.c +--- mtd-utils/nftl_format.c 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/nftl_format.c 2012-10-04 17:39:34.000000000 +0200 +@@ -28,13 +28,19 @@ + #include + #include + #include ++#ifdef __APPLE__ ++#define _DARWIN_C_SOURCE ++#include ++#endif + #include + #include + #include + #include + #include + ++#ifndef __APPLE__ + #include ++#endif + #include + #include + #include +diff -urN mtd-utils/nftldump.c mtd-utils.2/nftldump.c +--- mtd-utils/nftldump.c 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/nftldump.c 2012-10-04 17:30:37.000000000 +0200 +@@ -34,7 +34,9 @@ + #include + + #include ++#ifndef __APPLE__ + #include ++#endif + #include + #include + #include +diff -urN mtd-utils/rbtree.h mtd-utils.2/rbtree.h +--- mtd-utils/rbtree.h 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/rbtree.h 2012-10-04 17:17:40.000000000 +0200 +@@ -94,8 +94,10 @@ + #ifndef _LINUX_RBTREE_H + #define _LINUX_RBTREE_H + ++#ifndef __APPLE__ + #include + #include ++#endif + + struct rb_node + { +diff -urN mtd-utils/recv_image.c mtd-utils.2/recv_image.c +--- mtd-utils/recv_image.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/recv_image.c 2012-10-04 17:51:38.000000000 +0200 +@@ -4,7 +4,15 @@ + #define _BSD_SOURCE /* struct ip_mreq */ + + #include ++#ifndef __APPLE__ + #include ++#else ++#define _DARWIN_C_SOURCE 1 ++#ifndef IPV6_ADD_MEMBERSHIP ++#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP ++#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP ++#endif ++#endif + #include + #include + #include +diff -urN mtd-utils/rfddump.c mtd-utils.2/rfddump.c +--- mtd-utils/rfddump.c 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/rfddump.c 2012-10-04 17:42:38.000000000 +0200 +@@ -25,7 +25,9 @@ + #include + + #include ++#ifndef __APPLE__ + #include ++#endif + #include + + /* next is an array of mapping for each corresponding sector */ +diff -urN mtd-utils/rfdformat.c mtd-utils.2/rfdformat.c +--- mtd-utils/rfdformat.c 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/rfdformat.c 2012-10-04 17:43:17.000000000 +0200 +@@ -27,7 +27,9 @@ + #include + + #include ++#ifndef __APPLE__ + #include ++#endif + + void display_help(void) + { +diff -urN mtd-utils/serve_image.c mtd-utils.2/serve_image.c +--- mtd-utils/serve_image.c 2012-10-04 17:11:52.000000000 +0200 ++++ mtd-utils.2/serve_image.c 2012-10-04 17:43:59.000000000 +0200 +@@ -3,7 +3,9 @@ + + #include + #include +-#include ++#ifndef __APPLE__ ++#include ++#endif + #include + #include + #include +diff -urN mtd-utils/summary.h mtd-utils.2/summary.h +--- mtd-utils/summary.h 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/summary.h 2012-10-04 17:29:20.000000000 +0200 +@@ -12,7 +12,9 @@ + #ifndef JFFS2_SUMMARY_H + #define JFFS2_SUMMARY_H + ++#ifndef __APPLE__ + #include ++#endif + #include + + #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ +diff -urN mtd-utils/sumtool.c mtd-utils.2/sumtool.c +--- mtd-utils/sumtool.c 2012-10-04 16:25:49.000000000 +0200 ++++ mtd-utils.2/sumtool.c 2012-10-04 17:52:53.000000000 +0200 +@@ -40,11 +40,22 @@ + #include + #include + #include ++#ifndef __APPLE__ + #include ++#endif + #include + #include +-#include ++#ifndef __APPLE__ + #include ++#include ++#else ++#define __BYTE_ORDER BYTE_ORDER ++#define __LITTLE_ENDIAN LITTLE_ENDIAN ++#define __BIG_ENDIAN BIG_ENDIAN ++#include ++#define bswap_16(x) OSSwapInt16(x) ++#define bswap_32(x) OSSwapInt32(x) ++#endif + #include + #include + #include "summary.h" diff --git a/recipes/mtd/mtd-utils.inc b/recipes/mtd/mtd-utils.inc index 6f8b191..18da31c 100644 --- a/recipes/mtd/mtd-utils.inc +++ b/recipes/mtd/mtd-utils.inc @@ -9,7 +9,7 @@ COMPATIBLE_HOST_ARCHS = ".*linux" inherit c make auto-package-utils SRC_URI = "git://git.infradead.org/mtd-utils.git;protocol=git;tag=v${PV}" -SRC_URI:>HOST_OS_darwin = " file://osx.patch" +SRC_URI:>HOST_KERNEL_darwin = " file://osx.patch" S = "${SRCDIR}/mtd-utils" DEPENDS = "libz liblzo2 libuuid libm" @@ -26,6 +26,7 @@ do_configure () { EXTRA_OEMAKE = "'LDFLAGS=${LDFLAGS}' \ 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR'" +EXTRA_OEMAKE:>native += " 'PREFIX=${prefix}' 'SBINDIR=${bindir}'" do_install () { oe_runmake install DESTDIR=${D}