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

DANGER: Initial stab at getting things working with fuse3 instead of fuse2. #182

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Also requires
[CMake](https://cmake.org/) build system.

On Ubuntu you can run the following command:
> sudo apt-get install cmake zlib1g-dev libboost-system-dev libboost-program-options-dev libpthread-stubs0-dev libfuse-dev libudev-dev
> sudo apt-get install cmake zlib1g-dev libboost-system-dev libboost-program-options-dev libpthread-stubs0-dev libfuse3-dev libudev-dev

## Build steps

> sudo apt-get install cmake zlib1g-dev libboost-system-dev libboost-program-options-dev libpthread-stubs0-dev libfuse-dev libudev-dev fuse build-essential git
> mkdir console-client
>
> git clone https://github.com/pcloudcom/console-client.git ./console-client/
> cd ./console-client/pCloudCC/
> cd lib/pclsync/
Expand Down
6 changes: 3 additions & 3 deletions pCloudCC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.22)
project(pcloudcc)

#INCLUDE(CPack)

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
unset(Boost_INCLUDE_DIR CACHE)
unset(Boost_LIBRARY_DIRS CACHE)
Expand Down Expand Up @@ -54,7 +54,7 @@ target_link_libraries(sqlite3 z dl)

add_library(pcloudcc_lib SHARED pclsync_lib_c.cpp pclsync_lib.cpp control_tools.cpp ${OVERLAY_CLENT_PATH}/overlay_client.c ${OVERLAY_CLENT_PATH}/debug.c )

target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/psynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse pthread sqlite3 udev
target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/psynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse3 pthread sqlite3 udev
)

add_executable(pcloudcc main.cpp)
Expand Down
2 changes: 1 addition & 1 deletion pCloudCC/lib/pclsync/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ debugfs: fs

cli: fs
$(CC) $(CFLAGS) -o cli cli.c $(LIB_A) $(LDFLAGS)

overlay_client:
cd ./lib/poverlay_linux && make

Expand Down
36 changes: 13 additions & 23 deletions pCloudCC/lib/pclsync/pfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#define FUSE_USE_VERSION 26
#define FUSE_USE_VERSION 31
#define _FILE_OFFSET_BITS 64

#include <stdlib.h>
#include <pthread.h>
#include <fuse.h>
#include <fuse3/fuse.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
Expand Down Expand Up @@ -108,7 +108,6 @@ typedef off_t fuse_off_t;
#define PSYNC_FS_ERR_MOVE_ACROSS_CRYPTO EXDEV
#endif

static struct fuse_chan *psync_fuse_channel=NULL;
static struct fuse *psync_fuse=NULL;
static char *psync_current_mountpoint=NULL;
static psync_generic_callback_t psync_start_callback=NULL;
Expand Down Expand Up @@ -818,12 +817,12 @@ static int filler_decoded(psync_crypto_aes256_text_decoder_t dec, fuse_fill_dir_
namedec=psync_cloud_crypto_decode_filename(dec, name);
if (!namedec)
return 0;
ret=filler(buf, namedec, st, off);
ret=filler(buf, namedec, st, off, FUSE_FILL_DIR_PLUS);
psync_free(namedec);
return ret;
}
else
return filler(buf, name, st, off);
return filler(buf, name, st, off, FUSE_FILL_DIR_PLUS);
}

static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, fuse_off_t offset, struct fuse_file_info *fi){
Expand Down Expand Up @@ -858,9 +857,9 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
}
else
dec=NULL;
filler(buf, ".", NULL, 0);
filler(buf, ".", NULL, 0, FUSE_FILL_DIR_PLUS);
if (folderid!=0)
filler(buf, "..", NULL, 0);
filler(buf, "..", NULL, 0, FUSE_FILL_DIR_PLUS);
folder=psync_fstask_get_folder_tasks_rdlocked(folderid);
if (folderid>=0){
res=psync_sql_query_nolock("SELECT id, permissions, ctime, mtime, subdircnt, name FROM folder WHERE parentfolderid=?");
Expand Down Expand Up @@ -3267,9 +3266,7 @@ static void psync_fs_do_stop(void){
#endif

#if defined(P_OS_LINUX)
char *mp;
mp = psync_fuse_get_mountpoint();
fuse_unmount(mp, psync_fuse_channel);
fuse_unmount(psync_fuse);
#endif

debug(D_NOTICE, "running fuse_exit");
Expand Down Expand Up @@ -3365,7 +3362,7 @@ static void psync_fuse_thread(){
}
pthread_mutex_unlock(&start_mutex);
debug(D_NOTICE, "running fuse_loop_mt");
fr=fuse_loop_mt(psync_fuse);
fr=fuse_loop_mt(psync_fuse,0);
debug(D_NOTICE, "fuse_loop_mt exited with code %d, running fuse_destroy", fr);
pthread_mutex_lock(&start_mutex);
fuse_destroy(psync_fuse);
Expand Down Expand Up @@ -3408,19 +3405,18 @@ static int psync_fs_do_start(){
char *mp;
struct fuse_operations psync_oper;
struct fuse_args args=FUSE_ARGS_INIT(0, NULL);

// it seems that fuse option parser ignores the first argument
// it is ignored as it's like in the exec() parameters, argv[0] is the program

#if defined(P_OS_LINUX)
fuse_opt_add_arg(&args, "argv");
fuse_opt_add_arg(&args, "-oauto_unmount");
// fuse_opt_add_arg(&args, "-oauto_unmount");
// fuse_opt_add_arg(&args, "-ouse_ino");
fuse_opt_add_arg(&args, "-ofsname="DEFAULT_FUSE_MOUNT_POINT".fs");
if (!is_fuse3_installed_on_system()) {
fuse_opt_add_arg(&args, "-ononempty");
}
fuse_opt_add_arg(&args, "-ohard_remove");
// fuse_opt_add_arg(&args, "-ohard_remove");
// fuse_opt_add_arg(&args, "-d");
#endif

Expand Down Expand Up @@ -3456,7 +3452,7 @@ static int psync_fs_do_start(){
psync_oper.chmod = psync_fs_chmod;
psync_oper.chown = psync_fs_chown;
psync_oper.utimens = psync_fs_utimens;
psync_oper.ftruncate= psync_fs_ftruncate;
// psync_oper.ftruncate= psync_fs_ftruncate;
psync_oper.truncate = psync_fs_truncate;

psync_oper.setxattr = psync_fs_setxattr;
Expand Down Expand Up @@ -3485,23 +3481,17 @@ static int psync_fs_do_start(){
#if defined(P_OS_MACOSX)
unmount(mp, MNT_FORCE);
#endif

psync_fuse_channel=fuse_mount(mp, &args);
if (unlikely_log(!psync_fuse_channel))
goto err0;
psync_fuse=fuse_new(psync_fuse_channel, &args, &psync_oper, sizeof(psync_oper), NULL);
psync_fuse=fuse_new(&args, &psync_oper, sizeof(psync_oper), NULL);
if (unlikely_log(!psync_fuse))
goto err1;
fuse_mount(psync_fuse,mp);
psync_current_mountpoint=mp;
started=1;
pthread_mutex_unlock(&start_mutex);
fuse_opt_free_args(&args);
psync_run_thread("fuse", psync_fuse_thread);
return 0;
err1:
fuse_unmount(mp, psync_fuse_channel);
err0:
psync_free(mp);
err00:
pthread_mutex_unlock(&start_mutex);
fuse_opt_free_args(&args);
Expand Down
4 changes: 2 additions & 2 deletions pCloudCC/lib/pclsync/pfsxattr.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#define FUSE_USE_VERSION 26
#define FUSE_USE_VERSION 31
#define _FILE_OFFSET_BITS 64

#include "pfsxattr.h"
#include "plibs.h"
#include "pfsfolder.h"
#include "pfstasks.h"
#include <fuse.h>
#include <fuse3/fuse.h>
#include <errno.h>
#include <string.h>

Expand Down