umount: try fusermount, then try umount

This commit is contained in:
Marian Beermann 2017-07-24 10:42:14 +02:00
parent b85076db6f
commit 2fe37dba7f
9 changed files with 17 additions and 22 deletions

View File

@ -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

View File

@ -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])

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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])

View File

@ -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])

View File

@ -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.