3232#include <netdb.h>
3333#include <signal.h>
3434#include <sys/uio.h>
35+ #include <sys/param.h>
3536#include <sys/types.h>
3637#include <sys/time.h>
3738#include <sys/wait.h>
@@ -602,6 +603,9 @@ static const char *type_name(uint8_t type)
602603#define list_entry (ptr , type , member ) \
603604 container_of(ptr, type, member)
604605
606+ static int sshfs_releasedir (const char * path , struct fuse_file_info * fi );
607+
608+
605609static void list_init (struct list_head * head )
606610{
607611 head -> next = head ;
@@ -1108,7 +1112,11 @@ static int pty_master(char **name)
11081112{
11091113 int mfd ;
11101114
1115+ #ifdef __FreeBSD__
1116+ mfd = posix_openpt (O_RDWR | O_NOCTTY );
1117+ #else
11111118 mfd = open ("/dev/ptmx" , O_RDWR | O_NOCTTY );
1119+ #endif
11121120 if (mfd == -1 ) {
11131121 perror ("failed to open pty" );
11141122 return -1 ;
@@ -1891,12 +1899,8 @@ static void *sshfs_init(struct fuse_conn_info *conn,
18911899 if (conn -> capable & FUSE_CAP_ASYNC_READ )
18921900 sshfs .sync_read = 1 ;
18931901
1894- // These workarounds require the "path" argument.
1895- cfg -> nullpath_ok = !(sshfs .truncate_workaround || sshfs .fstat_workaround );
1896-
1897- // When using multiple connections, release() needs to know the path
1898- if (sshfs .max_conns > 1 )
1899- cfg -> nullpath_ok = 0 ;
1902+ /* Allways require the "path" argument. */
1903+ cfg -> nullpath_ok = 0 ;
19001904
19011905 // Lookup of . and .. is supported
19021906 conn -> capable |= FUSE_CAP_EXPORT_SUPPORT ;
@@ -2200,6 +2204,7 @@ static int sshfs_req_pending(struct request *req)
22002204static int sftp_readdir_async (struct conn * conn , struct buffer * handle ,
22012205 void * buf , off_t offset , fuse_fill_dir_t filler )
22022206{
2207+ (void ) offset ;
22032208 int err = 0 ;
22042209 int outstanding = 0 ;
22052210 int max = READDIR_START ;
@@ -2278,6 +2283,7 @@ static int sftp_readdir_async(struct conn *conn, struct buffer *handle,
22782283static int sftp_readdir_sync (struct conn * conn , struct buffer * handle ,
22792284 void * buf , off_t offset , fuse_fill_dir_t filler )
22802285{
2286+ (void ) offset ;
22812287 int err ;
22822288 assert (offset == 0 );
22832289 do {
@@ -2327,10 +2333,17 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler,
23272333 off_t offset , struct fuse_file_info * fi ,
23282334 enum fuse_readdir_flags flags )
23292335{
2330- (void ) path ; ( void ) flags ;
2336+ (void ) flags ;
23312337 int err ;
23322338 struct dir_handle * handle ;
23332339
2340+ if (path == NULL )
2341+ return - EIO ;
2342+ err = sshfs_opendir (path , fi );
2343+ if (err )
2344+ return err ;
2345+ offset = 0 ;
2346+
23342347 handle = (struct dir_handle * ) fi -> fh ;
23352348
23362349 if (sshfs .sync_readdir )
@@ -2340,6 +2353,8 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler,
23402353 err = sftp_readdir_async (handle -> conn , & handle -> buf , dbuf ,
23412354 offset , filler );
23422355
2356+ sshfs_releasedir (path , fi );
2357+
23432358 return err ;
23442359}
23452360
@@ -3625,6 +3640,7 @@ static void usage(const char *progname)
36253640" [no]buflimit fix buffer fillup bug in server (default: off)\n"
36263641" [no]fstat always use stat() instead of fstat() (default: off)\n"
36273642" [no]createmode always pass mode 0 to create (default: off)\n"
3643+ " [no]readdir always open/read/close dir on readdir (default: on)\n"
36283644" -o idmap=TYPE user/group ID mapping (default: " IDMAP_DEFAULT ")\n"
36293645" none no translation of the ID space\n"
36303646" user only translate UID/GID of connecting user\n"
0 commit comments