bugfindutils - Bugs: bug #58458, Using -L option and -samefile test...

 
 

bug #58458: Using -L option and -samefile test will match both hard links and symbolic links, but the manual is incorrect

Submitter:  David <comppreper>
Submitted:  Thu 28 May 2020 06:17:46 AM UTC
   
 
Category:  documentation Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  berny
Originator Name:  Open/Closed:  Closed
Release:  4.7.0 Fixed Release:  4.8.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 21 Jun 2020 05:49:26 PM UTC, comment #4: 

True, there is no point to talk about "first" or "second" at all.

I changed it like this:

-Directories normally have at least two hard
-links; their @file{.} entry is the second one.  If they have
-subdirectories, each of those also has a hard link called @file{..} to
-its parent directory.
+A directory normally has at least two hard links: the entry named in its parent
+directory, and the @file{.} entry inside of the directory.
+If a directory has subdirectories, each of those also has a hard link called
+@file{..} to its parent directory.


Pushed at:
  https://git.sv.gnu.org/cgit/findutils.git/commit/?id=7c72d72838

Thanks for the report and the review.

Bernhard Voelker <berny>
Group administrator
Fri 19 Jun 2020 04:40:20 AM UTC, comment #3: 

I refer to patch file #49281:

Line 135: +Directories normally have at least two hard
Line 136:  links; their @file{.} entry is the second one.  If they have

It sounds a little odd to me to describe the "." directory entry as the "second one", without first saying anything about the first one.

Other than that, I think that the amendments sound good. Thanks for the work.

David <comppreper>
Tue 16 Jun 2020 09:54:32 PM UTC, comment #2: 

Proposed documentation patch attached (finally).
Please check.

(file #49281)

Bernhard Voelker <berny>
Group administrator
Fri 29 May 2020 04:41:57 PM UTC, comment #1: 

Thanks for the detailed report and the suggestion.

In my opinion, the whole "Hard links" node could read a bit better
regarding the style: it describes more what "you could" do instead
of how find processes the -samefile option.

Thus, I'm not 100% happy with the suggested change - still I'm
grateful that we have it as basis for discussion (which is very
valuable). Thanks again for that.
I'll try to come up with something else, and then we can discuss
what reads best for the user.

Bernhard Voelker <berny>
Group administrator
Thu 28 May 2020 06:17:46 AM UTC, original submission:  

The second paragraph under section 2.2.2 Hard Links states as follows:

If the ‘-L’ option is in effect, and name is in fact a symbolic link, the symbolic link will be dereferenced. Hence you are searching for other links (hard or symbolic) to the file pointed to by name. If ‘-L’ is in effect but name is not itself a symbolic link, other symbolic links to the file name will be matched.

The above paragraph is not entirely correct and is likely to mislead the reader. If name (ie the filename provided to the -samefile test) refers to a file that has both hard links and symbolic links, then the ‘-L' option will cause both hard links and symbolic links to be matched, even if name does not refer to a symbolic link. Therefore, it is not correct to suggest that only symbolic links will be matched. Unfortunately, when read in context, the last sentence of the above paragraph suggests that only symbolic links will be matched.

In fact, to be clear, the ‘-L’ option will always match both hard links and symbolic links irrespective of whether name refers to a hard link or symbolic link. Of course, if a file has only one name (ie other names have not been hard-linked to the file), then the ‘-L’ option will only ever find the file itself (if it is within the search scope) and other symbolic links (if any) within the search scope.

For example:


touch ./original-file.txt
link ./original-file.txt hardlink.txt
ln -s ./original-file.txt symlink-original.txt
ln -s ./hardlink.txt symlink-hardlink.txt
ln -s ./symlink-original.txt symlink-symlink.txt
ln -P ./symlink-original.txt hardlink-symlink.txt
find -L -samefile ./original-file.txt
./original-file.txt
./hardlink.txt
./symlink-original.txt
./symlink-hardlink.txt
./symlink-symlink.txt
./hardlink-symlink.txt
find --version
find (GNU findutils) 4.7.0
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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)


In view of the above, I suggest changing the second paragraph under section 2.2.2 Hard Links to read as follows:

If the ‘-L’ option is in effect, then any symbolic link will be dereferenced (this is the case for both the file name and the name). Hence, you will be searching for both hard links and symbolic links to the file pointed to by name.

David <comppreper>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49281:  0001-doc-improve-section-Hard-links-and-fix-find-L-samefi.patch added by berny (6KiB - text/x-patch - [PATCH] doc: improve section 'Hard links' and fix 'find -L -samefile' description)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by berny (Posted a comment)
  • -email is unavailable- added by comppreper (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-09 berny Open/ClosedOpen Closed
        Fixed ReleaseNone 4.8.0
    2020-06-21 berny StatusCode Review Fixed
    2020-06-16 berny Attached File- Added 0001-doc-improve-section-Hard-links-and-fix-find-L-samefi.patch, #49281
        StatusNone Code Review
    2020-05-29 berny Assigned toNone berny

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code