Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Quick Unixy Q.


>Here's a quick one... What is /dev/zero used for, and what are a few good
>examples?

Here's a couple Makefile rules I used to pad a target file to the right
number of bytes:

# rules to make a LILO-bootable image
%.lilo:		%.rom $(LILOPREFIX)
	cat $(LILOPREFIX) $< /dev/zero | head -c 64k > $@

%.lzlilo:	%.lzrom $(LILOPREFIX)
	cat $(LILOPREFIX) $< /dev/zero | head -c 64k > $@

Essentially I'm using it as an inexhaustible source of nul bytes.

I *think* the dynamic loader uses it to null fill memory areas, which is
why removing /dev/zero stops executables that use shared libs from
working.