Home Forum Developers General discussions Command cp in ip04 vs cp in ubuntu

JRPassphrase Registration Control

In order to register on this site, you must first submit the passphrase below.

TODO list for each hardware target can be found as sticky topic in the corresponding forum


fant
useravatar
User Info

Command cp in ip04 vs cp in ubuntu

Hi guys,

I copy file to symlink, and I have different result in ip04 and Ubuntu.
File replace symlink in ip04. Why?
That behaviour of command "cp" is correct?

Andrej

in IP04

Code:

root@ip0x:~> cat > 1

111111

root@ip0x:~> ln -sf 1 2
root@ip0x:~> cat > 3
33333

root@ip0x:~> cp 3 2
root@ip0x:~> cat 1
111111
root@ip0x:~> ls -l
-rw-r--r--    1 root     root             7 Oct 21 11:48 1
-rw-r--r--    1 root     root             6 Oct 21 11:48 2
-rw-r--r--    1 root     root             6 Oct 21 11:48 3

In Ubuntu

Code:

$ cat > 1

111111
^C
$ ln -sf 1 2
$ cat > 3
33333
^C
$ cp 3 2
$ ls -l
-rw-r--r--  1 an an    6 2011-10-21 11:39 1
lrwxrwxrwx  1 an an    1 2011-10-21 11:39 2 -> 1
-rw-r--r--  1 an an    6 2011-10-21 11:39 3
$ cat 1
33333



Edited By:  fant
Oct-21-11 12:26:17

Administrator has disabled public posting
Chewi
useravatar
User Info

Re: Command cp in ip04 vs cp in ubuntu

We use Busybox cp, not GNU cp, and apparently the behaviour is intended as the author disagrees with the POSIX behaviour.

http://lists.busybox.net/pipermail/busy … 69533.html

I'm on the fence with this one. I can see his point and Busybox doesn't pretend to be POSIX compliant but breaking compatibility for idealogical reasons seems controversial.


Administrator has disabled public posting
fant
useravatar
User Info

Re: Command cp in ip04 vs cp in ubuntu

Hi Chewi,

Thanks to answer. BusyBox v1.4.1 not replaced link. hmm


Code:

BusyBox v1.4.1 (2009-05-19 16:40:05 EEST) Built-in shell (msh)

Enter 'help' for a list of built-in commands.

root:/> cat > 1
11111
root:/> ln -sf 1 2
root:/> cat > 3
3333
root:/> cp 3 2
root:/> ls -l
-rw-r--r--    1 root     root            5 Oct 21 08:43 1
lrwxrwxrwx    1 root     root            1 Oct 21 08:43 2 -> 1
-rw-r--r--    1 root     root            5 Oct 21 08:43 3
root:/> cat 1
3333
root:/> uname -a
Linux blackfin 2.6.22.18-ADI-2008R1-svn #253 Thu Oct 15 14:13:30 EEST 2009 blackfin unknown

How work command "cat" with binary file? Zero will not be taken as an end of file? Or other shadow problem?

   cat binary.file > /dev/xxx

Andrej


Administrator has disabled public posting
Chewi
useravatar
User Info

Re: Command cp in ip04 vs cp in ubuntu

1.4.1 is very old. Trunk is using 1.16.2 and my Gentoo system is using 1.19.2, which is also displaying this behaviour.


Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 2587  Total Topics: 299  Total Polls: 1  Total Posts: 1727  Dormant
User Info:   Newest User :  user2553   Members Online: 0   Guests Online: 227
Online  There are no members online
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked