Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directories not walked recursively in FUSE mounted directories #3832

Closed
5 of 10 tasks
jpalus opened this issue Jun 1, 2024 · 3 comments · Fixed by #3878
Closed
5 of 10 tasks

Directories not walked recursively in FUSE mounted directories #3832

jpalus opened this issue Jun 1, 2024 · 3 comments · Fixed by #3878

Comments

@jpalus
Copy link
Contributor

jpalus commented Jun 1, 2024

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.52.1 (6432f00)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

  1. Create test directories and files:
$ mkdir -p test/test mnt
$ touch test/test/test{1,2,3,4,5} test/test6
  1. Enter test and try to complete files:
$ cd test
$ stat **<TAB>
  1. As expected it shows all files and dirs:
$ stat **
>
  7/7 (0) ───────────
> test6
  test
  test/test5
  test/test2
  test/test1
  test/test3
  test/test4 
  1. Mount test to mnt over ssh
$ cd ..
$ sshfs localhost:test mnt
  1. Enter mnt and try to complete files:
$ cd mnt
$ stat **<TAB>

Expected result: same as for local filesystem
Actual result: only top level items are listed

$ stat **
>
  2/2 (0) ───────────
> test
  test6 

Now the really weird thing is that for some commands it works fine in both cases ls **<TAB> or cat **<TAB>, but not in others vim **<TAB> or mpv **<TAB.

@junegunn
Copy link
Owner

junegunn commented Jun 2, 2024

Do you have any custom configuration?

env | grep FZF_

print -l ${(ok)functions} | grep _fzf_compgen

jpalus added a commit to jpalus/sshfs that referenced this issue Jun 17, 2024
Uncached and cached results for readdir were inconsistent -- the former
returned correct stat info for directory entries while the latter
didn't. That's because only names of entries were saved in cache without
stat info. In turn this leads to issues like
junegunn/fzf#3832 since directory traversal
library (https://github.com/charlievieth/fastwalk in this case) relies
on proper stat info returned by readdir. Hence when unchached result was
returned it gave proper outcome, while with cached result it was wrong.

Cache stat info next to entry name to fix the issue. While file
attributes are saved in cache already, they use full path as key. To
avoid potentially plenty of allocations, string copying and cache
lookups to get each attr, let's keep a copy of stat struct independently
to be on the fast path.
@jpalus
Copy link
Contributor Author

jpalus commented Jun 17, 2024

Turns out it's an issue caused by caching mechanism in sshfssee libfuse/sshfs#306 for details.

It started to affect fzf with switch to new fastwalk based walker. It relies on proper d_type returned by getdents syscall (translated to readdir in FUSE). If the type is unexpected bogus one is returned which later fails to meet criteria for recursive walk.

On the other hand previous find based walker, which uses fts_read internally, will call stat for each file with unknown type (DT_UNKNOWN) resulting in recursive walk.

@jpalus
Copy link
Contributor Author

jpalus commented Jun 17, 2024

Also submitted charlievieth/fastwalk#18 to match find's behavior cause ie gvfs FUSE mount does not populate stat in readdir at all.

jpalus added a commit to jpalus/fzf that referenced this issue Jun 18, 2024
junegunn pushed a commit that referenced this issue Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants