[BusyBox] /bin/ls reads /etc/ files for every file listed
Rob Landley
rob at landley.net
Sun Jan 2 19:35:09 UTC 2005
On Sunday 02 January 2005 02:12 am, Penelope Fudd wrote:
> Package: BusyBox
> Version: 1.00
>
> When I execute 'strace -fo/tmp/a ls -l' it shows that the files /etc/TZ,
> /etc/passwd and /etc/group are being opened and read between each file
> being printed.
[mondo snippage]
> Maybe the /etc/TZ reads could be cut down a bit?
Those reads are actually coming from uClibc, not from busybox. (I grepped
busybox for "TZ" and all I found was an environment variable by that name.)
Busybox is obviously doing something to trigger them, but uclibc seems to be
relying on the filesystem cache rather than caching quite so much. Was your
comparison done with gnu ls compiled against uclibc, or against glibc?
/etc/TZ contains something like eight bytes of data, and the filesystem has a
cache. It's ugly, but not as ugly as actually hitting the disk. (I suspect
the unnecessary open/read/close syscalls to re-read it each time were judged
to be less complexity than cacheing it and figuring out when to make a stat()
syscall to see if it had changed...) I'm not personally going to thump on
uclibc itself much until (unless?) 0.9.27 ships...
As for passwd and group, it looks like the other ls/glibc is mmaping them,
which sounds like a good idea in a memory constrained environment anyway. A
quick grep shows we could probably clean this up a bit:
./libbb/messages.c:#define PASSWD_FILE "/etc/passwd"
./libpwdgrp/pwd_grp.c:#define _PATH_PASSWD "/etc/passwd"
Assuming the subversion repository ever goes in, anyway. Eric?
Rob
More information about the busybox
mailing list