Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve FreeBSD support: #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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