|
|
The cpio(C) command copies file archives usually to or from a storage medium such as tape, disk, or diskette. By default, cpio does not follow symbolic links, unless the -L option used with the -o and -p options to indicates that symbolic links should be followed. Note that this option is not valid with the -i option.
Normally, a user invokes the find(C) command to produce a list of filenames and pipes this into the cpio(C) command to create an archive of the files listed. The find(C) command also has a new option -follow to indicate that symbolic links should be followed. If a user invokes find(C) with the -follow option, then cpio(C) must also be invoked with its new option -L to indicate that it too should follow symbolic links.
When evaluating the output from find(C), following or not following symbolic links only makes a difference when a symbolic link to a directory is encountered. For example, if /usr/jan/symd is a symbolic link to the directory ../joe/test and files test1 and test2 are in directory /usr/joe/test, the output of a find starting from /usr/jan includes the file /usr/jan/symd if symbolic links are not followed, but includes /usr/jan/symd/test1 and /usr/jan/symd/test2 as well as /usr/jan/symd if symbolic links are followed.
If the user wants to preserve the structure of the directories being archived, it is recommended that symbolic links not be followed on both commands. (This is the default.) When this is done symbolic links will be preserved and the directory hierarchy will be duplicated as it was. If the user is more concerned that the contents of the files be saved, then the user should use the -L option to cpio(C) and the -follow option to find(C) to follow symbolic links.
The -i option to cpio(C) copies symbolic links as is. So if a user creates an archive to be read in on a pre-System V Release 4 system, it may be more useful to follow symbolic links because System V prior to Release 4 lacked symbolic links and the result of copying in a symbolic link will be a regular file containing the pathname of the referenced file.