@@ -70,6 +70,10 @@ typedef off_t fuse_off_t;
7070#include <sys/mount.h>
7171#endif
7272
73+ #if defined(P_OS_LINUX )
74+ #include <sys/mount.h>
75+ #endif
76+
7377#if IS_DEBUG
7478#define psync_fs_set_thread_name () do {psync_thread_name=__FUNCTION__;} while (0)
7579#else
@@ -2979,7 +2983,9 @@ static void *psync_fs_init(struct fuse_conn_info *conn){
29792983 conn -> want |=FUSE_CAP_BIG_WRITES ;
29802984#endif
29812985 conn -> max_readahead = 1024 * 1024 ;
2986+ #if !defined(P_OS_LINUX )
29822987 conn -> max_write = FS_MAX_WRITE ;
2988+ #endif
29832989 if (psync_start_callback )
29842990 psync_timer_register (psync_fs_start_callback_timer , 1 , NULL );
29852991 return 0 ;
@@ -3080,8 +3086,10 @@ void psync_fs_refresh_folder(psync_folderid_t folderid){
30803086 else {
30813087 debug (D_NOTICE , "creating fake file %s" , fpath );
30823088 fd = psync_file_open (fpath , P_O_WRONLY , P_O_CREAT );
3083- if (fd != INVALID_HANDLE_VALUE )
3089+ if (fd != INVALID_HANDLE_VALUE ){
30843090 psync_file_close (fd );
3091+ psync_file_delete (fpath );
3092+ }
30853093 }
30863094 psync_free (fpath );
30873095}
@@ -3196,6 +3204,13 @@ static void psync_fs_do_stop(void){
31963204 unmount (psync_current_mountpoint , MNT_FORCE );
31973205 debug (D_NOTICE , "unmount exited" );
31983206#endif
3207+
3208+ #if defined(P_OS_LINUX )
3209+ char * mp ;
3210+ mp = psync_fuse_get_mountpoint ();
3211+ fuse_unmount (mp , psync_fuse_channel );
3212+ #endif
3213+
31993214 debug (D_NOTICE , "running fuse_exit" );
32003215 fuse_exit (psync_fuse );
32013216 started = 2 ;
@@ -3305,6 +3320,29 @@ static void psync_fuse_thread(){
33053320 pthread_mutex_unlock (& start_mutex );
33063321}
33073322
3323+ // Returns true if FUSE 3 is installed on the user's machine.
3324+ // Returns false if FUSE version is less than 3.
3325+ static char is_fuse3_installed_on_system ()
3326+ {
3327+ // Assuming that fusermount3 is only available on FUSE 3.
3328+ FILE * pipe = popen ("which fusermount3" , "r" );
3329+
3330+ if (!pipe ) {
3331+ return 0 ;
3332+ }
3333+
3334+ char output [1024 ];
3335+ memset (output , 0 , sizeof (output ));
3336+
3337+ char * o = fgets (output , sizeof (output ), pipe );
3338+
3339+ pclose (pipe );
3340+ size_t outlen = strlen (output );
3341+
3342+ return outlen > 0 ;
3343+ }
3344+
3345+
33083346static int psync_fs_do_start (){
33093347 char * mp ;
33103348 struct fuse_operations psync_oper ;
@@ -3318,7 +3356,9 @@ static int psync_fs_do_start(){
33183356 fuse_opt_add_arg (& args , "-oauto_unmount" );
33193357// fuse_opt_add_arg(&args, "-ouse_ino");
33203358 fuse_opt_add_arg (& args , "-ofsname=" DEFAULT_FUSE_MOUNT_POINT ".fs" );
3321- fuse_opt_add_arg (& args , "-ononempty" );
3359+ if (!is_fuse3_intalled_on_system ()) {
3360+ fuse_opt_add_arg (& args , "-ononempty" );
3361+ }
33223362 fuse_opt_add_arg (& args , "-ohard_remove" );
33233363// fuse_opt_add_arg(&args, "-d");
33243364#endif
@@ -3479,3 +3519,4 @@ int psync_fs_remount(){
34793519 else
34803520 return 0 ;
34813521}
3522+
0 commit comments