On 09/30/2011 09:47 AM, Stuart Hughes wrote:
> Hi Jurgen,
>
> This is not so much a dirty trick, but a necessary bug fix.
>
> So your options are:
>
> 1. Wait for the an updated release of busybox that includes this fix
> 2. Use your fix
> 3. Use an earlier version of busybox (in ltib)
>
> Probably the easiest thing is to use your bugfix for now. What you
> may like to do is re-name the patch and the reference to it in the
> updated .spec file.
indeed, did it.
>
> From what I recall, this version of busybox is not in the public
> Savannah LTIB? so it may be worth asking
indeed. We use now ltib from cvs (spring this year) and downloaded
busybox recently from busybox.net.
> whoever provided the BSP to you to fix this and re-release. Also if
> you send me your .spec file and the patch and a URL to the busybox
> you're using I'll try to get this packaged and put into the public
> Savannah CVS. To
see attach.
http://www.busybox.net/downloads/busybox-1.19.2.tar.bz2
I added UBI support to ltib, I can also send you this if you want, but I
have no time to update our ltib version to the latest from cvs..
Kind regards,
Jürgen
P.S.: we also added the imx27pdk platform to ltib, for linux 3.0-rc6
(and also some older versions we used before); I also want to provide
that, but it needs some cleanup; and also with patches to the linux
> start with I would probably not make this the default, but name it
> busybox-VERSION.spec, which would be accessibly by putting an entry in
> the using BSP (targets) config/platform/TARGET/pkg_map file.
>
> Regards, Stuart
>
>
> On 30/09/11 07:20, Lambrecht Jürgen wrote:
>> Hello,
>>
>> for completeness, I added the verbose error message below.
>>
>> Is this an ltib error or a busybox error?
>>
>> I solved it now by copying the missing header file from my pc to
>> ./rpm/BUILD/busybox*/include/mtd.
>> Then I created a patch for busybox to add the missing header file (with
>> '-m patchmerge).
>>
>> But this solution feels like a dirty trick.. does anybody know a better
>> solution?
>>
>> Regards,
>> Jürgen
>>
>> On 09/26/2011 01:41 PM, Lambrecht Jürgen wrote:
>>> Hello,
>>>
>>> When enabling mtd-utils (ubi..) busybox 1.19.2 fails to compile and
>>> complains that mtd/mtd-user.h and mtd/mtd-abi.h are missing.
>>>
>> Processing: busybox
>> =====================
>> Build path taken because: directory build, build key set, no prebuilt rpm,
>>
>> rpmbuild --dbpath /usr/src/cross/Ltib-svn/rootfs//var/lib/rpm --target
>> arm --define '_unpackaged_files_terminate_build 0' --define '_target_cpu
>> arm' --define '__strip strip' --define '_topdir
>> /usr/src/cross/Ltib-svn/rpm' --define '_prefix /usr' --define '_tmppath
>> /usr/src/cross/Ltib-svn/tmp' --define '_rpmdir
>> /usr/src/cross/Ltib-svn/rpm/RPMS' --define '_mandir /usr/share/man'
>> --define '_sysconfdir /etc' --define '_localstatedir /var' -bc
>> --short-circuit /usr/src/cross/Ltib-svn/dist/lfs-5.1/busybox/busybox.spec
>> Building target platforms: arm
>> Building for target arm
>> Executing(%build): /bin/sh -e /usr/src/cross/Ltib-svn/tmp/rpm-tmp.10531
>> + umask 022
>> + cd /usr/src/cross/Ltib-svn/rpm/BUILD
>> + cd busybox-1.19.2
>> + PKG_BUSYBOX_PRECONFIG=busybox.config
>> + [ -f /usr/src/cross/Ltib-svn/config/platform/imx27iat/busybox.config ]
>> + cp /usr/src/cross/Ltib-svn/config/platform/imx27iat/busybox.config .config
>> + [ -n y -o -n ]
>> + make menuconfig HOSTCC=ccache /usr/bin/gcc -B/usr/bin//
>> HOSTCC scripts/basic/fixdep
>> HOSTCC scripts/basic/split-include
>> HOSTCC scripts/basic/docproc
>> scripts/basic/split-include.c: In function 'main':
>> scripts/basic/split-include.c:134: warning: ignoring return value of
>> 'fgets', declared with attribute warn_unused_result
>> scripts/kconfig/mconf Config.in
>> #
>> # using defaults found in .config
>> #
>>
>>
>> *** End of configuration.
>> *** Execute 'make' to build the project or try 'make help'.
>>
>> + cp .config /usr/src/cross/Ltib-svn/config/platform/imx27iat/busybox.config
>> + make dep HOSTCC=ccache /usr/bin/gcc -B/usr/bin//
>> *** Warning: make dep is unnecessary now.
>> + make V=1 HOSTCC=ccache /usr/bin/gcc -B/usr/bin//
>> rm -f .kernelrelease
>> echo 1.19.2> .kernelrelease
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2/scripts/gen_build_files.sh
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2
>> make -f scripts/Makefile.build obj=scripts/basic
>> make -f scripts/Makefile.build obj=applets
>> scripts/basic/split-include include/autoconf.h include/config
>> ccache /usr/bin/gcc -B/usr/bin// -Wp,-MD,applets/.usage.d -Wall
>> -Wstrict-prototypes -O2 -fomit-frame-pointer -Iinclude -Iinclude -o
>> applets/usage applets/usage.c
>> ccache /usr/bin/gcc -B/usr/bin// -Wp,-MD,applets/.applet_tables.d
>> -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o
>> applets/applet_tables applets/applet_tables.c
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2/scripts/mkconfigs
>> include/bbconfigopts.h include/bbconfigopts_bz2.h
>> applets/usage.c: In function 'main':
>> applets/usage.c:52: warning: ignoring return value of 'write', declared
>> with attribute warn_unused_result
>> applets/applet_tables.c: In function 'main':
>> applets/applet_tables.c:144: warning: ignoring return value of 'fgets',
>> declared with attribute warn_unused_result
>> mkdir -p .tmp_versions
>> make -f scripts/Makefile.build obj=scripts
>> rm -f .tmp_versions/*
>> applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
>> ccache /usr/bin/gcc -B/usr/bin// -Wp,-MD,applets/.usage_pod.d -Wall
>> -Wstrict-prototypes -O2 -fomit-frame-pointer -Iinclude -Iinclude -o
>> applets/usage_pod applets/usage_pod.c
>> applets/usage_pod.c: In function 'main':
>> applets/usage_pod.c:74: warning: format not a string literal and no
>> format arguments
>> applets/usage_compressed include/usage_compressed.h applets
>> gcc -Wp,-MD,applets/.applets.o.d -std=gnu99 -Iinclude -Ilibbb
>> -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG
>> -D"BB_VER=KBUILD_STR(1.19.2)" -DBB_BT=AUTOCONF_TIMESTAMP -Wall -Wshadow
>> -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter
>> -Wunused-function -Wunused-value -Wmissing-prototypes
>> -Wmissing-declarations -Wdeclaration-after-statement
>> -Wold-style-definition -fno-builtin-strlen -finline-limit=0
>> -fomit-frame-pointer -ffunction-sections -fdata-sections
>> -fno-guess-branch-probability -funsigned-char -static-libgcc
>> -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os
>> -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(applets)"
>> -D"KBUILD_MODNAME=KBUILD_STR(applets)" -c -o applets/applets.o
>> applets/applets.c
>> gcc -nostdlib -r -o applets/built-in.o applets/applets.o
>> make -f scripts/Makefile.build obj=.
>> mkdir -p docs
>> ( \
>> cat
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2/docs/busybox_header.pod; \
>> echo; \
>> applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$/&\n/'; \
>> cat
>> /usr/src/cross/Ltib-svn/rpm/BUILD/busybox-1.19.2/docs/busybox_footer.pod; \
>> )> docs/busybox.pod
>> mkdir -p docs
>> mkdir -p docs
>> pod2text docs/busybox.pod> docs/BusyBox.txt
>> mkdir -p docs/busybox.net
>> pod2man --center=busybox --release="version 1.19.2" docs/busybox.pod>
>> docs/busybox.1
>> pod2html --noindex docs/busybox.pod> docs/busybox.net/BusyBox.html
>> rm -f pod2htm*
>> mkdir -p docs
>> rm -f docs/BusyBox.html
>> cp docs/busybox.net/BusyBox.html docs/BusyBox.html
>> make -f scripts/Makefile.build obj=applets
>> make -f scripts/Makefile.build obj=archival
>> make -f scripts/Makefile.build obj=archival/libarchive
>> make -f scripts/Makefile.build obj=console-tools
>> make -f scripts/Makefile.build obj=coreutils
>> make -f scripts/Makefile.build obj=coreutils/libcoreutils
>> make -f scripts/Makefile.build obj=debianutils
>> make -f scripts/Makefile.build obj=e2fsprogs
>> make -f scripts/Makefile.build obj=editors
>> make -f scripts/Makefile.build obj=findutils
>> make -f scripts/Makefile.build obj=init
>> make -f scripts/Makefile.build obj=libbb
>> make -f scripts/Makefile.build obj=libpwdgrp
>> make -f scripts/Makefile.build obj=loginutils
>> make -f scripts/Makefile.build obj=mailutils
>> make -f scripts/Makefile.build obj=miscutils
>> make -f scripts/Makefile.build obj=modutils
>> make -f scripts/Makefile.build obj=networking
>> make -f scripts/Makefile.build obj=networking/libiproute
>> gcc -Wp,-MD,miscutils/.ubi_tools.o.d -std=gnu99 -Iinclude -Ilibbb
>> -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG
>> -D"BB_VER=KBUILD_STR(1.19.2)" -DBB_BT=AUTOCONF_TIMESTAMP -Wall -Wshadow
>> -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter
>> -Wunused-function -Wunused-value -Wmissing-prototypes
>> -Wmissing-declarations -Wdeclaration-after-statement
>> -Wold-style-definition -fno-builtin-strlen -finline-limit=0
>> -fomit-frame-pointer -ffunction-sections -fdata-sections
>> -fno-guess-branch-probability -funsigned-char -static-libgcc
>> -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os
>> -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(ubi_tools)"
>> -D"KBUILD_MODNAME=KBUILD_STR(ubi_tools)" -c -o miscutils/ubi_tools.o
>> miscutils/ubi_tools.c
>> make -f scripts/Makefile.build obj=networking/udhcp
>> gcc -Wp,-MD,libbb/.appletlib.o.d -std=gnu99 -Iinclude -Ilibbb
>> -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG
>> -D"BB_VER=KBUILD_STR(1.19.2)" -DBB_BT=AUTOCONF_TIMESTAMP -Wall -Wshadow
>> -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter
>> -Wunused-function -Wunused-value -Wmissing-prototypes
>> -Wmissing-declarations -Wdeclaration-after-statement
>> -Wold-style-definition -fno-builtin-strlen -finline-limit=0
>> -fomit-frame-pointer -ffunction-sections -fdata-sections
>> -fno-guess-branch-probability -funsigned-char -static-libgcc
>> -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os
>> -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(appletlib)"
>> -D"KBUILD_MODNAME=KBUILD_STR(appletlib)" -c -o libbb/appletlib.o
>> libbb/appletlib.c
>> make -f scripts/Makefile.build obj=printutils
>> make -f scripts/Makefile.build obj=procps
>> make -f scripts/Makefile.build obj=runit
>> make -f scripts/Makefile.build obj=selinux
>> make -f scripts/Makefile.build obj=shell
>> miscutils/ubi_tools.c:63:26: error: mtd/ubi-user.h: No such file or
>> directory
>> miscutils/ubi_tools.c: In function 'ubi_tools_main':
>> miscutils/ubi_tools.c:133: error: 'UBI_DEV_NUM_AUTO' undeclared (first
>> use in this function)
>> miscutils/ubi_tools.c:133: error: (Each undeclared identifier is
>> reported only once
>> miscutils/ubi_tools.c:133: error: for each function it appears in.)
>> miscutils/ubi_tools.c:134: error: 'UBI_VOL_NUM_AUTO' undeclared (first
>> use in this function)
>> miscutils/ubi_tools.c:153: error: storage size of 'req' isn't known
>> miscutils/ubi_tools.c:161: error: 'UBI_IOCATT' undeclared (first use in
>> this function)
>> miscutils/ubi_tools.c:153: warning: unused variable 'req'
>> miscutils/ubi_tools.c:167: error: 'UBI_IOCDET' undeclared (first use in
>> this function)
>> miscutils/ubi_tools.c:170: error: storage size of 'req' isn't known
>> miscutils/ubi_tools.c:177: error: 'UBI_MAX_VOLUME_NAME' undeclared
>> (first use in this function)
>> miscutils/ubi_tools.c:184: error: 'UBI_STATIC_VOLUME' undeclared (first
>> use in this function)
>> miscutils/ubi_tools.c:186: error: 'UBI_DYNAMIC_VOLUME' undeclared (first
>> use in this function)
>> miscutils/ubi_tools.c:195: error: 'UBI_IOCMKVOL' undeclared (first use
>> in this function)
>> miscutils/ubi_tools.c:170: warning: unused variable 'req'
>> miscutils/ubi_tools.c:201: error: 'UBI_IOCRMVOL' undeclared (first use
>> in this function)
>> miscutils/ubi_tools.c:204: error: storage size of 'req' isn't known
>> miscutils/ubi_tools.c:214: error: 'UBI_IOCRSVOL' undeclared (first use
>> in this function)
>> miscutils/ubi_tools.c:204: warning: unused variable 'req'
>> miscutils/ubi_tools.c:222: error: 'UBI_IOCVOLUP' undeclared (first use
>> in this function)
>> make[1]: *** [miscutils/ubi_tools.o] Error 1
>> make: *** [miscutils] Error 2
>> make: *** Waiting for unfinished jobs....
>> rm -f libbb/lib.a; ar rcs libbb/lib.a libbb/appletlib.o
>> libbb/ask_confirmation.o libbb/bb_askpass.o libbb/bb_bswap_64.o
>> libbb/bb_do_delay.o libbb/bb_pwd.o libbb/bb_qsort.o libbb/bb_strtonum.o
>> libbb/change_identity.o libbb/chomp.o libbb/compare_string_array.o
>> libbb/concat_path_file.o libbb/concat_subpath_file.o libbb/copy_file.o
>> libbb/copyfd.o libbb/correct_password.o libbb/crc32.o
>> libbb/create_icmp6_socket.o libbb/create_icmp_socket.o
>> libbb/default_error_retval.o libbb/device_open.o libbb/dump.o
>> libbb/execable.o libbb/fclose_nonstdin.o libbb/fflush_stdout_and_exit.o
>> libbb/fgets_str.o libbb/find_mount_point.o libbb/find_pid_by_name.o
>> libbb/find_root_device.o libbb/full_write.o libbb/get_console.o
>> libbb/get_cpu_count.o libbb/get_last_path_component.o
>> libbb/get_line_from_file.o libbb/get_shell_name.o libbb/get_volsize.o
>> libbb/getopt32.o libbb/getpty.o libbb/hash_md5_sha.o libbb/herror_msg.o
>> libbb/human_readable.o libbb/inet_common.o libbb/info_msg.o
>> libbb/inode_hash.o libbb/isdirectory.o libbb/kernel_version.o
>> libbb/last_char_is.o libbb/lineedit.o libbb/lineedit_ptr_hack.o
>> libbb/llist.o libbb/login.o libbb/loop.o libbb/make_directory.o
>> libbb/makedev.o libbb/match_fstype.o libbb/messages.o
>> libbb/mode_string.o libbb/obscure.o libbb/parse_config.o
>> libbb/parse_mode.o libbb/perror_msg.o libbb/perror_nomsg.o
>> libbb/perror_nomsg_and_die.o libbb/pidfile.o libbb/platform.o
>> libbb/print_flags.o libbb/printable.o libbb/printable_string.o
>> libbb/process_escape_sequence.o libbb/procps.o libbb/progress.o
>> libbb/ptr_to_globals.o libbb/pw_encrypt.o libbb/read.o libbb/read_key.o
>> libbb/read_printf.o libbb/recursive_action.o libbb/remove_file.o
>> libbb/rtc.o libbb/run_shell.o libbb/safe_gethostname.o libbb/safe_poll.o
>> libbb/safe_strncpy.o libbb/safe_write.o libbb/setup_environment.o
>> libbb/signals.o libbb/simplify_path.o libbb/single_argv.o
>> libbb/skip_whitespace.o libbb/speed_table.o libbb/str_tolower.o
>> libbb/strrstr.o libbb/systemd_support.o libbb/time.o libbb/trim.o
>> libbb/u_signal_names.o libbb/udp_io.o libbb/unicode.o
>> libbb/update_passwd.o libbb/utmp.o libbb/uuencode.o libbb/vdprintf.o
>> libbb/verror_msg.o libbb/vfork_daemon_rexec.o libbb/warn_ignoring_args.o
>> libbb/wfopen.o libbb/wfopen_input.o libbb/write.o libbb/xatonum.o
>> libbb/xconnect.o libbb/xfunc_die.o libbb/xfuncs.o libbb/xfuncs_printf.o
>> libbb/xgetcwd.o libbb/xgethostbyname.o libbb/xreadlink.o
>> libbb/xrealloc_vector.o libbb/xregcomp.o
>> make: *** wait: No child processes. Stop.
>> error: Bad exit status from /usr/src/cross/Ltib-svn/tmp/rpm-tmp.10531
>> (%build)
>>
>>
>> RPM build errors:
>> Bad exit status from /usr/src/cross/Ltib-svn/tmp/rpm-tmp.10531 (%build)
>> Build time for busybox: 9 seconds
>>
>> Failed building busybox
>>
>>
>> f_scbuild() returned an error, exiting
>> traceback:
>> main:567
>>
>> Exiting on error or interrupt
>>
>>> I guess this is the same error as in
>>> https://bugs.busybox.net/show_bug.cgi?id=1669 , fixed I think for
>>> buildroot.
>>>
>>> I am looking into it, but maybe someone else has already fixed it or can
>>> give me some hints?
>>>
>>> Thanks,
>>> Jürgen
>>>
>>> --
>>> Jürgen Lambrecht
>>> R&D Associate
>>> Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
>>> http://www.televic-rail.com
>>> Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
>>> Company number 0825.539.581 - RPR Kortrijk
>>>
>>> _______________________________________________
>>> LTIB home page:http://ltib.org
>>>
>>> Ltib mailing list
>>> [email protected]
>>> https://lists.nongnu.org/mailman/listinfo/ltib
>>>
>
--
Jürgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
%define base %(echo %{_prefix} | sed -e s,/usr.*$,,)
%define pfx /opt/freescale/rootfs/%{_target_cpu}
Summary : A small executable that replaces many UNIX utilities
Name : busybox
Version : 1.19.2
Release : 1
License : GPL
Vendor : Freescale
Packager : Olivia Yin
Group : System Environment/Shells
Source : %{name}-%{version}.tar.bz2
Patch1 : busybox-1.19.2-ubi-user-h.patch
BuildRoot : %{_tmppath}/%{name}
Prefix : %{pfx}
%Description
%{summary}
%Prep
%setup
%patch1 -p1
%Build
PKG_BUSYBOX_PRECONFIG=${PKG_BUSYBOX_PRECONFIG:-busybox.config}
if [ -f "$PLATFORM_PATH/${PKG_BUSYBOX_PRECONFIG}" ]
then
cp $PLATFORM_PATH/$PKG_BUSYBOX_PRECONFIG .config
else
if [ -f "$CONFIG_DIR/defaults/$PKG_BUSYBOX_PRECONFIG" ]
then
cp "$CONFIG_DIR/defaults/$PKG_BUSYBOX_PRECONFIG" .config
fi
fi
if [ -n "$PKG_BUSYBOX_WANT_CF" -o -n "$SCB_WANT_CF" ]
then
make menuconfig HOSTCC="$BUILDCC"
cp .config $PLATFORM_PATH/$PKG_BUSYBOX_PRECONFIG
else
yes "" | make config HOSTCC="$BUILDCC"
fi
make dep HOSTCC="$BUILDCC"
make HOSTCC="$BUILDCC"
%Install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT/%{pfx}/%{base}/bin
make HOSTCC="$BUILDCC" CONFIG_PREFIX=$RPM_BUILD_ROOT/%{pfx}/%{base} install
for i in pidof ip
do
if [ -f $RPM_BUILD_ROOT/%{pfx}/%{base}/bin/$i ]
then
rm $RPM_BUILD_ROOT/%{pfx}/%{base}/bin/$i
ln -sf ../bin/busybox $RPM_BUILD_ROOT/%{pfx}/%{base}/sbin/$i
fi
done
mkdir -p $RPM_BUILD_ROOT/%{pfx}/%{base}/etc/rc.d/init.d
for i in run log
do
install -d $RPM_BUILD_ROOT/%{pfx}/%{base}/var/$i
done
touch $RPM_BUILD_ROOT/%{pfx}/%{base}/var/run/utmp
touch $RPM_BUILD_ROOT/%{pfx}/%{base}/var/log/wtmp
cat <<EOF > $RPM_BUILD_ROOT/%{pfx}/%{base}/etc/busybox.conf
[SUID]
#su = ssx root.root
passwd = ssx root.root
EOF
chmod 644 $RPM_BUILD_ROOT/%{pfx}/%{base}/etc/busybox.conf
%Clean
rm -rf $RPM_BUILD_ROOT
%Files
%defattr(-,root,root)
%attr(4755,root,root) %{pfx}/%{base}/bin/busybox
%{pfx}/*
%changelog
20110926 Juergen Lambrecht <[email protected]>
This patch add an include file from mtd-utils.
diff --exclude CVS --exclude .git -uNr busybox-1.19.2/include/mtd/ubi-user.h busybox-1.19.2.modified/include/mtd/ubi-user.h
--- busybox-1.19.2/include/mtd/ubi-user.h 1970-01-01 01:00:00.000000000 +0100
+++ busybox-1.19.2.modified/include/mtd/ubi-user.h 2011-09-26 15:48:54.884088675 +0200
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) International Business Machines Corp., 2006
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм)
+ */
+
+#ifndef __UBI_USER_H__
+#define __UBI_USER_H__
+
+#include <linux/types.h>
+
+/*
+ * UBI device creation (the same as MTD device attachment)
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI
+ * control device. The caller has to properly fill and pass
+ * &struct ubi_attach_req object - UBI will attach the MTD device specified in
+ * the request and return the newly created UBI device number as the ioctl
+ * return value.
+ *
+ * UBI device deletion (the same as MTD device detachment)
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI
+ * control device.
+ *
+ * UBI volume creation
+ * ~~~~~~~~~~~~~~~~~~~
+ *
+ * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character
+ * device. A &struct ubi_mkvol_req object has to be properly filled and a
+ * pointer to it has to be passed to the ioctl.
+ *
+ * UBI volume deletion
+ * ~~~~~~~~~~~~~~~~~~~
+ *
+ * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character
+ * device should be used. A pointer to the 32-bit volume ID hast to be passed
+ * to the ioctl.
+ *
+ * UBI volume re-size
+ * ~~~~~~~~~~~~~~~~~~
+ *
+ * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character
+ * device should be used. A &struct ubi_rsvol_req object has to be properly
+ * filled and a pointer to it has to be passed to the ioctl.
+ *
+ * UBI volumes re-name
+ * ~~~~~~~~~~~~~~~~~~~
+ *
+ * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command
+ * of the UBI character device should be used. A &struct ubi_rnvol_req object
+ * has to be properly filled and a pointer to it has to be passed to the ioctl.
+ *
+ * UBI volume update
+ * ~~~~~~~~~~~~~~~~~
+ *
+ * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the
+ * corresponding UBI volume character device. A pointer to a 64-bit update
+ * size should be passed to the ioctl. After this, UBI expects user to write
+ * this number of bytes to the volume character device. The update is finished
+ * when the claimed number of bytes is passed. So, the volume update sequence
+ * is something like:
+ *
+ * fd = open("/dev/my_volume");
+ * ioctl(fd, UBI_IOCVOLUP, &image_size);
+ * write(fd, buf, image_size);
+ * close(fd);
+ *
+ * Logical eraseblock erase
+ * ~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the
+ * corresponding UBI volume character device should be used. This command
+ * unmaps the requested logical eraseblock, makes sure the corresponding
+ * physical eraseblock is successfully erased, and returns.
+ *
+ * Atomic logical eraseblock change
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH
+ * ioctl command of the corresponding UBI volume character device. A pointer to
+ * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the
+ * user is expected to write the requested amount of bytes (similarly to what
+ * should be done in case of the "volume update" ioctl).
+ *
+ * Logical eraseblock map
+ * ~~~~~~~~~~~~~~~~~~~~~
+ *
+ * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP
+ * ioctl command should be used. A pointer to a &struct ubi_map_req object is
+ * expected to be passed. The ioctl maps the requested logical eraseblock to
+ * a physical eraseblock and returns. Only non-mapped logical eraseblocks can
+ * be mapped. If the logical eraseblock specified in the request is already
+ * mapped to a physical eraseblock, the ioctl fails and returns error.
+ *
+ * Logical eraseblock unmap
+ * ~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP
+ * ioctl command should be used. The ioctl unmaps the logical eraseblocks,
+ * schedules corresponding physical eraseblock for erasure, and returns. Unlike
+ * the "LEB erase" command, it does not wait for the physical eraseblock being
+ * erased. Note, the side effect of this is that if an unclean reboot happens
+ * after the unmap ioctl returns, you may find the LEB mapped again to the same
+ * physical eraseblock after the UBI is run again.
+ *
+ * Check if logical eraseblock is mapped
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * To check if a logical eraseblock is mapped to a physical eraseblock, the
+ * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is
+ * not mapped, and %1 if it is mapped.
+ *
+ * Set an UBI volume property
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be
+ * used. A pointer to a &struct ubi_set_prop_req object is expected to be
+ * passed. The object describes which property should be set, and to which value
+ * it should be set.
+ */
+
+/*
+ * When a new UBI volume or UBI device is created, users may either specify the
+ * volume/device number they want to create or to let UBI automatically assign
+ * the number using these constants.
+ */
+#define UBI_VOL_NUM_AUTO (-1)
+#define UBI_DEV_NUM_AUTO (-1)
+
+/* Maximum volume name length */
+#define UBI_MAX_VOLUME_NAME 127
+
+/* ioctl commands of UBI character devices */
+
+#define UBI_IOC_MAGIC 'o'
+
+/* Create an UBI volume */
+#define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req)
+/* Remove an UBI volume */
+#define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, __s32)
+/* Re-size an UBI volume */
+#define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req)
+/* Re-name volumes */
+#define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req)
+
+/* ioctl commands of the UBI control character device */
+
+#define UBI_CTRL_IOC_MAGIC 'o'
+
+/* Attach an MTD device */
+#define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req)
+/* Detach an MTD device */
+#define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, __s32)
+
+/* ioctl commands of UBI volume character devices */
+
+#define UBI_VOL_IOC_MAGIC 'O'
+
+/* Start UBI volume update */
+#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, __s64)
+/* LEB erasure command, used for debugging, disabled by default */
+#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, __s32)
+/* Atomic LEB change command */
+#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, __s32)
+/* Map LEB command */
+#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
+/* Unmap LEB command */
+#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, __s32)
+/* Check if LEB is mapped command */
+#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32)
+/* Set an UBI volume property */
+#define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req)
+
+/* Maximum MTD device name length supported by UBI */
+#define MAX_UBI_MTD_NAME_LEN 127
+
+/* Maximum amount of UBI volumes that can be re-named at one go */
+#define UBI_MAX_RNVOL 32
+
+/*
+ * UBI data type hint constants.
+ *
+ * UBI_LONGTERM: long-term data
+ * UBI_SHORTTERM: short-term data
+ * UBI_UNKNOWN: data persistence is unknown
+ *
+ * These constants are used when data is written to UBI volumes in order to
+ * help the UBI wear-leveling unit to find more appropriate physical
+ * eraseblocks.
+ */
+enum {
+ UBI_LONGTERM = 1,
+ UBI_SHORTTERM = 2,
+ UBI_UNKNOWN = 3,
+};
+
+/*
+ * UBI volume type constants.
+ *
+ * @UBI_DYNAMIC_VOLUME: dynamic volume
+ * @UBI_STATIC_VOLUME: static volume
+ */
+enum {
+ UBI_DYNAMIC_VOLUME = 3,
+ UBI_STATIC_VOLUME = 4,
+};
+
+/*
+ * UBI set property ioctl constants
+ *
+ * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and
+ * erase individual eraseblocks on dynamic volumes
+ */
+enum {
+ UBI_PROP_DIRECT_WRITE = 1,
+};
+
+/**
+ * struct ubi_attach_req - attach MTD device request.
+ * @ubi_num: UBI device number to create
+ * @mtd_num: MTD device number to attach
+ * @vid_hdr_offset: VID header offset (use defaults if %0)
+ * @padding: reserved for future, not used, has to be zeroed
+ *
+ * This data structure is used to specify MTD device UBI has to attach and the
+ * parameters it has to use. The number which should be assigned to the new UBI
+ * device is passed in @ubi_num. UBI may automatically assign the number if
+ * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in
+ * @ubi_num.
+ *
+ * Most applications should pass %0 in @vid_hdr_offset to make UBI use default
+ * offset of the VID header within physical eraseblocks. The default offset is
+ * the next min. I/O unit after the EC header. For example, it will be offset
+ * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or
+ * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages.
+ *
+ * But in rare cases, if this optimizes things, the VID header may be placed to
+ * a different offset. For example, the boot-loader might do things faster if
+ * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages.
+ * As the boot-loader would not normally need to read EC headers (unless it
+ * needs UBI in RW mode), it might be faster to calculate ECC. This is weird
+ * example, but it real-life example. So, in this example, @vid_hdr_offer would
+ * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes
+ * aligned, which is OK, as UBI is clever enough to realize this is 4th
+ * sub-page of the first page and add needed padding.
+ */
+struct ubi_attach_req {
+ __s32 ubi_num;
+ __s32 mtd_num;
+ __s32 vid_hdr_offset;
+ __s8 padding[12];
+};
+
+/**
+ * struct ubi_mkvol_req - volume description data structure used in
+ * volume creation requests.
+ * @vol_id: volume number
+ * @alignment: volume alignment
+ * @bytes: volume size in bytes
+ * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
+ * @padding1: reserved for future, not used, has to be zeroed
+ * @name_len: volume name length
+ * @padding2: reserved for future, not used, has to be zeroed
+ * @name: volume name
+ *
+ * This structure is used by user-space programs when creating new volumes. The
+ * @used_bytes field is only necessary when creating static volumes.
+ *
+ * The @alignment field specifies the required alignment of the volume logical
+ * eraseblock. This means, that the size of logical eraseblocks will be aligned
+ * to this number, i.e.,
+ * (UBI device logical eraseblock size) mod (@alignment) = 0.
+ *
+ * To put it differently, the logical eraseblock of this volume may be slightly
+ * shortened in order to make it properly aligned. The alignment has to be
+ * multiple of the flash minimal input/output unit, or %1 to utilize the entire
+ * available space of logical eraseblocks.
+ *
+ * The @alignment field may be useful, for example, when one wants to maintain
+ * a block device on top of an UBI volume. In this case, it is desirable to fit
+ * an integer number of blocks in logical eraseblocks of this UBI volume. With
+ * alignment it is possible to update this volume using plane UBI volume image
+ * BLOBs, without caring about how to properly align them.
+ */
+struct ubi_mkvol_req {
+ __s32 vol_id;
+ __s32 alignment;
+ __s64 bytes;
+ __s8 vol_type;
+ __s8 padding1;
+ __s16 name_len;
+ __s8 padding2[4];
+ char name[UBI_MAX_VOLUME_NAME + 1];
+} __attribute__ ((packed));
+
+/**
+ * struct ubi_rsvol_req - a data structure used in volume re-size requests.
+ * @vol_id: ID of the volume to re-size
+ * @bytes: new size of the volume in bytes
+ *
+ * Re-sizing is possible for both dynamic and static volumes. But while dynamic
+ * volumes may be re-sized arbitrarily, static volumes cannot be made to be
+ * smaller than the number of bytes they bear. To arbitrarily shrink a static
+ * volume, it must be wiped out first (by means of volume update operation with
+ * zero number of bytes).
+ */
+struct ubi_rsvol_req {
+ __s64 bytes;
+ __s32 vol_id;
+} __attribute__ ((packed));
+
+/**
+ * struct ubi_rnvol_req - volumes re-name request.
+ * @count: count of volumes to re-name
+ * @padding1: reserved for future, not used, has to be zeroed
+ * @vol_id: ID of the volume to re-name
+ * @name_len: name length
+ * @padding2: reserved for future, not used, has to be zeroed
+ * @name: new volume name
+ *
+ * UBI allows to re-name up to %32 volumes at one go. The count of volumes to
+ * re-name is specified in the @count field. The ID of the volumes to re-name
+ * and the new names are specified in the @vol_id and @name fields.
+ *
+ * The UBI volume re-name operation is atomic, which means that should power cut
+ * happen, the volumes will have either old name or new name. So the possible
+ * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes
+ * A and B one may create temporary volumes %A1 and %B1 with the new contents,
+ * then atomically re-name A1->A and B1->B, in which case old %A and %B will
+ * be removed.
+ *
+ * If it is not desirable to remove old A and B, the re-name request has to
+ * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1
+ * become A and B, and old A and B will become A1 and B1.
+ *
+ * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1
+ * and B1 become A and B, and old A and B become X and Y.
+ *
+ * In other words, in case of re-naming into an existing volume name, the
+ * existing volume is removed, unless it is re-named as well at the same
+ * re-name request.
+ */
+struct ubi_rnvol_req {
+ __s32 count;
+ __s8 padding1[12];
+ struct {
+ __s32 vol_id;
+ __s16 name_len;
+ __s8 padding2[2];
+ char name[UBI_MAX_VOLUME_NAME + 1];
+ } ents[UBI_MAX_RNVOL];
+} __attribute__ ((packed));
+
+/**
+ * struct ubi_leb_change_req - a data structure used in atomic LEB change
+ * requests.
+ * @lnum: logical eraseblock number to change
+ * @bytes: how many bytes will be written to the logical eraseblock
+ * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
+ * @padding: reserved for future, not used, has to be zeroed
+ */
+struct ubi_leb_change_req {
+ __s32 lnum;
+ __s32 bytes;
+ __s8 dtype;
+ __s8 padding[7];
+} __attribute__ ((packed));
+
+/**
+ * struct ubi_map_req - a data structure used in map LEB requests.
+ * @lnum: logical eraseblock number to unmap
+ * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
+ * @padding: reserved for future, not used, has to be zeroed
+ */
+struct ubi_map_req {
+ __s32 lnum;
+ __s8 dtype;
+ __s8 padding[3];
+} __attribute__ ((packed));
+
+
+/**
+ * struct ubi_set_prop_req - a data structure used to set an ubi volume
+ * property.
+ * @property: property to set (%UBI_PROP_DIRECT_WRITE)
+ * @padding: reserved for future, not used, has to be zeroed
+ * @value: value to set
+ */
+struct ubi_set_prop_req {
+ __u8 property;
+ __u8 padding[7];
+ __u64 value;
+} __attribute__ ((packed));
+
+#endif /* __UBI_USER_H__ */
_______________________________________________
LTIB home page: http://ltib.org
Ltib mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ltib