From 2cfaf03f840d67a0daa3b94ffb9572ff39b2a668 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 24 Jan 2017 14:18:25 +0100 Subject: [PATCH] mount: umount on SIGINT/^C when in foreground --- borg/archiver.py | 7 +++++++ borg/fuse.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/borg/archiver.py b/borg/archiver.py index 667a8e90b..c2626beba 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -1546,6 +1546,13 @@ class Archiver: - allow_damaged_files: by default damaged files (where missing chunks were replaced with runs of zeros by borg check --repair) are not readable and return EIO (I/O error). Set this option to read such files. + + When the daemonized process receives a signal or crashes, it does not unmount. + Unmounting in these cases could cause an active rsync or similar process + to unintentionally delete data. + + When running in the foreground ^C/SIGINT unmounts cleanly, but other + signals or crashes do not. """) subparser = subparsers.add_parser('mount', parents=[common_parser], description=self.do_mount.__doc__, diff --git a/borg/fuse.py b/borg/fuse.py index f92f76900..710611004 100644 --- a/borg/fuse.py +++ b/borg/fuse.py @@ -6,6 +6,7 @@ import os import stat import tempfile import time +from signal import SIGINT from distutils.version import LooseVersion import msgpack @@ -98,7 +99,8 @@ class FuseOperations(llfuse.Operations): umount = False try: signal = fuse_main() - umount = (signal is None) # no crash and no signal -> umount request + # no crash and no signal (or it's ^C and we're in the foreground) -> umount request + umount = (signal is None or (signal == SIGINT and foreground)) finally: llfuse.close(umount)