X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cebc9af013fbe65d83cb4a60813e3d1871f7ca3a..8fd18fc4a32797fc3c6255099fc253d7aede12b5:/services/fuse/arvados_fuse/unmount.py diff --git a/services/fuse/arvados_fuse/unmount.py b/services/fuse/arvados_fuse/unmount.py index 7a7464d4da..db78ddc738 100644 --- a/services/fuse/arvados_fuse/unmount.py +++ b/services/fuse/arvados_fuse/unmount.py @@ -26,25 +26,7 @@ def mountinfo(): return mi -def unmount_all(path, timeout=10): - if not path.endswith("/..."): - return unmount(path, timeout=timeout) - root = os.path.realpath(path[:-4]) - - paths = [] - for m in mountinfo(): - if m.path == root or m.path.startswith(root+"/"): - paths.append(m.path) - if not m.is_fuse: - raise Exception( - "cannot unmount {}: non-fuse mountpoint {}".format( - path, m)) - for path in sorted(paths, key=len, reverse=True): - unmount(path, timeout=timeout) - return len(paths) > 0 - - -def unmount(path, timeout=10): +def unmount(path, timeout=10, recursive=False): """Unmount the fuse mount at path. Unmounting is done by writing 1 to the "abort" control file in @@ -61,6 +43,19 @@ def unmount(path, timeout=10): path = os.path.realpath(path) + if recursive: + paths = [] + for m in mountinfo(): + if m.path == path or m.path.startswith(path+"/"): + paths.append(m.path) + if not m.is_fuse: + raise Exception( + "cannot unmount {}: non-fuse mountpoint {}".format( + path, m)) + for path in sorted(paths, key=len, reverse=True): + unmount(path, timeout=timeout, recursive=False) + return len(paths) > 0 + was_mounted = False attempted = False if timeout is None: