Fix spurious 'not mounted' error on FUSE3 shutdown

In FUSE3 mode, pfs_do_stop called fuse_unmount followed by fuse_exit.
The FUSE thread then called fuse_destroy, which tried to unmount again,
producing "fusermount3: not mounted".

For FUSE3, fuse_exit is sufficient to stop the loop; fuse_destroy handles
the unmount. Restrict the explicit fuse_unmount call to FUSE2 only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-03-10 13:49:47 +01:00
parent 723a39540b
commit 1156d48464
1 changed files with 3 additions and 16 deletions

View File

@ -3616,29 +3616,15 @@ static void pfs_do_stop(void) {
if (started == 1) {
char *mp;
struct stat st_before, st_after;
struct timespec ts = {0, 100000000};
mp = psync_fuse_get_mountpoint();
#if FUSE_USE_VERSION < 30
if (mp) {
struct stat st_before;
if (stat(mp, &st_before) == 0) {
#if FUSE_USE_VERSION >= 30
fuse_unmount(psync_fuse);
#else
fuse_unmount(mp, psync_fuse_channel);
psync_fuse_channel = NULL;
#endif
clock_gettime(CLOCK_REALTIME, &ts);
// Check if the mountpoint is still accessible
if (stat(mp, &st_after) == 0) {
if (st_before.st_dev == st_after.st_dev) {
pdbg_logf(D_WARNING, "FUSE filesystem may not have unmounted properly");
}
} else if (errno != ENOENT) {
pdbg_logf(D_WARNING, "Unexpected error after unmount: %s",
strerror(errno));
}
} else {
pdbg_logf(D_WARNING, "Mountpoint not accessible before unmount: %s",
strerror(errno));
@ -3646,6 +3632,7 @@ static void pfs_do_stop(void) {
} else {
pdbg_logf(D_ERROR, "Failed to get mountpoint");
}
#endif
pdbg_logf(D_NOTICE, "running fuse_exit");
fuse_exit(psync_fuse);