[BusyBox] PATCH: cp /dev/null some_file

Glenn McGrath bug1 at iinet.net.au
Sun May 30 13:34:27 UTC 2004


On Sun, 30 May 2004 09:08:35 -0400
<tom at ceisystems.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Anthony,
> 
> > Below is a bug fix for the common idiom
> > 	cp /dev/null some_file
> > to create an empty file.
> 
> I know this is getting a little off subject here, but what is the
> _correct_ thing to do when cp gets a device file for its source?
> Should it copy the dev file? I would think this would be the proper
> thing to do. What I'm getting at here is this- should we taint busybox
> with fixes for broken thinking? Isn't this what makes glibc and all of
> the standard tools so big?

When -R is used it should do the equivilent of mknod, if the
device node is specificaly mentioned as the source file then the
contents of the source file should be copied.

"The difference between -R and -r is in the treatment by cp of file
types
other than regular and directory. The original -r flag, for historic
reasons, does not handle special files any differently from regular
files, but always reads the file and copies its contents. This has
obvious problems in the presence of special file types; for example,
character devices, FIFOs, and sockets. The -R option is intended to
recreate the file hierarchy and the -r option supports historical
practice." - from SuSv3 under the topic Application Usage.


Glenn



More information about the busybox mailing list