[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: Strange echo behaviour
From: Baruch Siach <baruch () tkos ! co ! il>
Date: 2011-01-27 11:30:38
Message-ID: 20110127113037.GG12588 () jasper ! tkos ! co ! il
[Download RAW message or body]
Hi Denys,
On Thu, Jan 27, 2011 at 10:07:31AM +0100, Denys Vlasenko wrote:
> On Thu, Jan 27, 2011 at 7:59 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> > Here is some more information that may help in understanding this issue.
> >
> > I've only observed this problem when running a statically linked Busybox
> > linked against uClibc 0.9.30.3, and only when running echo directly from the
> > shell (ash). When I run
> >
> > ./strace-armv5l echo 56 > /sys/class/gpio/export
> >
> > I see
> >
> > write(1, "56\n", 3) = -1 EBUSY (Device or resource busy)
> > write(1, "56\n", 3) = -1 EBUSY (Device or resource busy)
> >
> > as expected,
>
> I wouldn't call this "expected". Why there are two writes?
> User definitely didn't instruct echo to do multiple writes!
>
> > but when I run
> >
> > ./strace-armv5l sh -c 'echo 56 > /sys/class/gpio/export'
> >
> > I see
> >
> > write(1, "56\n", 3) = -1 EBUSY (Device or resource busy)
> > write(1, "5", 1) = 1
> >
> > So apparently this problem has something to do with either uClibc or ash, not
> > echo.
>
> Looks like uClibc. Need to experiment with glibc...
Indeed. You can easily trigger this and the following bug on x86 using Rob's
static uClibc Busybox build
(http://landley.net/aboriginal/downloads/binaries/old/1.0.0/extras/busybox-x86_64).
Does a write() based implementation of echo looks like a solution for you?
baruch
> > However, we can implement echo using write(), thus avoiding the
> > buffering of stdio.
> >
> > Another related problem that I've observed with echo goes as follows:
> >
> > ./strace-armv5l sh -c 'echo test > /dev/input/event0'
> >
> > shows:
> >
> > write(1, "test\n", 5) = 16
> > write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., \
> > 2147483647) = -1 EFAULT (Bad address) write(1, \
> > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4095) = \
> > 4096 write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., \
> > 2147483647) = -1 EFAULT (Bad address) write(1, \
> > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = \
> > 4096
> > That is, the return value of write() is larger that the written buffer (is
> > this legal?) so echo (or ash) tries again with a bogus count == -1.
>
> Horror.
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic