@@ -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 ;
@@ -3198,6 +3204,13 @@ static void psync_fs_do_stop(void){
3198
3204
unmount (psync_current_mountpoint , MNT_FORCE );
3199
3205
debug (D_NOTICE , "unmount exited" );
3200
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
+
3201
3214
debug (D_NOTICE , "running fuse_exit" );
3202
3215
fuse_exit (psync_fuse );
3203
3216
started = 2 ;
@@ -3307,6 +3320,29 @@ static void psync_fuse_thread(){
3307
3320
pthread_mutex_unlock (& start_mutex );
3308
3321
}
3309
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
+
3310
3346
static int psync_fs_do_start (){
3311
3347
char * mp ;
3312
3348
struct fuse_operations psync_oper ;
@@ -3320,7 +3356,9 @@ static int psync_fs_do_start(){
3320
3356
fuse_opt_add_arg (& args , "-oauto_unmount" );
3321
3357
// fuse_opt_add_arg(&args, "-ouse_ino");
3322
3358
fuse_opt_add_arg (& args , "-ofsname=" DEFAULT_FUSE_MOUNT_POINT ".fs" );
3323
- fuse_opt_add_arg (& args , "-ononempty" );
3359
+ if (!is_fuse3_installed_on_system ()) {
3360
+ fuse_opt_add_arg (& args , "-ononempty" );
3361
+ }
3324
3362
fuse_opt_add_arg (& args , "-ohard_remove" );
3325
3363
// fuse_opt_add_arg(&args, "-d");
3326
3364
#endif
@@ -3481,3 +3519,4 @@ int psync_fs_remount(){
3481
3519
else
3482
3520
return 0 ;
3483
3521
}
3522
+
0 commit comments