Busybox make, modify my /dev/null on host
Denys Vlasenko
vda.linux at googlemail.com
Mon Feb 11 08:06:56 UTC 2008
On Sunday 10 February 2008 22:26, Mike Frysinger wrote:
> On Sunday 10 February 2008, Martinb_ARM_NOMMU_KISSDVD wrote:
> > After 2 weeks of the strangest things happening to my /dev/null I did find
> > a relation on this problem and the use of busybox (compiling)
This is a generic UNIX administration problem.
Many programs would inadvertently delete /dev/null
in unusual cases. Heck, even busybox had a bug where
if you would specify that pidfile is "/dev/null",
it was deleting it! Now we protect against that:
void write_pidfile(const char *path)
{
...
pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (pid_fd < 0)
return;
/* path can be "/dev/null"! Test for such cases */
wrote_pidfile = (fstat(pid_fd, &sb) == 0) && S_ISREG(sb.st_mode);
...
}
#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
From the POV of UNIX admin, though, I find it impractical to ensure
that all installed programs are not buggy. I want to make /dev/null
not deletable instead. ext[23] immutable bit can help, but what to do
on ramfs? :(
> your toolchain is broken. either dont build as root or upgrade your gcc and
> binutils. older versions of both would unlink the output even if it were a
> character device.
Yes, it probably happens somewhere here:
scripts/trylink:
check_cc() {
if $CC $1 -shared -o /dev/null -xc /dev/null >/dev/null 2>&1; then
echo "$1";
else
echo "$2";
fi
}
scripts/Kbuild.include:
as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
-xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
else echo "$(2)"; fi ;)
(these are just examples, there are more such cases).
Add ls -l /dev/null before and after these statements and you
will see which invocation of gcc kills /dev/null.
--
vda
More information about the busybox
mailing list