Subject: bug#10686: mv: moving hardlink of a softlink to the softlink does nothing

From: Bernhard Voelker <[email-masked]>
Date: Tue, 07 Feb 2012 13:26:09 +0100

On 02/07/2012 11:45 AM, Michael Felt wrote:
> Just reading - for reference only - AIX 5.3, and I expect new versions behave as follows
> (second link becomes a hardlink to original file, mv "removes" one hard link, i.e. original file (as inode) remains.
> 
> root@x105:[/tmp/test]touch f
> root@x105:[/tmp/test]ln -s f l
> root@x105:[/tmp/test]ls -l
> total 0
> -rw-r--r--  1 root system 0 2012-02-07 11:41 f
> lrwxrwxrwx  1 root system 1 2012-02-07 11:41 l -> f
> root@x105:[/tmp/test]ln l s
> root@x105:[/tmp/test]ls -ogi
> total 0
> 239 -rw-r--r--  2 0 2012-02-07 11:41 f
> 240 lrwxrwxrwx  1 1 2012-02-07 11:41 l -> f
> 239 -rw-r--r--  2 0 2012-02-07 11:41 s
> root@x105:[/tmp/test]mv s f
> root@x105:[/tmp/test]ls -ogi
> total 0
> 239 -rw-r--r--  1 0 2012-02-07 11:41 f
> 240 lrwxrwxrwx  1 1 2012-02-07 11:41 l -> f

Hi Michael,

the result is the same, but there's a little difference here:
your ln does not create a hardlink to the symlink, but
rather a hardlink to the symlink's *target*.

On Linux, the situation before mv looks like this:

  $ touch f && ln -s f l && ln l s && ls -ogi
  total 0
  11279 -rw-r--r-- 1 0 Feb  7 13:17 f
  11280 lrwxrwxrwx 2 1 Feb  7 13:17 l -> f
  11280 lrwxrwxrwx 2 1 Feb  7 13:17 s -> f

Before Jim's patch, mv didn't remove the source, i.e. 's':

  $ /bin/mv s l ; ls -ogi
  total 0
  11279 -rw-r--r-- 1 0 Feb  7 13:17 f
  11280 lrwxrwxrwx 2 1 Feb  7 13:17 l -> f
  11280 lrwxrwxrwx 2 1 Feb  7 13:17 s -> f

Now, mv correctly unlinks 's':

  $ ~/git/coreutils/src/mv s l ; ls -ogi
  total 0
  11279 -rw-r--r-- 1 0 Feb  7 13:17 f
  11280 lrwxrwxrwx 1 1 Feb  7 13:17 l -> f

Regarding your case, there's no change.

Have a nice day,
Berny