In manual https://www.gnu.org/software/cpio/manual/cpio.html
If you wanted to archive an entire directory tree, the find command can
provide the file list to cpio:
% find . -print -depth | cpio -ov > tree.cpio
The-depthoption forces ‘find’ to print of the entries in a directory
before printing the directory itself. This limits the effects of
restrictive directory permissions by printing the directory entries in a
directory before the directory name itself.
Аs I understand it's in the case when a directory have no write
permission for user who extract the archive, because if cpio create
first a directory with no permission to write he will not be able to add
a new file in this directory from the archive.
BUT
user@s9ffd145e:~/tmp$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
user@s9ffd145e:~/tmp$ cpio --version
cpio (GNU cpio) 2.11
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Phil Nelson, David MacKenzie, John Oleynick,
and Sergey Poznyakoff.
user@s9ffd145e:~/tmp/orig$ ls -l
total 4
drwxr-xr-x 2 user user 4096 Aug 29 23:22 dir
user@s9ffd145e:~/tmp/orig$ chmod -w dir
user@s9ffd145e:~/tmp/orig$ ls -ld dir
*dr-xr-xr-x 2 user user 4096 Aug 29 23:22 dir # *no write permission
user@s9ffd145e:~/tmp/orig$ find
.
*./dir* # dir with no write permission is first
./dir/file2
./dir/file1
user@s9ffd145e:~/tmp/orig$ find -print0 | cpio -0o > ../test.cpio
1 block
user@s9ffd145e:~/tmp/orig$ cd ..
user@s9ffd145e:~/tmp$ cpio -tv < test.cpio
drwxr-xr-x 3 user user 0 Aug 29 23:26 .
*dr-xr-xr-x 2 user user 0 Aug 29 23:22 dir* # dir with
now write permission is first
-rw-r--r-- 1 user user 0 Aug 29 23:22 dir/file2
-rw-r--r-- 1 user user 0 Aug 29 23:22 dir/file1
1 block
user@s9ffd145e:~/tmp$ mkdir copy
user@s9ffd145e:~/tmp$ cd copy/
user@s9ffd145e:~/tmp/copy$ cpio -i < ../test.cpio
1 block
user@s9ffd145e:~/tmp/copy$ ls -Rl
.:
total 4
dr-xr-xr-x 2 user user 4096 Aug 29 23:31 dir
./dir:
total 0
-rw-r--r-- 1 user user 0 Aug 29 23:31 file1
-rw-r--r-- 1 user user 0 Aug 29 23:31 file2
If dir was create first, why file was create in dir with no permission
to write?
user@s9ffd145e:~/tmp/copy$ touch dir/file3
touch: cannot touch 'dir/file3': Permission denied
29.08.2017 12:25, Sergey Poznyakoff пишет:
mad1ost <mad1...@mail.ru> ha escrit:
For the second question, should I create a new message with other
subject or can I write here?
As you wish, Andrey. I'm equally comfortable both ways.
Regards,
Sergey