tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Short circuit cp -l



On Wed 18 Jul 2018 at 13:02:03 +0000, Christos Zoulas wrote:
> Let's survey the other implementations (linux, etc.) and see what they
> do, and decide. We should document this clearly as well as stating what
> other implementations do, and why we decided to do what we decided so others
> don't have to re-do this in the future.

It seems linux cp -lr also links files it would not be able to read:

rhialto:~/tmp$ cp -lr dir1 dir1a
rhialto:~/tmp$ l -R dir1
dir1:
total 12
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:13 ./
drwxrwxr-x 5 rhialto rhialto 4096 Jul 18 21:13 ../
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 a
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 b
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 c
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:13 dir2/

dir1/dir2:
total 8
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:13 ./
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:13 ../
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 d
---------- 2 rhialto rhialto    0 Jul 18 21:13 e
---------- 2 rhialto rhialto    0 Jul 18 21:13 f
rhialto:~/tmp$ l -R dir1a
dir1a:
total 12
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:13 ./
drwxrwxr-x 5 rhialto rhialto 4096 Jul 18 21:13 ../
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 a
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 b
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 c
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:13 dir2/

dir1a/dir2:
total 8
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:13 ./
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:13 ../
-rw-rw-r-- 2 rhialto rhialto    0 Jul 18 21:13 d
---------- 2 rhialto rhialto    0 Jul 18 21:13 e
---------- 2 rhialto rhialto    0 Jul 18 21:13 f
rhialto:~/tmp$ cp -r dir1 dir1b
cp: cannot open 'dir1/dir2/e' for reading: Permission denied
cp: cannot open 'dir1/dir2/f' for reading: Permission denied
rhialto:~/tmp$ l -R dir1b
dir1b:
total 12
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:15 ./
drwxrwxr-x 6 rhialto rhialto 4096 Jul 18 21:15 ../
-rw-rw-r-- 1 rhialto rhialto    0 Jul 18 21:15 a
-rw-rw-r-- 1 rhialto rhialto    0 Jul 18 21:15 b
-rw-rw-r-- 1 rhialto rhialto    0 Jul 18 21:15 c
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:15 dir2/

dir1b/dir2:
total 8
drwxrwxr-x 2 rhialto rhialto 4096 Jul 18 21:15 ./
drwxrwxr-x 3 rhialto rhialto 4096 Jul 18 21:15 ../
-rw-rw-r-- 1 rhialto rhialto    0 Jul 18 21:15 d
rhialto:~/tmp$ cp --version
cp (GNU coreutils) 8.25
Copyright (C) 2016 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 Torbjörn Granlund, David MacKenzie, and Jim Meyering.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl      -- are condemned to reinvent it. Poorly.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index