Skip to content

Commit

Permalink
adding kernel 5+ fix and fuse 3+ fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pcloudcom authored and pcloudcom committed Feb 18, 2020
1 parent 90a52dd commit 664df26
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions pCloudCC/lib/pclsync/pfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ typedef off_t fuse_off_t;
#include <sys/mount.h>
#endif

#if defined(P_OS_LINUX)
#include <sys/mount.h>
#endif

#if IS_DEBUG
#define psync_fs_set_thread_name() do {psync_thread_name=__FUNCTION__;} while (0)
#else
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -3479,3 +3519,4 @@ int psync_fs_remount(){
else
return 0;
}

0 comments on commit 664df26

Please sign in to comment.