minutils
Software
www.skarnet.org
The hiercopy program
hiercopy copies a directory structure recursively.
Interface
hiercopy source destination
- hiercopy recursively copies source to
destination, which is created if it doesn't exist.
The permissions are preserved. The owner and group are preserved
if the user is the superuser.
- It exits 0 on success and 111 on temporary failure.
Notes
Copying files and browsing through directories is one of Unix's
weakest points, and hiercopy is not meant to work around
the problem; it's only a quick hack that I needed to boot my embedded
platform. I originally planned to write the ultimate cp utility,
portable and reliable and featureful and everything - while needing
approximately a hundred times less resources than GNU cp does,
of course. But I eventually dropped the idea: it's just impossible to
design, much less write, such a utility.
- You can't make it portable because there's no universal standard.
There is no portable way of creating device special files, for instance.
So hiercopy appears here instead of in
skaembutils:
the platform where I needed that kind of tool is Linux.
- You can't make it reliable because Unix's set of filesystem
management primitives is just too weak. It lacks a lot of atomic
operations, and filesystem transactions. I await
ReiserFS 4 with impatience: at
last we'll have a filesystem with a transactional interface. But it's
not there yet, and it's not standard Unix. As a result, hiercopy
is stuffed with race conditions and should ABSOLUTELY NOT be considered
reliable when used in a multitasking environment.
But then, cp -a shouldn't either, and I only need
hiercopy at boot time before other processes are launched,
so I didn't even bother trying to avoid race conditions that actually
could be avoided with a little more work.