libfuse / sshfs

A network filesystem client to connect to SSH servers
GNU General Public License v2.0
6.04k stars 496 forks source link

rewinddir() does not work as expected #278

Open el-bart opened 2 years ago

el-bart commented 2 years ago

sshfs-fuse version 3.7.1 (i.e. latest in Debian Bullseye - aka: stable). the problem is with rewinddir() call, that does not seem to work. example test program:

#include <sys/types.h>
#include <dirent.h>
#include <iostream>

int main(int argc, char** argv)
{
  if(argc!=1+1)
  {
    std::cerr << argv[0] << " </path/to/dir>" << std::endl;
    return 2;
  }

  auto d = opendir(argv[1]);

  std::cout << "#1:" << std::endl;
  while( auto e = readdir(d) )
    std::cout << " >> " << e->d_name << std::endl;

  std::cout << std::endl << "### rewinding" << std::endl << std::endl;
  rewinddir(d);

  std::cout << "#2:" << std::endl;
  while( auto e = readdir(d) )
    std::cout << " >> " << e->d_name << std::endl;
}

output on "regular" directory is (as expected):

#1:
 >> .
 >> ..
 >> some_dir_1
 >> some_dir_2
 >> some_file

### rewinding

#2:
 >> .
 >> ..
 >> some_dir_1
 >> some_dir_2
 >> some_file

actual output on sshfs-mounted directory is:

#1:
 >> .
 >> ..
 >> some_dir_1
 >> some_dir_2
 >> some_file

### rewinding

#2:

it looks like rewinddir() does not have any affect on sshfs.

el-bart commented 2 years ago

note that this issue is what makes sshfs mounts unusable under mc (see https://midnight-commander.org/ticket/4289).

Nikratio commented 2 years ago

Yep, that's a known problem. Patches welcome :-).

There is some more information in #211, but I'm keeping this one open because it's more concise.