@@ -70,6 +70,10 @@ typedef off_t fuse_off_t;
70
70
#include <sys/mount.h>
71
71
#endif
72
72
73
+ #if defined(P_OS_LINUX )
74
+ #include <sys/mount.h>
75
+ #endif
76
+
73
77
#if IS_DEBUG
74
78
#define psync_fs_set_thread_name () do {psync_thread_name=__FUNCTION__;} while (0)
75
79
#else
@@ -2979,7 +2983,9 @@ static void *psync_fs_init(struct fuse_conn_info *conn){
2979
2983
conn -> want |=FUSE_CAP_BIG_WRITES ;
2980
2984
#endif
2981
2985
conn -> max_readahead = 1024 * 1024 ;
2986
+ #if !defined(P_OS_LINUX )
2982
2987
conn -> max_write = FS_MAX_WRITE ;
2988
+ #endif
2983
2989
if (psync_start_callback )
2984
2990
psync_timer_register (psync_fs_start_callback_timer , 1 , NULL );
2985
2991
return 0 ;
@@ -3080,8 +3086,10 @@ void psync_fs_refresh_folder(psync_folderid_t folderid){
3080
3086
else {
3081
3087
debug (D_NOTICE , "creating fake file %s" , fpath );
3082
3088
fd = psync_file_open (fpath , P_O_WRONLY , P_O_CREAT );
3083
- if (fd != INVALID_HANDLE_VALUE )
3089
+ if (fd != INVALID_HANDLE_VALUE ){
3084
3090
psync_file_close (fd );
3091
+ psync_file_delete (fpath );
3092
+ }
3085
3093
}
3086
3094
psync_free (fpath );
3087
3095
}
@@ -3196,6 +3204,13 @@ static void psync_fs_do_stop(void){
3196
3204
unmount (psync_current_mountpoint , MNT_FORCE );
3197
3205
debug (D_NOTICE , "unmount exited" );
3198
3206
#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
+
3199
3214
debug (D_NOTICE , "running fuse_exit" );
3200
3215
fuse_exit (psync_fuse );
3201
3216
started = 2 ;
@@ -3305,6 +3320,29 @@ static void psync_fuse_thread(){
3305
3320
pthread_mutex_unlock (& start_mutex );
3306
3321
}
3307
3322
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
+
3308
3346
static int psync_fs_do_start (){
3309
3347
char * mp ;
3310
3348
struct fuse_operations psync_oper ;
@@ -3318,7 +3356,9 @@ static int psync_fs_do_start(){
3318
3356
fuse_opt_add_arg (& args , "-oauto_unmount" );
3319
3357
// fuse_opt_add_arg(&args, "-ouse_ino");
3320
3358
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
+ }
3322
3362
fuse_opt_add_arg (& args , "-ohard_remove" );
3323
3363
// fuse_opt_add_arg(&args, "-d");
3324
3364
#endif
@@ -3479,3 +3519,4 @@ int psync_fs_remount(){
3479
3519
else
3480
3520
return 0 ;
3481
3521
}
3522
+
0 commit comments