8000 mv compatibility: moving dangling symlink into directory (stat follows symlink, breaks musl PKGBUILD) · Issue #8044 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
mv compatibility: moving dangling symlink into directory (stat follows symlink, breaks musl PKGBUILD) #8044
Closed
@kpcyrd

Description

@kpcyrd

hello!

While building the Arch Linux musl PKGBUILD with uutils I noticed mv is failing to rename a symlink that does indeed exist:

+ mv /os/musl/pkg/musl/lib/ld-musl-x86_64.so.1 /os/musl/pkg/musl/usr/lib/
mv: cannot stat '/os/musl/pkg/musl/lib/ld-musl-x86_64.so.1': No such file or directory
# stat /os/musl/pkg/musl/lib/ld-musl-x86_64.so.1
  File: "/os/musl/pkg/musl/lib/ld-musl-x86_64.so.1" -> "/usr/lib/musl/lib/libc.so"
  Size: 25        	Blocks: 8          IO Block: 4096   symbolic link
Device: 1ah/26d	Inode: 203691771   Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-06-02 12:39:41.466226783 +0000
Modify: 2025-06-02 12:39:41.423226746 +0000
Change: 2025-06-02 12:39:41.463226780 +0000
 Birth: 2025-06-02 12:39:41.423226746 +0000

The file it's symlinking to does not, however.

This works with both coreutils:

% ln -s 404 abc
% mv abc def
% ls
lrwxrwxrwx - user user  2 Jun 14:43 def -> 404

This works with gnu/coreutils:

% ln -s 404 abc
% mkdir x
% mv abc x
% ls -la x 
lrwxrwxrwx - user user  2 Jun 14:49 abc -> 404

This does not with uutils/coreutils:

# ln -s 404 abc
# mkdir x
# mv abc x
mv: cannot stat 'abc': No such file or directory
# ls x  
# ls
abc  x

I assume this is because mv incorrectly follows symlinks when it shouldn't, this however seems to work correctly (the file is moved to x/def instead of x/abc):

# touch abc
# ln -s abc def
# mkdir x
# mv def x
# ls x
def

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0