s6-portable-utils
Software
skarnet.org
The s6-hiercopy program
s6-hiercopy copies a directory structure recursively.
Interface
s6-hiercopy source destination
- s6-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 s6-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 impossible to
design, much less write, such a utility. Notably,
you cannot 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. As a result, s6-hiercopy
is a walking race condition and should absolutely not
be considered instant when used in a multitasking environment.
But then, cp shouldn't either.
- There is no standard way of creating device nodes on a
filesystem, so any cp-like utility is inherently
non-portable. Fortunately, most systems still agree on the non-portable usages of
mknod
specification, so things should work in practice. Consequently,
the s6-hiercopy utility has been moved from
s6-linux-utils
to s6-portable-utils.