bugfindutils - Bugs: bug #54667, find -type l fails to find symlink...

 
 

bug #54667: find -type l fails to find symlink on NTFS volumes under linux

Submitter:  Aaron Queenan <aqueenan>
Submitted:  Mon 17 Sep 2018 12:18:29 AM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  4.6.0 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 23 Sep 2018 12:23:44 PM UTC, comment #4: 

As far as I can see, this is a bug in the file system implementation, not in findutils.

James Youngman <jay>
Group administrator
Tue 18 Sep 2018 02:47:32 PM UTC, comment #3: 

I don't have ufsd to test with, but if I had to guess I'd say it's probably returning DT_REG in d_type for symlinks, but still returning S_IFLNK from stat() for them.  Depending on whether stat() is called, you may get the right or the wrong type, which explains the difference between %Y being specified or not.

Tavian Barnes <tavianator>
Tue 18 Sep 2018 01:35:21 AM UTC, comment #2: 

It appears to be using ufsd not ntfs-3g.


[admin@storage test]# stat --format "%m" .
/share/external/sdv2

[admin@storage test]# mount
/dev/sdv2 on /share/external/sdv2 type ufsd (rw,iocharset=utf8,dmask=0000,fmask=0111,force)


Aaron Queenan <aqueenan>
Mon 17 Sep 2018 05:30:15 PM UTC, comment #1: 

What ntfs driver are you using?  I couldn't reproduce this with ntfs-3g.

Tavian Barnes <tavianator>
Mon 17 Sep 2018 12:18:29 AM UTC, original submission:  

Given the following files, including a link created with ln -s on the same system, several problems occur with symlinks on NTFS volumes.

[admin@storage test]# l
-rw-rw-rw-    1 admin    administ         0 Sep 17 07:43 file
lr--r--r--    1 admin    administ        18 Sep 17 07:43 link -> file

System


[admin@storage test]# uname -a
Linux storage 3.4.6 #1 SMP Wed Aug 29 12:08:32 CST 2018 x86_64 unknown

find -type l behaviour


The first problem is that –type l doesn’t find the symlink at all and –type f includes symlinks in the result.

GNU find


[admin@storage test]# find --version
find (GNU findutils) 4.6.0
Copyright (C) 2015 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 Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

[admin@storage test]# find . -type l

BusyBox


The BusyBox version of find correctly detects the symlink.

[admin@storage test]# /usr/bin/find --version
BusyBox v1.01 (2018.08.29-02:29+0000) multi-call binary

Usage: find [PATH...] [EXPRESSION]

Search for files in a directory hierarchy.  The default PATH is
the current directory; default EXPRESSION is '-print'

EXPRESSION may consist of:
        -follow         Dereference symbolic links.
        -name PATTERN   File name (leading directories removed) matches PATTERN.
        -print          Print (default and assumed).

        -type X         Filetype matches X (where X is one of: f,d,l,b,c,...)
        -perm PERMS     Permissions match any of (+NNN); all of (-NNN);
                        or exactly (NNN)
        -mtime TIME     Modified time is greater than (+N); less than (-N);
                        or exactly (N) days

[admin@storage test]# /usr/bin/find . -type l
./link

GNU bash


Some other GNU tools, including [[ in GNU bash correctly detect the symlink.

[admin@storage test]# bash --version
GNU bash, version 3.2.57(2)-release (i686-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

[admin@storage test]# type [[
[[ is a shell keyword

[admin@storage test]# for i in *; do [[ -h $i ]] && echo $i; done
link

find -printf behaviour for %y


The second problem is that %y behaves differently depending upon whether or not %Y is also used.

[admin@storage test]# find . -type f -printf "%y %Y " -ls
f f       450      0 -rw-rw-rw-   1  admin    administrators        0 Sep 17 07:43 ./file
l f    206257      4 lr--r--r--   1  admin    administrators       18 Sep 17 07:43 ./link -> file

[admin@storage test]# find . -type f -printf "  %Y " -ls
  f       450      0 -rw-rw-rw-   1  admin    administrators        0 Sep 17 07:43 ./file
  f    206257      4 lr--r--r--   1  admin    administrators       18 Sep 17 07:43 ./link -> file

[admin@storage test]# find . -type f -printf "%y   " -ls
f         450      0 -rw-rw-rw-   1  admin    administrators        0 Sep 17 07:43 ./file
f      206257      4 lr--r--r--   1  admin    administrators       18 Sep 17 07:43 ./link -> file

Both work correctly on the same system on ext4 filesystems.

Aaron Queenan <aqueenan>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jay (Posted a comment)
  • -email is unavailable- added by tavianator (Posted a comment)
  • -email is unavailable- added by aqueenan (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-23 jay StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code