cat returns EINVAL for sysfs entry in ifup script

John Faith jfaith7 at gmail.com
Thu Jan 6 19:18:24 UTC 2011


Hi,
Using busybox 1.13.2 on an ARM board, I use 'cat
/sys/class/net/eth0/speed' in a script in /etc/network/if-pre-up.d/
called by ifup.  strace shows that read() is not happy:

open("/sys/class/net/eth0/speed", O_RDONLY|O_LARGEFILE) = 3
read(3, 0xbed1cc88, 4096)        = -1 EINVAL (Invalid argument)
cat: read error: Invalid argument

strace from the command line shows:
open("/sys/class/net/eth0/speed", O_RDONLY|O_LARGEFILE) = 3
read(3, "100\n", 4096)                 = 4

Running the same command in a shell is fine, /bin/sh points to busybox
(not bash), and if I try a text file with 'cat /tmp/catme' also in the
ifup script, all is fine.

Why might a sysfs entry behave differently than a text file in this case?

Thanks!
,
John


More information about the busybox mailing list