While at it also fix the type of flen holding a string length
(int -> size_t).
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of letting rpc_lookup_req set mount_port and nfs_port, let it
return the port found and let the caller use that information.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
When a former transaction was aborted by hitting Ctrl-C the old reply might
still hang in the ethernet controller making all further transactions fail.
So just skip over old replies.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
We're speaking rpc mount version 2 (i.e. the same version as the
implemented nfs protocol), so also specify that in the lookup.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Implement the readlink entry point for future use by the DA923RC.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
ubiformat needs the subpagesize to work correctly. The kernel uses
sysfs to pass the subpagesize, but in barebox we have the possibility
to extend struct mtd_info_user. Add a corresponding field and use it
in ubiformat.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
A chdir to a path registered as an automount path followed by a 'ls'
results in an endless loop. This happens because the command the
automounter executes results in another automount request.
Fix this by running the automounter from the chdir code before
the cwd is actually changed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The O_TRUNC flag has to be ignored when opening devices. Otherwise
cp /somefile /dev/somedev fails. This is broken since:
| commit d4f5bb1e01
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Sat Sep 28 13:12:50 2013 +0200
|
| copy_file: Add missing O_TRUNC
|
| Without it, when copying a smaller file over a larger file the
| resulting file still has the remaining space from the larger file.
|
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Simple update file format developed for Somfy, tools and library are
available under LGPLv2 (https://www.gitorious.org/libbpk).
This format in the v1.0 allow you to store 6 types a binary stream for
a unique hardware id:
- bootloader
- bootloader_version
- description.gz
- kernel
- rootfs
- firmware_version
and you can easly add more binary stream type.
The fs will display you in a directory per hw id
and if a binary stream type is unknown will be display
as unknown_%08x
# mount image.bpk /tmp
# ls -l /tmp/hw_id_0/
-rwxrwxrwx 10 firmware_version
-rwxrwxrwx 8 firmware_version.crc
-rwxrwxrwx 1845968 kernel
-rwxrwxrwx 8 kernel.crc
-rwxrwxrwx 5062656 rootfs
-rwxrwxrwx 8 rootfs.crc
-rwxrwxrwx 248 bootloader
-rwxrwxrwx 8 bootloader.crc
-rwxrwxrwx 248925 description.gz
-rwxrwxrwx 8 description.gz.crc
-rwxrwxrwx 4 bootloader_version
-rwxrwxrwx 8 bootloader_version.crc
-rwxrwxrwx 4 unknown_1234567g
-rwxrwxrwx 8 unknown_1234567g.crc
Why BPK and not CPIO or uImage
1) CPIO
cpio does not handle > 4GiB image and does not have any crc checksum
2) uImage
uImage only provide one crc32 for the all data part and only a list of binary
stream with no information about what is what (in multi-image format)
3) BPK
BPK provide a crc32 for the header part and one crc32 per binary stream
so if you does not care of some data you are not force to check them
And you known exactly the binary stream type and for which hw to
use it.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Fargier Sylvain <sylvain.fargier@somfy.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
All filesystem drivers which need a backingstore device do the same
ignoring of '/dev/' in the backingstore followed by a cdev_open. Add a
helper function for it and let the core handle the cdev. As a side
effect this makes sure that fsdev->cdev is also set when a device is
mounted without the leading '/dev/' which was previously ignored
by the mount code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
this will provide the image data and information via file
# ls -l /tmp/
-rwxrwxrwx 3 arch
-rwxrwxrwx 12 compression
-rwxrwxrwx 16 name
-rwxrwxrwx 5 os
-rwxrwxrwx 24 time
-rwxrwxrwx 12 type
-rwxrwxrwx 10 load_addr
-rwxrwxrwx 10 entry_point
-rwxrwxrwx 2199875 data0
-rwxrwxrwx 2199875 data
-rwxrwxrwx 10 data.crc
if it's multi image
# ls -l /tmp-multi/
-rwxrwxrwx 3 arch
-rwxrwxrwx 12 compression
-rwxrwxrwx 16 name
-rwxrwxrwx 5 os
-rwxrwxrwx 24 time
-rwxrwxrwx 16 type
-rwxrwxrwx 10 load_addr
-rwxrwxrwx 10 entry_point
-rwxrwxrwx 1292 data0
-rwxrwxrwx 983 data1
-rwxrwxrwx 2287 data
-rwxrwxrwx 10 data.crc
you can get the image header via an ioctl on any file
UIMAGEFS_METADATA
if you want to check the crc do
# crc32 -f /tmp-multi/data -V /tmp-multi/data.crc
CRC32 for /tmp-multi/data 0x00000000 ... 0x000008ee ==> 0x88d5a0db
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds ubifs support from u-boot-2013.07. This is taken
mostly as-is, only the necessary adjustments to attach to the
barebox fs layer have been made.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
cdev_open() opens a cdev by name. This introduces cdev_do_open which
allows to open a cdev when the cdev is already found by other means.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
currently most partition cdevs have the name <devname>.<partname>
This makes it hard to find a partition by <partname>. This introduces
a partname field in struct cdev so that.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Some tftp servers (for example netkit-tftp) do not pass the filesize.
Add a workaround for read_file which reads the file into a temporary
file which then is copied to a buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Some systems are runnignfrom a very limited SRAM, but have a huge
malloc space in SDRAM. The bss normally is in SRAM, so we should
avoid having big structures there. The FILE table is 5120 bytes
big, so allocate it dynamically instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Add pread and pwrite functions.
Split read and write functions to save some space.
The functions pread and pwrite saves and sets the file
position to a given offset and restore them afterwards.
This also makes the nandtest command use these function
which is necessary to not break compilation for the nandtest
command.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
When during tftp receive operation a ACK packet can't successfully be sent
the timer was resetted directly after send resulting in a deadlock.
This patch changes the timer reset operation in a way that it is only resetted
when the actually is progress, namely in the TFTP_ACK/TFTP_DATA pathes in the
tftp handler.
Reported-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Antony Pavlov <antonynpavlov@gmail.com>
To make that, we need to shift mtd_erase before mtd_ioctl.
ubi-utils need that, especially ubiformat.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
dev_add_child is a very unsafe function. If called multiple times
it allows setting the same device to different parents thus corrupting
the siblings list. This happens regularly since:
| commit c2e568d19c
| Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| Date: Sat Nov 3 16:11:05 2012 +0100
|
| bus: add bus device
|
| automatically add it as parent of any bus device if none already specified
|
| we have now a nice output per bus
If for example a FATfs is mounted this nice output per bus often ends with:
> `---- fat0
> `---- 0
> `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL>
> `---- sram00
> `---- 0x00000000-0xffffffffffffffff: /dev/<NULL>
> `---- 0x00000000-0xffffffffffffffff: /dev/<NULL>
> unable to handle NULL pointer dereference at address 0x0000000c
> pc : [<87f08a20>] lr : [<87f08a04>]
> sp : 86eff8c0 ip : 87f3fbde fp : ffffffff
> r10: ffffffff r9 : 00000000 r8 : 00000003
> r7 : 86f075b8 r6 : 00000002 r5 : ffffffec r4 : 86f07544
> r3 : 00000000 r2 : 43f900b4 r1 : 00000020 r0 : 00000005
> Flags: Nzcv IRQs off FIQs off Mode SVC_32
> [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130)
>
> [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c)
> [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14)
> [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38)
> [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60)
This patch fixes this by adding a device to its parents children list in
register_device so that dev_add_child is no longer needed. This function
is removed from the tree. Now callers of register_device have to clearly
set the parent *before* registering a device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Jan Lübbe <jlu@pengutronix.de>
This patch provides a global cleanup barebox Kconfig files. This includes
replacing spaces to tabs, formatting in accordance format, removing
extraneous lines and spaces. No functional changes.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The ext4 implementation has been taken from U-Boot with some
changes:
- No global variables to allow for multiple filesystems to
be mounted and multiple files to be open.
- remove fs internal link following and use the barebox link
implementation.
- remove write support. This is incomplete in U-Boot, so I decided
to skip this for now.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
In tftp_read we send a request for a new packet without checking if we
have enough space in the FIFO. This can lead to a FIFO overflow and a
corrupt file. Add a check for it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tftp_send is called often. Each time, when in STATE_RDATA, a packet
is requested from the tftp server, even if we requested the same packet
already.
Stop this by tracking which packet we requested.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>