Browse Source

Merge pull request #2875 from enkore/issue/2863

umount: try fusermount, then try umount
enkore 8 years ago
parent
commit
3c0f8b7943

+ 2 - 1
src/borg/archiver.py

@@ -66,11 +66,12 @@ from .helpers import replace_placeholders
 from .helpers import ChunkIteratorFileWrapper
 from .helpers import popen_with_error_handling
 from .helpers import dash_open
+from .helpers import umount
 from .nanorst import rst_to_terminal
 from .patterns import ArgparsePatternAction, ArgparseExcludeFileAction, ArgparsePatternFileAction, parse_exclude_pattern
 from .patterns import PatternMatcher
 from .item import Item
-from .platform import get_flags, umount, get_process_id, SyncFile
+from .platform import get_flags, get_process_id, SyncFile
 from .remote import RepositoryServer, RemoteRepository, cache_if_remote
 from .repository import Repository, LIST_SCAN_LIMIT
 from .selftest import selftest

+ 7 - 0
src/borg/helpers.py

@@ -2277,3 +2277,10 @@ def dash_open(path, mode):
 
 def is_terminal(fd=sys.stdout):
     return hasattr(fd, 'isatty') and fd.isatty() and (sys.platform != 'win32' or 'ANSICON' in os.environ)
+
+
+def umount(mountpoint):
+    try:
+        return subprocess.call(['fusermount', '-u', mountpoint])
+    except FileNotFoundError:
+        return subprocess.call(['umount', mountpoint])

+ 4 - 4
src/borg/platform/__init__.py

@@ -9,7 +9,7 @@ Public APIs are documented in platform.base.
 from .base import acl_get, acl_set
 from .base import set_flags, get_flags
 from .base import SaveFile, SyncFile, sync_dir, fdatasync, safe_fadvise
-from .base import swidth, umount, API_VERSION
+from .base import swidth, API_VERSION
 from .base import process_alive, get_process_id, local_pid_alive
 
 OS_API_VERSION = API_VERSION
@@ -22,12 +22,12 @@ if sys.platform.startswith('linux'):  # pragma: linux only
     from .linux import acl_get, acl_set
     from .linux import set_flags, get_flags
     from .linux import SyncFile
-    from .linux import swidth, umount
+    from .linux import swidth
 elif sys.platform.startswith('freebsd'):  # pragma: freebsd only
     from .freebsd import API_VERSION as OS_API_VERSION
     from .freebsd import acl_get, acl_set
-    from .freebsd import swidth, umount
+    from .freebsd import swidth
 elif sys.platform == 'darwin':  # pragma: darwin only
     from .darwin import API_VERSION as OS_API_VERSION
     from .darwin import acl_get, acl_set
-    from .darwin import swidth, umount
+    from .darwin import swidth

+ 0 - 5
src/borg/platform/base.py

@@ -183,11 +183,6 @@ def swidth(s):
     return len(s)
 
 
-def umount(mountpoint):
-    """un-mount the FUSE filesystem mounted at <mountpoint>"""
-    return 0  # dummy, see also posix module
-
-
 def get_process_id():
     """
     Return identification tuple (hostname, pid, thread_id) for 'us'. If this is a FUSE process, then the PID will be

+ 1 - 1
src/borg/platform/darwin.pyx

@@ -2,7 +2,7 @@ import os
 
 from ..helpers import user2uid, group2gid
 from ..helpers import safe_decode, safe_encode
-from .posix import swidth, umount
+from .posix import swidth
 
 API_VERSION = '1.1_01'
 

+ 1 - 1
src/borg/platform/freebsd.pyx

@@ -2,7 +2,7 @@ import os
 
 from ..helpers import posix_acl_use_stored_uid_gid
 from ..helpers import safe_encode, safe_decode
-from .posix import swidth, umount
+from .posix import swidth
 
 API_VERSION = '1.1_01'
 

+ 0 - 4
src/borg/platform/linux.pyx

@@ -258,7 +258,3 @@ class SyncFile(BaseSyncFile):
         # tell the OS that it does not need to cache what we just wrote,
         # avoids spoiling the cache for the OS and other processes.
         safe_fadvise(self.fileno, 0, 0, 'DONTNEED')
-
-
-def umount(mountpoint):
-    return subprocess.call(['fusermount', '-u', mountpoint])

+ 0 - 5
src/borg/platform/posix.pyx

@@ -72,8 +72,3 @@ def local_pid_alive(pid):
             return False
         # Any other error (eg. permissions) means that the process ID refers to a live process.
         return True
-
-
-# most POSIX platforms (but not Linux)
-def umount(mountpoint):
-    return subprocess.call(['umount', mountpoint])

+ 2 - 1
src/borg/testsuite/__init__.py

@@ -12,7 +12,8 @@ import uuid
 import unittest
 
 from ..xattr import get_all
-from ..platform import get_flags, umount
+from ..platform import get_flags
+from ..helpers import umount
 from .. import platform
 
 # Note: this is used by borg.selftest, do not use or import py.test functionality here.