32
32
#include <netdb.h>
33
33
#include <signal.h>
34
34
#include <sys/uio.h>
35
+ #include <sys/param.h>
35
36
#include <sys/types.h>
36
37
#include <sys/time.h>
37
38
#include <sys/wait.h>
@@ -602,6 +603,9 @@ static const char *type_name(uint8_t type)
602
603
#define list_entry (ptr , type , member ) \
603
604
container_of(ptr, type, member)
604
605
606
+ static int sshfs_releasedir (const char * path , struct fuse_file_info * fi );
607
+
608
+
605
609
static void list_init (struct list_head * head )
606
610
{
607
611
head -> next = head ;
@@ -1108,7 +1112,11 @@ static int pty_master(char **name)
1108
1112
{
1109
1113
int mfd ;
1110
1114
1115
+ #ifdef __FreeBSD__
1116
+ mfd = posix_openpt (O_RDWR | O_NOCTTY );
1117
+ #else
1111
1118
mfd = open ("/dev/ptmx" , O_RDWR | O_NOCTTY );
1119
+ #endif
1112
1120
if (mfd == -1 ) {
1113
1121
perror ("failed to open pty" );
1114
1122
return -1 ;
@@ -1891,12 +1899,8 @@ static void *sshfs_init(struct fuse_conn_info *conn,
1891
1899
if (conn -> capable & FUSE_CAP_ASYNC_READ )
1892
1900
sshfs .sync_read = 1 ;
1893
1901
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 ;
1900
1904
1901
1905
// Lookup of . and .. is supported
1902
1906
conn -> capable |= FUSE_CAP_EXPORT_SUPPORT ;
@@ -2200,6 +2204,7 @@ static int sshfs_req_pending(struct request *req)
2200
2204
static int sftp_readdir_async (struct conn * conn , struct buffer * handle ,
2201
2205
void * buf , off_t offset , fuse_fill_dir_t filler )
2202
2206
{
2207
+ (void ) offset ;
2203
2208
int err = 0 ;
2204
2209
int outstanding = 0 ;
2205
2210
int max = READDIR_START ;
@@ -2278,6 +2283,7 @@ static int sftp_readdir_async(struct conn *conn, struct buffer *handle,
2278
2283
static int sftp_readdir_sync (struct conn * conn , struct buffer * handle ,
2279
2284
void * buf , off_t offset , fuse_fill_dir_t filler )
2280
2285
{
2286
+ (void ) offset ;
2281
2287
int err ;
2282
2288
assert (offset == 0 );
2283
2289
do {
@@ -2327,10 +2333,17 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler,
2327
2333
off_t offset , struct fuse_file_info * fi ,
2328
2334
enum fuse_readdir_flags flags )
2329
2335
{
2330
- (void ) path ; ( void ) flags ;
2336
+ (void ) flags ;
2331
2337
int err ;
2332
2338
struct dir_handle * handle ;
2333
2339
2340
+ if (path == NULL )
2341
+ return - EIO ;
2342
+ err = sshfs_opendir (path , fi );
2343
+ if (err )
2344
+ return err ;
2345
+ offset = 0 ;
2346
+
2334
2347
handle = (struct dir_handle * ) fi -> fh ;
2335
2348
2336
2349
if (sshfs .sync_readdir )
@@ -2340,6 +2353,8 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler,
2340
2353
err = sftp_readdir_async (handle -> conn , & handle -> buf , dbuf ,
2341
2354
offset , filler );
2342
2355
2356
+ sshfs_releasedir (path , fi );
2357
+
2343
2358
return err ;
2344
2359
}
2345
2360
@@ -3625,6 +3640,7 @@ static void usage(const char *progname)
3625
3640
" [no]buflimit fix buffer fillup bug in server (default: off)\n"
3626
3641
" [no]fstat always use stat() instead of fstat() (default: off)\n"
3627
3642
" [no]createmode always pass mode 0 to create (default: off)\n"
3643
+ " [no]readdir always open/read/close dir on readdir (default: on)\n"
3628
3644
" -o idmap=TYPE user/group ID mapping (default: " IDMAP_DEFAULT ")\n"
3629
3645
" none no translation of the ID space\n"
3630
3646
" user only translate UID/GID of connecting user\n"
0 commit comments