summary refs log tree commit diff stats
path: root/ranger/ext/mount_path.py
blob: 1c11139dc0b34a9d50ee04434f9eb62bcce2bad5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Copyright (C) 2009-2013  Roman Zimbelmann <hut@lepus.uberspace.de>
# This software is distributed under the terms of the GNU GPL version 3.

from os.path import realpath, abspath, dirname, ismount

def mount_path(path):
    """Get the mount root of a directory"""
    path = abspath(realpath(path))
    while path != '/':
        if ismount(path):
            return path
        path = dirname(path)
    return '/'