Bug 8216

Summary: cp -Ll doesn't dereference symlinks
Product: Busybox Reporter: Adam Sampson <ats>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.23.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description Adam Sampson 2015-07-10 16:52:02 UTC
GNU cp and busybox cp behave differently if both -L (follow symlinks) and -l (create hardlinks) are specified, and you try to copy a symlink.

GNU cp (8.24) makes a hardlink to the file that's the target of the symlink.

busybox cp (1.23.2) makes a hardlink to the symlink itself.

Here's an example:

$ date >orig
$ ln -s orig symlink
$ cp -Ll symlink gnu-copy
$ busybox cp -Ll symlink busybox-copy
$ ls -li orig symlink gnu-copy busybox-copy
64454 lrwxrwxrwx 2 ats ats  4 Jul 10 17:48 busybox-copy -> orig
64453 -rw-r--r-- 2 ats ats 29 Jul 10 17:48 gnu-copy
64453 -rw-r--r-- 2 ats ats 29 Jul 10 17:48 orig
64454 lrwxrwxrwx 2 ats ats  4 Jul 10 17:48 symlink -> orig

-l isn't specified by POSIX, but the GNU cp behaviour is basically what I'd expect.