diff --git a/sshfs.c b/sshfs.c index 5513266d..b4b5620b 100644 --- a/sshfs.c +++ b/sshfs.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -602,6 +603,9 @@ static const char *type_name(uint8_t type) #define list_entry(ptr, type, member) \ container_of(ptr, type, member) +static int sshfs_releasedir(const char *path, struct fuse_file_info *fi); + + static void list_init(struct list_head *head) { head->next = head; @@ -1108,7 +1112,11 @@ static int pty_master(char **name) { int mfd; +#ifdef __FreeBSD__ + mfd = posix_openpt(O_RDWR | O_NOCTTY); +#else mfd = open("/dev/ptmx", O_RDWR | O_NOCTTY); +#endif if (mfd == -1) { perror("failed to open pty"); return -1; @@ -1891,12 +1899,8 @@ static void *sshfs_init(struct fuse_conn_info *conn, if (conn->capable & FUSE_CAP_ASYNC_READ) sshfs.sync_read = 1; - // These workarounds require the "path" argument. - cfg->nullpath_ok = !(sshfs.truncate_workaround || sshfs.fstat_workaround); - - // When using multiple connections, release() needs to know the path - if (sshfs.max_conns > 1) - cfg->nullpath_ok = 0; + /* Allways require the "path" argument. */ + cfg->nullpath_ok = 0; // Lookup of . and .. is supported conn->capable |= FUSE_CAP_EXPORT_SUPPORT; @@ -2200,6 +2204,7 @@ static int sshfs_req_pending(struct request *req) static int sftp_readdir_async(struct conn *conn, struct buffer *handle, void *buf, off_t offset, fuse_fill_dir_t filler) { + (void) offset; int err = 0; int outstanding = 0; int max = READDIR_START; @@ -2278,6 +2283,7 @@ static int sftp_readdir_async(struct conn *conn, struct buffer *handle, static int sftp_readdir_sync(struct conn *conn, struct buffer *handle, void *buf, off_t offset, fuse_fill_dir_t filler) { + (void) offset; int err; assert(offset == 0); do { @@ -2327,10 +2333,17 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags) { - (void) path; (void) flags; + (void) flags; int err; struct dir_handle *handle; + if (path == NULL) + return -EIO; + err = sshfs_opendir(path, fi); + if (err) + return err; + offset = 0; + handle = (struct dir_handle*) fi->fh; if (sshfs.sync_readdir) @@ -2340,6 +2353,8 @@ static int sshfs_readdir(const char *path, void *dbuf, fuse_fill_dir_t filler, err = sftp_readdir_async(handle->conn, &handle->buf, dbuf, offset, filler); + sshfs_releasedir(path, fi); + return err; } @@ -3625,6 +3640,7 @@ static void usage(const char *progname) " [no]buflimit fix buffer fillup bug in server (default: off)\n" " [no]fstat always use stat() instead of fstat() (default: off)\n" " [no]createmode always pass mode 0 to create (default: off)\n" +" [no]readdir always open/read/close dir on readdir (default: on)\n" " -o idmap=TYPE user/group ID mapping (default: " IDMAP_DEFAULT ")\n" " none no translation of the ID space\n" " user only translate UID/GID of connecting user\n"