Skip to content

Commit

Permalink
Improve FreeBSD support:
Browse files Browse the repository at this point in the history
- include posix_openpt() usage patch
- add workaround for readdir() issue: #211, #278
- fix few warnings
  • Loading branch information
rozhuk-im committed Jun 11, 2022
1 parent c91eb9a commit a73501f
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <netdb.h>
#include <signal.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down

0 comments on commit a73501f

Please sign in to comment.