diff --git a/pCloudCC/lib/pclsync/pfs.c b/pCloudCC/lib/pclsync/pfs.c index 30238329..1641252f 100644 --- a/pCloudCC/lib/pclsync/pfs.c +++ b/pCloudCC/lib/pclsync/pfs.c @@ -70,6 +70,10 @@ typedef off_t fuse_off_t; #include #endif +#if defined(P_OS_LINUX) +#include +#endif + #if IS_DEBUG #define psync_fs_set_thread_name() do {psync_thread_name=__FUNCTION__;} while (0) #else @@ -2979,7 +2983,9 @@ static void *psync_fs_init(struct fuse_conn_info *conn){ conn->want|=FUSE_CAP_BIG_WRITES; #endif conn->max_readahead=1024*1024; +#if !defined(P_OS_LINUX) conn->max_write=FS_MAX_WRITE; +#endif if (psync_start_callback) psync_timer_register(psync_fs_start_callback_timer, 1, NULL); return 0; @@ -3080,8 +3086,10 @@ void psync_fs_refresh_folder(psync_folderid_t folderid){ else{ debug(D_NOTICE, "creating fake file %s", fpath); fd=psync_file_open(fpath, P_O_WRONLY, P_O_CREAT); - if (fd!=INVALID_HANDLE_VALUE) + if (fd!=INVALID_HANDLE_VALUE){ psync_file_close(fd); + psync_file_delete(fpath); + } } psync_free(fpath); } @@ -3196,6 +3204,13 @@ static void psync_fs_do_stop(void){ unmount(psync_current_mountpoint, MNT_FORCE); debug(D_NOTICE, "unmount exited"); #endif + +#if defined(P_OS_LINUX) + char *mp; + mp = psync_fuse_get_mountpoint(); + fuse_unmount(mp, psync_fuse_channel); +#endif + debug(D_NOTICE, "running fuse_exit"); fuse_exit(psync_fuse); started=2; @@ -3305,6 +3320,29 @@ static void psync_fuse_thread(){ pthread_mutex_unlock(&start_mutex); } +// Returns true if FUSE 3 is installed on the user's machine. +// Returns false if FUSE version is less than 3. +static char is_fuse3_installed_on_system() +{ + // Assuming that fusermount3 is only available on FUSE 3. + FILE* pipe = popen("which fusermount3", "r"); + + if (!pipe) { + return 0; + } + + char output[1024]; + memset(output, 0, sizeof(output)); + + char* o = fgets(output, sizeof(output), pipe); + + pclose(pipe); + size_t outlen = strlen(output); + + return outlen > 0; +} + + static int psync_fs_do_start(){ char *mp; struct fuse_operations psync_oper; @@ -3318,7 +3356,9 @@ static int psync_fs_do_start(){ 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"); - fuse_opt_add_arg(&args, "-ononempty"); + if (!is_fuse3_intalled_on_system()) { + fuse_opt_add_arg(&args, "-ononempty"); + } fuse_opt_add_arg(&args, "-ohard_remove"); // fuse_opt_add_arg(&args, "-d"); #endif @@ -3479,3 +3519,4 @@ int psync_fs_remount(){ else return 0; } +