From 8ba5a6c0eac5de008d5c1799a86f6b6437252364 Mon Sep 17 00:00:00 2001 From: James Miller Date: Sat, 8 Apr 2023 15:23:53 -0700 Subject: [PATCH 1/5] Initial stab at getting things working with fuse3 instead of fuse2. Caveats: My knowlege of C would best be described as "Basic" My prior fuse development experince would best be described as "None" I made no effort to keep things working for systems that still use fuse2, like older linux distros and I assume MacOS I do not have a proper suite of tests. I added files, made sure I could see them and then deleted them. Testing has be MINIMAL. Keep that in mind before using my code to mess with data you care about. That being said, these changes allowed me to compile pcloudcc on an amd64 install of gentoo linux. Basic operations work as far as I can tell. --- pCloudCC/CMakeLists.txt | 6 +++--- pCloudCC/lib/pclsync/Makefile | 2 +- pCloudCC/lib/pclsync/pfs.c | 36 ++++++++++++--------------------- pCloudCC/lib/pclsync/pfsxattr.c | 4 ++-- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/pCloudCC/CMakeLists.txt b/pCloudCC/CMakeLists.txt index bfe3a6bd..b28ba9a3 100644 --- a/pCloudCC/CMakeLists.txt +++ b/pCloudCC/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.25) 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) @@ -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) diff --git a/pCloudCC/lib/pclsync/Makefile b/pCloudCC/lib/pclsync/Makefile index ffb86385..4b3195cc 100644 --- a/pCloudCC/lib/pclsync/Makefile +++ b/pCloudCC/lib/pclsync/Makefile @@ -83,7 +83,7 @@ debugfs: fs cli: fs $(CC) $(CFLAGS) -o cli cli.c $(LIB_A) $(LDFLAGS) - + overlay_client: cd ./lib/poverlay_linux && make diff --git a/pCloudCC/lib/pclsync/pfs.c b/pCloudCC/lib/pclsync/pfs.c index 165c0856..acaff8d7 100644 --- a/pCloudCC/lib/pclsync/pfs.c +++ b/pCloudCC/lib/pclsync/pfs.c @@ -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 #include -#include +#include #include #include #include @@ -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; @@ -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){ @@ -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=?"); @@ -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"); @@ -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); @@ -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 @@ -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; @@ -3485,13 +3481,10 @@ 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); @@ -3499,9 +3492,6 @@ static int psync_fs_do_start(){ 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); diff --git a/pCloudCC/lib/pclsync/pfsxattr.c b/pCloudCC/lib/pclsync/pfsxattr.c index 87871bef..c9632afb 100644 --- a/pCloudCC/lib/pclsync/pfsxattr.c +++ b/pCloudCC/lib/pclsync/pfsxattr.c @@ -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 +#include #include #include From 78a156f5f08247c5eba55e86dc769b73deed5899 Mon Sep 17 00:00:00 2001 From: James Miller Date: Sat, 8 Apr 2023 17:27:11 -0700 Subject: [PATCH 2/5] Lowering the required version makes this build successfully on ubuntu 22.04.2 ltl for amd64 --- pCloudCC/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pCloudCC/CMakeLists.txt b/pCloudCC/CMakeLists.txt index b28ba9a3..ac125f68 100644 --- a/pCloudCC/CMakeLists.txt +++ b/pCloudCC/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.22) project(pcloudcc) #INCLUDE(CPack) From 03b47dd21db9c0f32324bc8e32abd955c9137fd0 Mon Sep 17 00:00:00 2001 From: jvaskonen Date: Sat, 8 Apr 2023 17:46:22 -0700 Subject: [PATCH 3/5] Update README.md to install fuse3-dev --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0be218a4..81fd3ca5 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ 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 From 7019581a50e2c13b67b2d46cd3bb47fdbf6a2a42 Mon Sep 17 00:00:00 2001 From: jvaskonen Date: Sat, 8 Apr 2023 17:48:33 -0700 Subject: [PATCH 4/5] Update README.md drop unneeded step For some reason when it's being reneder, it's not getting put on it's own line, which causes problems with cut-and-paste --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 81fd3ca5..83b5daef 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ On Ubuntu you can run the following command: ## 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/ From 4ea0b2d11790b45f2983ebdd422811cbd57b322d Mon Sep 17 00:00:00 2001 From: jvaskonen Date: Sat, 8 Apr 2023 17:49:10 -0700 Subject: [PATCH 5/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 83b5daef..464786a0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ On Ubuntu you can run the following command: ## 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 +> > git clone https://github.com/pcloudcom/console-client.git ./console-client/ > cd ./console-client/pCloudCC/ > cd lib/pclsync/