Re: Makefile gcc -o /dev/null: the dissapearing of /dev/null

Jim Treadway (jim@stardot-tech.com)
Sat, 29 Sep 2001 20:03:34 -0700 (PDT)


On Sat, 29 Sep 2001, Jan-Benedict Glaw wrote:

> On Sat, 2001-09-29 06:10:52 -0700, Jim Treadway <jim@stardot-tech.com>
> wrote in message <Pine.LNX.4.33.0109290535390.25966-100000@cerberus.stardot-tech.com>:
> >
> > So then you can no longer 'make modules && make modules_install', or you
> > have to cp or chown /usr/src/linux on a fresh install to compile your
> > kernel? Doesn't sound pleasant to me.
>
> You may do it this way:
>
> make dep clean bzImage modules && su -c "make modules_install"
>
> This is so far the minimal version for building as non-root user.

Except...

a) It doesn't work (yeah, I'm sure there are many, many, many other
work-arounds, but I can't believe I'm the only one compiling as root):

$ cd /usr/src/linux
$ make dep clean bzImage modules && su -c "make modules_install"
make[1]: Entering directory `/usr/src/linux/arch/i386/boot'
make[1]: Nothing to be done for `dep'.
make[1]: Leaving directory `/usr/src/linux/arch/i386/boot'
scripts/mkdep init/*.c > .depend
/bin/sh: .depend: Permission denied
make: *** [dep-files] Error 1

b) You are still evaluting most, if not all, of the lines in the Makefiles
that do "gcc -o /dev/null", as root.

> > I think the "trick" is to redirect stdout and stderr to /dev/null as well,
> > so that /dev/null doesn't get removed from the file system since it is
> > held open by the shell.
> >
> > Something like:
> >
> > gcc -o /dev/null -xc /dev/null /dev/null 2>&1
>
> No-go. It's perfectly okay to remove an opened file. Test it yourself.
> You may even replace a running (!) executable...

Which is exactly why I suggested keeping it open via I/O redirection
(except see below).

> > Perhaps someone just forgot the I/O redirection in one of the tests?
>
> No. It would be of no effect:-)

You are right here though...the I/O redirection doesn't have anything to
do with it, assuming you pass the -S flag to gcc, which I neglected, and
insert the missing '>' in my example above (oops).

But... this seems to be moot since in my case however /dev/null stays
around even when compiling as root. ;)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/