1
1

Initial dump from Zyxel

This commit is contained in:
2026-04-17 17:00:52 +02:00
commit 81fec250f4
23116 changed files with 5231237 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
#
# Copyright (C) 2009-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd-utils
PKG_VERSION:=2.0.2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat
PKG_SOURCE_URL:=@ZyXEL_SITE/opensource/tools
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL:=1
PKG_FIXUP:=autoreconf
PKG_FLAGS:=nonshared
#PKG_BUILD_DEPENDS:=util-linux lzo zlib
#Start, ZyXEL, use zlib, not use lzo
PKG_BUILD_DEPENDS:=util-linux zlib
#End, ZyXEL
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=
include $(INCLUDE_DIR)/package.mk
FILES:=
ifneq ($(CONFIG_LINUX_2_4),y)
FILES += \
ubiattach \
ubicrc32 \
ubiblock \
ubidetach \
ubiformat \
ubimkvol \
ubinfo \
ubinize \
ubirename \
ubirmvol \
ubirsvol \
ubiupdatevol \
flash_erase \
nanddump \
nandwrite \
nandtest \
mtdinfo
endif
define PartGen
define Package/mtd-utils-$(subst _,-,$(1))
TITLE:=MTD $(1)
URL:=http://www.linux-mtd.infradead.org/
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=mtd-utils +zlib +libuuid
endef
endef
# +libext2fs
define Package/mtd-utils
TITLE:=Utilities for flash info/debug
SECTION:=utils
CATEGORY:=Utilities
MENU:=1
endef
define Package/mtd-utils/description
Utilities for manipulating memory technology devices.
endef
define Package/mtd-utils/install
true
endef
$(foreach file,$(FILES),$(eval $(call PartGen,$(file))))
MAKE_FLAGS += LDLIBS+="$(LIBGCC_S)"
MAKE_FLAGS += \
DESTDIR="$(PKG_INSTALL_DIR)" \
BUILDDIR="$(PKG_BUILD_DIR)" \
LDLIBS+="$(LIBGCC_S) -L$(PKG_BUILD_DIR)/lib -lmtd " \
CFLAGS+="$(CFLAGS)" \
WITHOUT_XATTR=1 WITHOUT_LZO=1 WITHOUT_XZ=1
CONFIGURE_ARGS += \
--disable-tests \
--without-xattr \
--without-lzo
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
define PartInstall
define Package/mtd-utils-$(subst _,-,$(1))/install
$(INSTALL_DIR) \
$$(1)/usr/sbin
$(INSTALL_BIN) \
$(PKG_BUILD_DIR)/$(1) \
$$(1)/usr/sbin/
endef
endef
define Build/Prepare
$(PKG_UNPACK)
$(Build/Patch)
endef
$(foreach file,$(FILES),$(eval $(call PartInstall,$(file))))
$(eval $(call BuildPackage,mtd-utils))
$(foreach file,$(FILES),$(eval $(call BuildPackage,mtd-utils-$(subst _,-,$(file)))))
+2
View File
@@ -0,0 +1,2 @@
#include <string.h>
#define fls local_fls
+18
View File
@@ -0,0 +1,18 @@
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H
#include <mtd/ubi-media.h>
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;
typedef __u16 __le16;
typedef __u32 __le32;
typedef __u64 __le64;
typedef __u64 off64_t;
typedef __u16 __sum16;
typedef __u32 __wsum;
#endif /* _LINUX_TYPES_H */
@@ -0,0 +1,10 @@
--- a/lib/libfec.c
+++ b/lib/libfec.c
@@ -45,6 +45,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include "libfec.h"
/*
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
From 7d27becbb355853ba778e8b83fe171eecb8195d2 Mon Sep 17 00:00:00 2001
From: Christian Lamparter <chunkeey@gmail.com>
Date: Thu, 7 Jun 2018 22:36:19 +0200
Subject: [PATCH] Revert "Return correct error number in ubi_get_vol_info1"
This reverts commit dede98ffb706676309488d7cc660f569548d5930.
---
lib/libubi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/libubi.c b/lib/libubi.c
index b50e68a..978b433 100644
--- a/lib/libubi.c
+++ b/lib/libubi.c
@@ -1240,11 +1240,8 @@ int ubi_get_vol_info1(libubi_t desc, int dev_num, int vol_id,
info->dev_num = dev_num;
info->vol_id = vol_id;
- if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor)) {
- if (errno == ENOENT)
- errno = ENODEV;
+ if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor))
return -1;
- }
ret = vol_read_data(lib->vol_type, dev_num, vol_id, buf, 50);
if (ret < 0)
--
2.17.1
@@ -0,0 +1,150 @@
--- a/compr_lzo.c
+++ b/compr_lzo.c
@@ -26,7 +26,6 @@
#include <string.h>
#ifndef WITHOUT_LZO
-#include <asm/types.h>
#include <linux/jffs2.h>
#include <lzo/lzo1x.h>
#include "compr.h"
--- a/compr_zlib.c
+++ b/compr_zlib.c
@@ -39,7 +39,6 @@
#include <zlib.h>
#undef crc32
#include <stdio.h>
-#include <asm/types.h>
#include <linux/jffs2.h>
#include "common.h"
#include "compr.h"
--- a/rbtree.h
+++ b/rbtree.h
@@ -94,8 +94,7 @@ static inline struct page * rb_insert_pa
#ifndef _LINUX_RBTREE_H
#define _LINUX_RBTREE_H
-#include <linux/kernel.h>
-#include <linux/stddef.h>
+#include <stddef.h>
struct rb_node
{
--- 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 <asm/byteorder.h>
+#else
+#include <stdint.h>
+typedef uint8_t __u8;
+typedef uint16_t __be16;
+typedef uint32_t __be32;
+typedef uint64_t __be64;
+#endif
/* 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 <endian.h>
#include <byteswap.h>
#include <linux/types.h>
+#ifdef __linux__
#include <linux/fs.h>
+#else
+# ifndef O_LARGEFILE
+# define O_LARGEFILE 0
+# endif
+# define llseek lseek
+#endif
#include <getopt.h>
#include <sys/types.h>
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -821,8 +821,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)
@@ -1079,6 +1079,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)
@@ -1089,6 +1090,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
memset(ino, 0, UBIFS_INO_NODE_SZ);
@@ -1158,7 +1160,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;
}
@@ -1343,10 +1347,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);
@@ -1388,7 +1394,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");
if (!strcmp(buf, "/"))
@@ -0,0 +1,457 @@
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,11 @@ else
LZOLDLIBS = -llzo2
endif
+ifeq ($(shell uname -o),Cygwin)
+CPPFLAGS += -I./include/cygwin
+endif
+
+ifneq ($(shell uname -o),Cygwin)
SUBDIRS = lib ubi-utils mkfs.ubifs
TESTS = tests
@@ -23,6 +28,10 @@ TARGETS = ftl_format flash_erase nanddum
rfddump rfdformat \
serve_image recv_image \
sumtool #jffs2reader
+else
+SUBDIRS =
+TARGETS = mkfs.jffs2
+endif
SCRIPTS = flash_eraseall
SYMLINKS =
--- /dev/null
+++ b/include/cygwin/bits-byteswap.h
@@ -0,0 +1,132 @@
+/* Macros to swap the order of bytes in integer values.
+ Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
+#endif
+
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
+/* Swap bytes in 16 bit value. */
+#define __bswap_constant_16(x) \
+ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+
+#ifdef __GNUC__
+# if __GNUC__ >= 2
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ register unsigned short int __v, __x = (x); \
+ if (__builtin_constant_p (__x)) \
+ __v = __bswap_constant_16 (__x); \
+ else \
+ __asm__ ("rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (__x) \
+ : "cc"); \
+ __v; }))
+# else
+/* This is better than nothing. */
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); }))
+# endif
+#else
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+ return __bswap_constant_16 (__bsx);
+}
+#endif
+
+/* Swap bytes in 32 bit value. */
+#define __bswap_constant_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+#ifdef __GNUC__
+# if __GNUC__ >= 2
+/* To swap the bytes in a word the i486 processors and up provide the
+ `bswap' opcode. On i386 we have to use three instructions. */
+# if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __v, __x = (x); \
+ if (__builtin_constant_p (__x)) \
+ __v = __bswap_constant_32 (__x); \
+ else \
+ __asm__ ("rorw $8, %w0;" \
+ "rorl $16, %0;" \
+ "rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (__x) \
+ : "cc"); \
+ __v; }))
+# else
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __v, __x = (x); \
+ if (__builtin_constant_p (__x)) \
+ __v = __bswap_constant_32 (__x); \
+ else \
+ __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); \
+ __v; }))
+# endif
+# else
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __x = (x); __bswap_constant_32 (__x); }))
+# endif
+#else
+static __inline unsigned int
+__bswap_32 (unsigned int __bsx)
+{
+ return __bswap_constant_32 (__bsx);
+}
+#endif
+
+
+#if defined __GNUC__ && __GNUC__ >= 2
+/* Swap bytes in 64 bit value. */
+#define __bswap_constant_64(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) \
+ | (((x) & 0x00ff000000000000ull) >> 40) \
+ | (((x) & 0x0000ff0000000000ull) >> 24) \
+ | (((x) & 0x000000ff00000000ull) >> 8) \
+ | (((x) & 0x00000000ff000000ull) << 8) \
+ | (((x) & 0x0000000000ff0000ull) << 24) \
+ | (((x) & 0x000000000000ff00ull) << 40) \
+ | (((x) & 0x00000000000000ffull) << 56))
+
+# define __bswap_64(x) \
+ (__extension__ \
+ ({ union { __extension__ unsigned long long int __ll; \
+ unsigned long int __l[2]; } __w, __r; \
+ if (__builtin_constant_p (x)) \
+ __r.__ll = __bswap_constant_64 (x); \
+ else \
+ { \
+ __w.__ll = (x); \
+ __r.__l[0] = __bswap_32 (__w.__l[1]); \
+ __r.__l[1] = __bswap_32 (__w.__l[0]); \
+ } \
+ __r.__ll; }))
+#endif
+
+#endif /* _BITS_BYTESWAP_H */
--- /dev/null
+++ b/include/cygwin/byteswap.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H 1
+
+/* Get the machine specific, optimized definitions. */
+#include "bits-byteswap.h"
+
+
+/* The following definitions must all be macros since otherwise some
+ of the possible optimizations are not possible. */
+
+/* Return a value with all bytes in the 16 bit argument swapped. */
+#define bswap_16(x) __bswap_16 (x)
+
+/* Return a value with all bytes in the 32 bit argument swapped. */
+#define bswap_32(x) __bswap_32 (x)
+
+#if defined __GNUC__ && __GNUC__ >= 2
+/* Return a value with all bytes in the 64 bit argument swapped. */
+# define bswap_64(x) __bswap_64 (x)
+#endif
+
+#endif /* byteswap.h */
--- /dev/null
+++ b/include/cygwin/endian.h
@@ -0,0 +1,26 @@
+#ifndef _CYGENDIAN_H_
+#define _CYGENDIAN_H_
+
+#ifdef __CYGWIN__
+
+#include <sys/param.h>
+
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#ifndef BYTE_ORDER
+#define BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#endif /* __CYGWIN__ */
+
+#endif /* _CYGENDIAN_H_ */
--- /dev/null
+++ b/include/cygwin/ioctl.h
@@ -0,0 +1,38 @@
+#ifndef _CYGIOCTL_H_
+#define _CYGIOCTL_H_
+
+#ifdef __CYGWIN__
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+#endif /* __CYGWIN__ */
+
+#endif /* _CYGIOCTL_H_ */
--- /dev/null
+++ b/include/cygwin/pread.c
@@ -0,0 +1,41 @@
+#ifdef __CYGWIN__
+
+#include <errno.h>
+
+ssize_t
+pread(int fd, void *p, size_t n, off_t off)
+{
+ off_t ooff;
+ int oerrno;
+
+ if ((ooff = lseek(fd, off, SEEK_SET)) == -1)
+ return -1;
+
+ n = read(fd, p, n);
+
+ oerrno = errno;
+ lseek(fd, ooff, SEEK_SET);
+ errno = oerrno;
+
+ return n;
+}
+
+ssize_t
+pwrite(int fd, const void *p, size_t n, off_t off)
+{
+ off_t ooff;
+ int oerrno;
+
+ if ((ooff = lseek(fd, off, SEEK_SET)) == -1)
+ return -1;
+
+ n = write(fd, p, n);
+
+ oerrno = errno;
+ lseek(fd, ooff, SEEK_SET);
+ errno = oerrno;
+
+ return n;
+}
+
+#endif /* __CYGWIN__ */
--- /dev/null
+++ b/lnconf.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Generic configure replacement.
+#
+# $Id: lnconf.sh,v 1.1 2004/04/05 21:55:59 igor Exp $
+#
+# Copies all files from the script directory to the current one.
+# Intended to replace 'configure' for packages that don't have one, to
+# allow building outside of the source tree.
+#
+# Note: this does not do any fancy things with detecting shells and
+# supporting other platforms. But it should work on Cygwin.
+
+# find out where the script is located
+tdir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
+test "x$tdir" = "x$0" && tdir=.
+
+a_srcdir=`cd $tdir; pwd`
+a_destdir=`pwd`
+
+# sanity checks:
+# are we in the script directory?
+test "x$a_srcdir" = "x$a_destdir" && exit 0
+# is there any chance that this is the script directory?
+test "x`cd "$a_srcdir" && /bin/ls -id`" = "x`/bin/ls -id`" && exit 0
+
+# try to find lndir and use it if it's available
+LNDIR="`which lndir 2>/dev/null`"
+if [ "x$LNDIR" = "x" ]; then
+ lndir() {
+ test "x$1" = "x" && return 1
+ # be careful of the current directory
+ DINODE=`find . -maxdepth 0 -ls | sed 's/ .*$//'`
+ case "`pwd`" in
+ "`cd "$1" && pwd`"/*) CUR="-type d -inum $DINODE -prune -o";;
+ esac
+ # duplicate the directory structure
+ (cd "$1" && find . $CUR -type d -mindepth 1 -print) | xargs -tr mkdir -p
+ # copy all symbolic links
+ (cd "$1" && find . $CUR -type l -mindepth 1 -print) | xargs -ri sh -c "ln -s \"\`readlink "$1/{}"\`\" \"{}\""
+ # or simply
+ #(cd "$1" && find . $CUR -type l -mindepth 1 -print) | xargs -ri ln -s "$1"/{} {}
+ # link all files
+ (cd "$1" && find . $CUR -type f -mindepth 1 -print) | xargs -ri ln -s "$1"/{} {}
+ }
+else
+ lndir() {
+ "$LNDIR" "$@"
+ }
+fi
+
+lndir "$tdir"
+
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -77,6 +77,14 @@
#include "rbtree.h"
#include "common.h"
+#ifdef __CYGWIN__
+#include <cygwin/ioctl.h>
+#include <cygwin/endian.h>
+#include <cygwin/pread.c>
+# define IFTODT(mode) (((mode) & 0170000) >> 12)
+# define DTTOIF(dirtype) ((dirtype) << 12)
+#endif /* __CYGWIN__ */
+
/* Do not use the weird XPG version of basename */
#undef basename
@@ -376,7 +384,7 @@ static struct filesystem_entry *recursiv
the following macros use it if available or use a hacky workaround...
*/
-#ifdef __GNUC__
+#if defined __GNUC__ && !defined __CYGWIN__
#define SCANF_PREFIX "a"
#define SCANF_STRING(s) (&s)
#define GETCWD_SIZE 0
@@ -459,6 +467,14 @@ static int interpret_table_entry(struct
}
entry = find_filesystem_entry(root, name, mode);
if (entry && !(count > 0 && (type == 'c' || type == 'b'))) {
+ /* Check the type */
+ if ((mode & S_IFMT) != (entry->sb.st_mode & S_IFMT)) {
+ error_msg ("skipping device_table entry '%s': type mismatch!", name);
+ free(name);
+ free(hostpath);
+ return 1;
+ }
+
/* Ok, we just need to fixup the existing entry
* and we will be all done... */
entry->sb.st_uid = uid;
@@ -468,11 +484,21 @@ static int interpret_table_entry(struct
entry->sb.st_rdev = makedev(major, minor);
}
} else {
+ if (type == 'f' || type == 'l') {
+ error_msg ("skipping device_table entry '%s': file does not exist!", name);
+ free(name);
+ free(hostpath);
+ return 1;
+ }
/* If parent is NULL (happens with device table entries),
* try and find our parent now) */
tmp = strdup(name);
dir = dirname(tmp);
- parent = find_filesystem_entry(root, dir, S_IFDIR);
+ if (!strcmp(dir, "/")) {
+ parent = root;
+ } else {
+ parent = find_filesystem_entry(root, dir, S_IFDIR);
+ }
free(tmp);
if (parent == NULL) {
errmsg ("skipping device_table entry '%s': no parent directory!", name);
@@ -486,6 +512,7 @@ static int interpret_table_entry(struct
add_host_filesystem_entry(name, hostpath, uid, gid, mode, 0, parent);
break;
case 'f':
+ case 'l':
add_host_filesystem_entry(name, hostpath, uid, gid, mode, 0, parent);
break;
case 'p':
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -32,6 +32,9 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#ifdef __CYGWIN__
+#include <cygwin/ioctl.h>
+#endif
#include <libubi.h>
#include "libubi_int.h"
#include "common.h"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,11 @@
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,7 +7,7 @@ SUBDIRS =
# CFLAGS += -Werror
CPPFLAGS += -I../include
LIBS = libmtd
-TARGETS = libmtd.a
+override TARGETS = libmtd.a
include ../common.mk
@@ -0,0 +1,20 @@
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -469,7 +469,7 @@ static int interpret_table_entry(struct
if (entry && !(count > 0 && (type == 'c' || type == 'b'))) {
/* Check the type */
if ((mode & S_IFMT) != (entry->sb.st_mode & S_IFMT)) {
- error_msg ("skipping device_table entry '%s': type mismatch!", name);
+ sys_errmsg ("skipping device_table entry '%s': type mismatch!", name);
free(name);
free(hostpath);
return 1;
@@ -485,7 +485,7 @@ static int interpret_table_entry(struct
}
} else {
if (type == 'f' || type == 'l') {
- error_msg ("skipping device_table entry '%s': file does not exist!", name);
+ sys_errmsg ("skipping device_table entry '%s': file does not exist!", name);
free(name);
free(hostpath);
return 1;
@@ -0,0 +1,13 @@
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -114,8 +114,8 @@ struct otp_info {
#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
#define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo)
#define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
-#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
-#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
+#define MEMGETBADBLOCK _IOW('M', 11, loff_t)
+#define MEMSETBADBLOCK _IOW('M', 12, loff_t)
#define OTPSELECT _IOR('M', 13, int)
#define OTPGETREGIONCOUNT _IOW('M', 14, int)
#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
@@ -0,0 +1,119 @@
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#include <lzo/lzo1x.h>
#include <linux/types.h>
#define crc32 __zlib_crc32
@@ -35,7 +34,6 @@
#include "ubifs-media.h"
#include "mkfs.ubifs.h"
-static void *lzo_mem;
static unsigned long long errcnt = 0;
static struct ubifs_info *c = &info_;
@@ -86,6 +84,25 @@ static int zlib_deflate(void *in_buf, si
return 0;
}
+#ifndef WITHOUT_LZO
+#include <lzo/lzo1x.h>
+
+static void *lzo_mem;
+
+static int lzo_init(void)
+{
+ lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
+ if (!lzo_mem)
+ return -1;
+
+ return 0;
+}
+
+static void lzo_fini(void)
+{
+ free(lzo_mem);
+}
+
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -103,6 +120,12 @@ static int lzo_compress(void *in_buf, si
return 0;
}
+#else
+static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
+ size_t *out_len) { return -1; }
+static inline int lzo_init(void) { return 0; }
+static inline void lzo_fini(void) { }
+#endif
static int no_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
@@ -123,7 +146,6 @@ static int favor_lzo_compress(void *in_b
lzo_len = zlib_len = *out_len;
lzo_ret = lzo_compress(in_buf, in_len, out_buf, &lzo_len);
zlib_ret = zlib_deflate(in_buf, in_len, zlib_buf, &zlib_len);
-
if (lzo_ret && zlib_ret)
/* Both compressors failed */
return -1;
@@ -198,23 +220,28 @@ int compress_data(void *in_buf, size_t i
int init_compression(void)
{
- lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
- if (!lzo_mem)
- return -1;
+ int ret;
+
+ ret = lzo_init();
+ if (ret)
+ goto err;
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
- if (!zlib_buf) {
- free(lzo_mem);
- return -1;
- }
+ if (!zlib_buf)
+ goto err_lzo;
return 0;
+
+err_lzo:
+ lzo_fini();
+err:
+ return ret;
}
void destroy_compression(void)
{
free(zlib_buf);
- free(lzo_mem);
+ lzo_fini();
if (errcnt)
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
}
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
@@ -6,7 +6,13 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
TARGETS = mkfs.ubifs
-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
+ifeq ($(WITHOUT_LZO), 1)
+ CPPFLAGS += -DWITHOUT_LZO
+else
+ LZOLDLIBS = -llzo2
+endif
+
+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
@@ -0,0 +1,404 @@
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# -*- sh -*-
-CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) -I./include/linux/lzma
+CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(XZCPPFLAGS) -I./include/linux/lzma
ifeq ($(WITHOUT_XATTR), 1)
CPPFLAGS += -DWITHOUT_XATTR
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -127,6 +127,114 @@ static inline int lzo_init(void) { retur
static inline void lzo_fini(void) { }
#endif
+#ifndef WITHOUT_XZ
+
+#include <lzma.h>
+
+struct xz_ctx {
+ lzma_filter filters[3];
+ lzma_options_lzma opts;
+};
+
+static struct xz_ctx *xz_ctx;
+
+#define LZMA_COMPRESSION_LEVEL 9
+
+static struct xz_ctx *xz_ctx_init(void)
+{
+ struct xz_ctx *ctx;
+ lzma_options_lzma *opts_lzma;
+ uint32_t preset;
+ int ret;
+
+ ctx = malloc(sizeof(struct xz_ctx));
+ if (ctx == NULL)
+ goto err;
+
+ memset(ctx, 0, sizeof(struct xz_ctx));
+
+ opts_lzma = &ctx->opts;
+
+ preset = LZMA_COMPRESSION_LEVEL | LZMA_PRESET_EXTREME;
+ ret = lzma_lzma_preset(opts_lzma, preset);
+ if (ret)
+ goto err_free_ctx;
+
+ /* TODO: allow to specify LZMA options via command line */
+#if 0
+ opts_lzma->lc = 3;
+ opts_lzma->lp = 0;
+ opts_lzma->pb = 2;
+ opts_lzma->nice_len = 64;
+#else
+ opts_lzma->lc = 0;
+ opts_lzma->lp = 2;
+ opts_lzma->pb = 2;
+ opts_lzma->nice_len = 64;
+#endif
+
+ ctx->filters[0].id = LZMA_FILTER_LZMA2;
+ ctx->filters[0].options = opts_lzma;
+ ctx->filters[1].id = LZMA_VLI_UNKNOWN;
+
+ return ctx;
+
+err_free_ctx:
+ free(ctx);
+err:
+ return NULL;
+}
+
+static void xz_ctx_free(struct xz_ctx *ctx)
+{
+ free(ctx);
+}
+
+static int xz_init(void)
+{
+ xz_ctx = xz_ctx_init();
+ if (xz_ctx == NULL)
+ return -1;
+
+ return 0;
+}
+
+static void xz_fini(void)
+{
+ xz_ctx_free(xz_ctx);
+}
+
+static int xz_compress(void *in_buf, size_t in_len, void *out_buf,
+ size_t *out_len)
+{
+ size_t ret_len;
+ lzma_ret ret_xz;
+ int ret;
+
+ ret = -1;
+
+ ret_len = 0;
+ ret_xz = lzma_stream_buffer_encode(xz_ctx->filters, LZMA_CHECK_CRC32,
+ NULL, in_buf, in_len, out_buf,
+ &ret_len, *out_len);
+ if (ret_xz != LZMA_OK) {
+ fprintf(stderr, "XZ error: %d\n", (int) ret_xz);
+ goto out;
+ }
+
+ *out_len = ret_len;
+
+ ret = 0;
+out:
+ return ret;
+}
+#else
+static inline int xz_init(void) { return 0; }
+static inline void xz_fini(void) { }
+static inline int xz_compress(void *in_buf, size_t in_len, void *out_buf,
+ size_t *out_len) { return -1; }
+#endif
+
static int no_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -199,6 +307,9 @@ int compress_data(void *in_buf, size_t i
case MKFS_UBIFS_COMPR_LZO:
ret = lzo_compress(in_buf, in_len, out_buf, out_len);
break;
+ case MKFS_UBIFS_COMPR_XZ:
+ ret = xz_compress(in_buf, in_len, out_buf, out_len);
+ break;
case MKFS_UBIFS_COMPR_ZLIB:
ret = zlib_deflate(in_buf, in_len, out_buf, out_len);
break;
@@ -226,12 +337,18 @@ int init_compression(void)
if (ret)
goto err;
+ ret = xz_init();
+ if (ret)
+ goto err_lzo;
+
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
if (!zlib_buf)
- goto err_lzo;
+ goto err_xz;
return 0;
+err_xz:
+ xz_fini();
err_lzo:
lzo_fini();
err:
@@ -241,6 +358,7 @@ err:
void destroy_compression(void)
{
free(zlib_buf);
+ xz_fini();
lzo_fini();
if (errcnt)
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
--- a/mkfs.ubifs/compr.h
+++ b/mkfs.ubifs/compr.h
@@ -36,6 +36,7 @@ enum compression_type
MKFS_UBIFS_COMPR_NONE,
MKFS_UBIFS_COMPR_LZO,
MKFS_UBIFS_COMPR_ZLIB,
+ MKFS_UBIFS_COMPR_XZ,
};
int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
@@ -6,21 +6,33 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
TARGETS = mkfs.ubifs
+MKFS_UBIFS_OBJS = $(addprefix $(BUILDDIR)/,\
+ crc16.o lpt.o compr.o devtable.o \
+ hashtable/hashtable.o hashtable/hashtable_itr.o)
+
ifeq ($(WITHOUT_LZO), 1)
CPPFLAGS += -DWITHOUT_LZO
else
LZOLDLIBS = -llzo2
endif
-LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
+ifeq ($(WITHOUT_XZ), 1)
+ CPPFLAGS += -DWITHOUT_XZ
+else
+ifneq ($(LZMA_STATIC_LIB),)
+ MKFS_UBIFS_OBJS += $(LZMA_STATIC_LIB)
+else
+ XZLDLIBS = -llzma
+endif
+endif
+
+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) $(XZLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
-LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(XZLDFLAGS)
include ../common.mk
-$(BUILDDIR)/mkfs.ubifs: $(addprefix $(BUILDDIR)/,\
- crc16.o lpt.o compr.o devtable.o \
- hashtable/hashtable.o hashtable/hashtable_itr.o)
+$(BUILDDIR)/mkfs.ubifs: $(MKFS_UBIFS_OBJS)
clean::
rm -f $(BUILDDIR)/hashtable/*.o cscope.*
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -98,6 +98,9 @@ struct ubifs_info info_;
static struct ubifs_info *c = &info_;
static libubi_t ubi;
+static int force_compr_set;
+static int force_compr;
+
/* Debug levels are: 0 (none), 1 (statistics), 2 (files) ,3 (more details) */
int debug_level;
int verbose;
@@ -132,7 +135,7 @@ static struct inum_mapping **hash_table;
/* Inode creation sequence number */
static unsigned long long creat_sqnum;
-static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
+static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:Fp:k:x:X:y:j:R:l:j:UQq";
static const struct option longopts[] = {
{"root", 1, NULL, 'r'},
@@ -149,6 +152,7 @@ static const struct option longopts[] =
{"reserved", 1, NULL, 'R'},
{"compr", 1, NULL, 'x'},
{"favor-percent", 1, NULL, 'X'},
+ {"force-compr", 1, NULL, 'y'},
{"fanout", 1, NULL, 'f'},
{"space-fixup", 0, NULL, 'F'},
{"keyhash", 1, NULL, 'k'},
@@ -178,11 +182,13 @@ static const char *helptext =
"-o, --output=FILE output to FILE\n"
"-j, --jrn-size=SIZE journal size\n"
"-R, --reserved=SIZE how much space should be reserved for the super-user\n"
-"-x, --compr=TYPE compression type - \"lzo\", \"favor_lzo\", \"zlib\" or\n"
-" \"none\" (default: \"lzo\")\n"
+"-x, --compr=TYPE default compression type - \"lzo\", \"favor_lzo\",\n"
+" \"zlib\" or \"none\" (default: \"lzo\")\n"
"-X, --favor-percent may only be used with favor LZO compression and defines\n"
" how many percent better zlib should compress to make\n"
" mkfs.ubifs use zlib instead of LZO (default 20%)\n"
+"-y, --force-compr=TYPE force to build the fs with different compression -\n"
+" \"lzo\", \"zlib\" or \"none\"\n"
"-f, --fanout=NUM fanout NUM (default: 8)\n"
"-F, --space-fixup file-system free space has to be fixed up on first mount\n"
" (requires kernel version 3.0 or greater)\n"
@@ -530,6 +536,43 @@ static int open_ubi(const char *node)
return 0;
}
+static const char *get_compr_str(int compr)
+{
+ switch (compr) {
+ case UBIFS_COMPR_LZO:
+ return "lzo";
+ case UBIFS_COMPR_ZLIB:
+ return "zlib";
+ case UBIFS_COMPR_XZ:
+ return "xz";
+ case UBIFS_COMPR_NONE:
+ return "none";
+ }
+
+ return "unknown";
+}
+
+static int get_compr_option(char *opt, int *compr_type, int *favor_lzo)
+{
+ *compr_type = UBIFS_COMPR_LZO;
+
+ if (favor_lzo)
+ *favor_lzo = 0;
+
+ if (favor_lzo && strcmp(optarg, "favor_lzo") == 0)
+ *favor_lzo = 1;
+ else if (strcmp(optarg, "zlib") == 0)
+ *compr_type = UBIFS_COMPR_ZLIB;
+ else if (strcmp(optarg, "xz") == 0)
+ *compr_type = UBIFS_COMPR_XZ;
+ else if (strcmp(optarg, "none") == 0)
+ *compr_type = UBIFS_COMPR_NONE;
+ else if (strcmp(optarg, "lzo") != 0)
+ return -1;
+
+ return 0;
+}
+
static int get_options(int argc, char**argv)
{
int opt, i;
@@ -649,14 +692,13 @@ static int get_options(int argc, char**a
return err_msg("bad key hash");
break;
case 'x':
- if (strcmp(optarg, "favor_lzo") == 0)
- c->favor_lzo = 1;
- else if (strcmp(optarg, "zlib") == 0)
- c->default_compr = UBIFS_COMPR_ZLIB;
- else if (strcmp(optarg, "none") == 0)
- c->default_compr = UBIFS_COMPR_NONE;
- else if (strcmp(optarg, "lzo") != 0)
- return err_msg("bad compressor name");
+ if (get_compr_option(optarg, &c->default_compr,
+ &c->favor_lzo))
+ return err_msg("bad compressor name '%s'",
+ optarg);
+ if (c->default_compr == UBIFS_COMPR_XZ)
+ return err_msg("'%s' can't be used as default compressor",
+ optarg);
break;
case 'X':
c->favor_percent = strtol(optarg, &endp, 0);
@@ -665,6 +707,12 @@ static int get_options(int argc, char**a
return err_msg("bad favor LZO percent '%s'",
optarg);
break;
+ case 'y':
+ if (get_compr_option(optarg, &force_compr, NULL))
+ return err_msg("bad forced compressor name '%s'",
+ optarg);
+ force_compr_set = 1;
+ break;
case 'j':
c->max_bud_bytes = get_bytes(optarg);
if (c->max_bud_bytes <= 0)
@@ -749,6 +797,9 @@ static int get_options(int argc, char**a
c->min_io_size = 8;
c->rp_size = add_space_overhead(c->rp_size);
+ if (force_compr_set == 0)
+ force_compr = c->default_compr;
+
if (verbose) {
printf("mkfs.ubifs\n");
printf("\troot: %s\n", root);
@@ -758,17 +809,10 @@ static int get_options(int argc, char**a
printf("\toutput: %s\n", output);
printf("\tjrn_size: %llu\n", c->max_bud_bytes);
printf("\treserved: %llu\n", c->rp_size);
- switch (c->default_compr) {
- case UBIFS_COMPR_LZO:
- printf("\tcompr: lzo\n");
- break;
- case UBIFS_COMPR_ZLIB:
- printf("\tcompr: zlib\n");
- break;
- case UBIFS_COMPR_NONE:
- printf("\tcompr: none\n");
- break;
- }
+ printf("\tcompr: %s\n", get_compr_str(c->default_compr));
+ if (force_compr_set)
+ printf("\tforced compr: %s\n",
+ get_compr_str(force_compr));
printf("\tkeyhash: %s\n", (c->key_hash == key_r5_hash) ?
"r5" : "test");
printf("\tfanout: %d\n", c->fanout);
@@ -1353,7 +1397,7 @@ static int add_file(const char *path_nam
use_compr = UBIFS_COMPR_LZO;
else
#endif
- use_compr = c->default_compr;
+ use_compr = force_compr;
compr_type = compress_data(buf, bytes_read, &dn->data,
&out_len, use_compr);
dn->compr_type = cpu_to_le16(compr_type);
--- a/mkfs.ubifs/mkfs.ubifs.h
+++ b/mkfs.ubifs/mkfs.ubifs.h
@@ -77,6 +77,9 @@
#if MKFS_UBIFS_COMPR_ZLIB != UBIFS_COMPR_ZLIB
#error MKFS_UBIFS_COMPR_ZLIB != UBIFS_COMPR_ZLIB
#endif
+#if MKFS_UBIFS_COMPR_XZ != UBIFS_COMPR_XZ
+#error MKFS_UBIFS_COMPR_XZ != UBIFS_COMPR_XZ
+#endif
extern int verbose;
extern int debug_level;
--- a/mkfs.ubifs/ubifs-media.h
+++ b/mkfs.ubifs/ubifs-media.h
@@ -303,6 +303,7 @@ enum {
UBIFS_COMPR_NONE,
UBIFS_COMPR_LZO,
UBIFS_COMPR_ZLIB,
+ UBIFS_COMPR_XZ,
UBIFS_COMPR_TYPES_CNT,
};
@@ -0,0 +1,100 @@
Index: mtd-utils-1.4.5/mkfs.jffs2.c
===================================================================
--- mtd-utils-1.4.5.orig/mkfs.jffs2.c 2013-10-22 14:24:10.743123864 +0800
+++ mtd-utils-1.4.5/mkfs.jffs2.c 2013-10-25 11:40:54.016495058 +0800
@@ -745,6 +745,31 @@
padword();
}
+static int do_not_compress(char *name)
+{
+ int ret = 0;
+ if( donotcompress_filelist[0] != '\0' )
+ {
+ char filename[256];
+ FILE *fp = xfopen(donotcompress_filelist, "r");
+
+ while( fgets(filename, sizeof(filename), fp) )
+ {
+ filename[strlen(filename) - 1] = '\0';
+ if( !strcmp(name, filename) )
+ {
+ printf("not compressing file, %s\n", name);
+ ret = 1;
+ break;
+ }
+ }
+
+ fclose(fp);
+ }
+
+ return( ret );
+}
+
static unsigned int write_regular_file(struct filesystem_entry *e)
{
int fd, len;
@@ -790,6 +815,9 @@
ri.mtime = cpu_to_je32(statbuf->st_mtime);
ri.isize = cpu_to_je32(statbuf->st_size);
+ if( do_not_compress(e->fullname) )
+ jffs2_set_compression_mode_name("none");
+
while ((len = read(fd, buf, page_size))) {
unsigned char *tbuf = buf;
@@ -867,6 +895,9 @@
}
free(buf);
close(fd);
+
+ jffs2_set_compression_mode_name(default_compression_name);
+
return totcomp;
}
@@ -1447,7 +1478,8 @@
" -h, --help Display this help text\n"
" -v, --verbose Verbose operation\n"
" -V, --version Display version information\n"
-" -i, --incremental=FILE Parse FILE and generate appendage output for it\n\n";
+" -i, --incremental=FILE Parse FILE and generate appendage output for it\n"
+" -N, --donotcompress-filelist=FILE Do not compress files in FILE\n\n";
static const char revtext[] = "1.60";
@@ -1600,7 +1632,7 @@
jffs2_compressors_init();
while ((opt = getopt_long(argc, argv,
- "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0)
+ "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:N:", long_options, &c)) >= 0)
{
switch (opt) {
case 'D':
@@ -1778,6 +1810,10 @@
| (1 << JFFS2_XPREFIX_ACL_DEFAULT);
break;
#endif
+ case 'N':
+ strcpy(donotcompress_filelist, optarg);
+ break;
+
}
}
if (warn_page_size) {
Index: mtd-utils-1.4.5/mkfs.jffs2.c
===================================================================
--- mtd-utils-1.4.5.orig/mkfs.jffs2.c 2013-10-25 11:42:48.112492118 +0800
+++ mtd-utils-1.4.5/mkfs.jffs2.c 2013-10-25 11:44:47.840488939 +0800
@@ -120,6 +120,9 @@
static int fake_times = 0;
int target_endian = __BYTE_ORDER;
+static char default_compression_name[16] = "priority";
+static char donotcompress_filelist[256] = "";
+
uint32_t find_hardlink(struct filesystem_entry *e)
{
struct filesystem_entry *f;
@@ -0,0 +1,16 @@
Index: mtd-utils-1.4.5/mkfs.ubifs/mkfs.ubifs.h
===================================================================
--- mtd-utils-1.4.5.orig/mkfs.ubifs/mkfs.ubifs.h 2014-05-07 16:54:06.318103764 +0800
+++ mtd-utils-1.4.5/mkfs.ubifs/mkfs.ubifs.h 2014-05-07 16:55:33.351846587 +0800
@@ -36,6 +36,11 @@
#include <linux/types.h>
#ifdef __linux__
#include <linux/fs.h>
+
+#if defined(__UCLIBC__) && !defined(llseek)
+# define llseek lseek64
+#endif
+
#else
# ifndef O_LARGEFILE
# define O_LARGEFILE 0
@@ -0,0 +1,104 @@
Index: mtd-utils-1.4.5/nandwrite.c
===================================================================
--- mtd-utils-1.4.5.orig/nandwrite.c 2012-12-28 15:19:34.000000000 +0800
+++ mtd-utils-1.4.5/nandwrite.c 2014-05-07 17:01:25.880567174 +0800
@@ -77,6 +77,7 @@
" -f, --forcelegacy Force legacy support on autoplacement-enabled mtd\n"
" device\n"
" -m, --markbad Mark blocks bad if write fails\n"
+" -c, --readbackcheck ReadBack Check after writing\n"
" -n, --noecc Write without ecc\n"
" -N, --noskipbad Write without bad block skipping\n"
" -o, --oob Image contains oob data\n"
@@ -117,6 +118,7 @@
static bool onlyoob = false;
static bool autoplace = false;
static bool markbad = false;
+static bool readbackchk = false;
static bool forcejffs2 = false;
static bool forceyaffs = false;
static bool forcelegacy = false;
@@ -131,7 +133,7 @@
for (;;) {
int option_index = 0;
- static const char *short_options = "ab:fjmnNoOpqrs:y";
+ static const char *short_options = "ab:fjcmnNoOpqrs:y";
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
@@ -140,6 +142,7 @@
{"forcelegacy", no_argument, 0, 'f'},
{"jffs2", no_argument, 0, 'j'},
{"markbad", no_argument, 0, 'm'},
+ {"readbackchk", no_argument, 0, 'c'},
{"noecc", no_argument, 0, 'n'},
{"noskipbad", no_argument, 0, 'N'},
{"oob", no_argument, 0, 'o'},
@@ -193,6 +196,9 @@
case 'm':
markbad = true;
break;
+ case 'c':
+ readbackchk = true;
+ break;
case 'o':
writeoob = true;
break;
@@ -281,6 +287,7 @@
size_t filebuf_len = 0;
// points to the current page inside filebuf
unsigned char *writebuf = NULL;
+ unsigned char *readbuf = NULL;
// points to the OOB for the current page in filebuf
unsigned char *oobreadbuf = NULL;
unsigned char *oobbuf = NULL;
@@ -455,6 +462,8 @@
filebuf_max = ebsize_aligned / mtd.min_io_size * pagelen;
filebuf = xmalloc(filebuf_max);
erase_buffer(filebuf, filebuf_max);
+ readbuf = xmalloc(filebuf_max);
+ erase_buffer(readbuf, filebuf_max);
oobbuf = xmalloc(mtd.oob_size);
erase_buffer(oobbuf, mtd.oob_size);
@@ -681,6 +690,31 @@
continue;
}
+ else
+ {
+ if(readbackchk){
+ memset (readbuf, 0xff, mtd.min_io_size);
+ if (mtd_read(&mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size, readbuf, mtd.min_io_size)) {
+ sys_errmsg("%s: MTD read failure", mtd_device);
+ goto closeall;
+ }
+//printf("blockstart=%#08llx, mtdoffset=%#08llx, blk_num=%#08llx, ofs=%#08llx, readbuf[0]=0x%x, readbuf[1]=0x%x, readbuf[2]=0x%x\n", blockstart, mtdoffset, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size, readbuf[0], readbuf[1], readbuf[2]);
+ if(memcmp(readbuf, writebuf, mtd.min_io_size)){
+ fprintf(stderr, "Readback Checking found Error at %#08llx\n", mtdoffset);
+ if (markbad) {
+ fprintf(stderr, "Marking block at %08llx bad\n", mtdoffset & (~mtd.eb_size + 1));
+ if (mtd_mark_bad(&mtd, fd, mtdoffset / mtd.eb_size)) {
+ sys_errmsg("%s: MTD Mark bad block failure", mtd_device);
+ goto closeall;
+ }
+ }
+ /* Must rewind to blockstart if we can */
+ writebuf = filebuf;
+ mtdoffset = blockstart + ebsize_aligned;
+ continue;
+ }
+ }
+ }
mtdoffset += mtd.min_io_size;
writebuf += pagelen;
}
@@ -693,6 +727,7 @@
restoreoob:
libmtd_close(mtd_desc);
free(filebuf);
+ free(readbuf);
free(oobbuf);
if (oobinfochanged == 1) {