Bug 9821

Summary: redirect to file fails ( echo haha > dummy.txt ): "1: Invalid argument"
Product: Busybox Reporter: pkass <busybox_001>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED WORKSFORME    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description pkass 2017-04-16 10:05:57 UTC
Version info:
BusyBox v1.26.2 (2017-01-10 16:08:05 UTC) multi-call binary.

HW: D-Link DNS-323 Network Storage (ARM)

/ # env
USER=root
SHLVL=1
OLDPWD=/mnt/HD_a2/lnx_bin
HOME=/
TERM=vt102
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/mnt/HD_a2/lnx_bin/
SHELL=/bin/sh
PWD=/

Replaced "BusyBox v1.00-pre1 (2008.09.02-11:43+0000) multi-call binary" by v1.26.2.

No Problems with old Version. But with v1.26.2 redirect to any file fails.
But piping works 
( my current Workaround: use "echo haha | tee dummy.txt" instead of "echo haha > dummy.txt")
Comment 1 Denys Vlasenko 2017-04-17 13:55:37 UTC
Obviously, this does not usually happen on 
1.26.2 (otherwise there would be tons of angry users on the mailing list).

This may be related to your .config, your libc, or your compiler. I'm not saying it's your fault: it may be a real bug which is only revealed by your .config, your libc, or your compiler.

If you can reproduce this on an x86 machine, please post your .cpnfig which exhibits the bug. Otherwise, if this only happens on your ARM hardware, follow example at
    https://busybox.net/FAQ.html#emu
how to make it possible for others to reproduce an ARM-specific bug in a qemu.
Comment 2 pkass 2017-04-18 01:46:11 UTC
I did not build it by myself, but used the binary from https://www.busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/busybox-armv4l
Reduced importance to "minor" as this seems to be a rare problem caused by some weird combinations of issues in my runtime environment.
BTW: tried also versions 1.21.1, 1.16.0 ==> all the same: "sh" and "ash" are not able to accept redirections of stdout or stderr.
BTW2: I found http://svn.dd-wrt.com/ticket/5784 , so I thought, that might be a more frequent problem.

I do not have time and resources to investigate it further.

The original motivation to install a newer busybox Version was my search for a "find" command which supports "-type l" Option.
A "find" script with content: 'busybox_1.26.2 find "$@"' does the job, so, no further activity expected from my side.
Comment 3 Denys Vlasenko 2017-04-18 15:27:15 UTC
(In reply to pkass from comment #2)
> I did not build it by myself, but used the binary from https://www.busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/busybox-armv4l

Here I test this very same binary in qemu using Rob's system-image-armv4l.tar.gz:

(armv4l:1) /home $ ./busybox-armv4l sh
(armv4l:1) /home $ echo foo > /tmp/bar
(armv4l:1) /home $ ls -l /tmp/bar
-rw-r--r-- 1 root root 4 2017-04-18 15:24 /tmp/bar

For reference, qemu command line is:
qemu-system-arm -M versatilepb -nographic -no-reboot -kernel linux -initrd rootfs.cpio.gz -append "panic=1 console=ttyAMA0 HOST=armv4l