Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"steps": [
{
"name": "Install build dependancies",
"run": "apt-get -y update\napt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install build-essential expect pkg-config fuse libfuse-dev git time p7zip-full\n"
"run": "apt-get -y update\napt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install build-essential expect pkg-config fuse3 libfuse3-dev git time p7zip-full\n"
},
{
"uses": "actions/checkout@v3",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Commands marked with DESTRUCTIVE could potentially wipe or remove important info

`pfsfuse` provides an ability to mount partition into host filesystem (like network folder).
`pfsfuse` supports physically connected drives, raw drive images as regular files, and an NBD network server from OPL.
Your system has to support fuse. For example, in the Linux `fuse` package should be installed, on the MacOS `macfuse` can be used.
Your system has to support fuse. For example, on Linux the `fuse3` package is recommended (with `fuse` as a fallback on older systems), while on macOS `macfuse` can be used.
The Unix users can use the following command for mounting the partition:

```sh
Expand Down
11 changes: 10 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-
libfuse_include = include_directories(['external/dokany/dokan_fuse/include'])
libfuse_dep = cc.find_library('libdokanfuse2.dll',
dirs : [meson.current_source_dir() +'/external/dokany/dokan_fuse/build'])
use_fuse3 = false
else
libfuse_include = ['']
libfuse_dep = dependency('fuse')
use_fuse3 = true
libfuse_dep = dependency('fuse3', required: false)
if not libfuse_dep.found()
use_fuse3 = false
libfuse_dep = dependency('fuse')
endif
endif

pfsfuse_src = [
Expand All @@ -71,6 +77,9 @@ pfsfuse_cflags = []
if host_system == 'linux'
pfsfuse_cflags += ['-pthread']
endif
if use_fuse3
pfsfuse_cflags += ['-DPFSFUSE_USE_FUSE3']
endif
pfsfuse_cflags += ['-D_FILE_OFFSET_BITS=64']
pfsfuse_ldflags = []
if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
Expand Down
80 changes: 72 additions & 8 deletions src/iomanx_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
#define pfsfuse_stat stat
#endif

#ifdef PFSFUSE_USE_FUSE3
#define FUSE_USE_VERSION 30
#include <fuse3/fuse.h>
#else
#define FUSE_USE_VERSION 26
#include <fuse.h>
#endif

#include "iomanX_port.h"

Expand Down Expand Up @@ -297,9 +302,17 @@ static void convert_stat_to_iomanx(iox_stat_t *iomanx_stat, const struct pfsfuse
#endif
}

static void *iomanx_adapter_init(struct fuse_conn_info *conn)
static void *iomanx_adapter_init(struct fuse_conn_info *conn
#if FUSE_USE_VERSION >= 30
,
struct fuse_config *cfg
#endif
)
{
(void)conn;
#if FUSE_USE_VERSION >= 30
(void)cfg;
#endif
return NULL;
}

Expand Down Expand Up @@ -530,14 +543,22 @@ static int iomanx_adapter_rmdir(const char *path)
}

static int iomanx_adapter_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
off_t offset, struct fuse_file_info *fi
#if FUSE_USE_VERSION >= 30
,
enum fuse_readdir_flags flags
#endif
)
{
int dp;
int res = 0;
iox_dirent_t de;

(void)offset;
(void)fi;
#if FUSE_USE_VERSION >= 30
(void)flags;
#endif

char translated_path[1024];
translate_path(translated_path, path, sizeof(translated_path));
Expand All @@ -550,7 +571,13 @@ static int iomanx_adapter_readdir(const char *path, void *buf, fuse_fill_dir_t f
while ((res = iomanX_dread(dp, &de)) && (res != -1)) {
struct pfsfuse_stat st;
convert_stat_to_posix(&st, &(de.stat));
if (filler(buf, de.name, &st, 0))
if (filler(buf, de.name, &st, 0
#if FUSE_USE_VERSION >= 30
/* fuse_fill_dir_flags */
,
0
#endif
))
break;
}

Expand All @@ -559,10 +586,18 @@ static int iomanx_adapter_readdir(const char *path, void *buf, fuse_fill_dir_t f
}


static int iomanx_adapter_getattr(const char *path, struct pfsfuse_stat *stbuf)
static int iomanx_adapter_getattr(const char *path, struct pfsfuse_stat *stbuf
#if FUSE_USE_VERSION >= 30
,
struct fuse_file_info *fi
#endif
)
{
int res;
iox_stat_t iomanx_stat;
#if FUSE_USE_VERSION >= 30
(void)fi;
#endif

char translated_path[1024];
translate_path(translated_path, path, sizeof(translated_path));
Expand All @@ -589,11 +624,19 @@ static int iomanx_adapter_ftruncate(const char *path, off_t offset,
return 0;
}

static int iomanx_adapter_chmod(const char *path, mode_t mode)
static int iomanx_adapter_chmod(const char *path, mode_t mode
#if FUSE_USE_VERSION >= 30
,
struct fuse_file_info *fi
#endif
)
{
int res;
iox_stat_t iomanx_stat;
struct pfsfuse_stat posix_stat;
#if FUSE_USE_VERSION >= 30
(void)fi;
#endif
posix_stat.st_mode = mode;
convert_stat_to_iomanx(&iomanx_stat, &posix_stat);

Expand All @@ -608,10 +651,18 @@ static int iomanx_adapter_chmod(const char *path, mode_t mode)
return 0;
}

static int iomanx_adapter_utimens(const char *path, const struct timespec ts[2])
static int iomanx_adapter_utimens(const char *path, const struct timespec ts[2]
#if FUSE_USE_VERSION >= 30
,
struct fuse_file_info *fi
#endif
)
{
int res;
iox_stat_t iomanx_stat;
#if FUSE_USE_VERSION >= 30
(void)fi;
#endif
convert_time_to_iomanx(iomanx_stat.atime, &(ts[0].tv_sec));
convert_time_to_iomanx(iomanx_stat.mtime, &(ts[1].tv_sec));

Expand All @@ -626,9 +677,19 @@ static int iomanx_adapter_utimens(const char *path, const struct timespec ts[2])
return 0;
}

static int iomanx_adapter_rename(const char *from, const char *to)
static int iomanx_adapter_rename(const char *from, const char *to
#if FUSE_USE_VERSION >= 30
,
unsigned int flags
#endif
)
{
int res;
#if FUSE_USE_VERSION >= 30
if (flags != 0) {
return -EINVAL;
}
#endif

char translated_from[1024];
translate_path(translated_from, from, sizeof(translated_from));
Expand Down Expand Up @@ -690,8 +751,11 @@ static const struct fuse_operations iomanx_adapter_operations = {
// link
.chmod = iomanx_adapter_chmod,
// chown
// ftruncate renamed to truncate into later libfuse
#if FUSE_USE_VERSION >= 30
.truncate = iomanx_adapter_ftruncate,
#else
.ftruncate = iomanx_adapter_ftruncate,
#endif
.open = iomanx_adapter_open,
.read = iomanx_adapter_read,
.write = iomanx_adapter_write,
Expand Down
Loading