MCPcopy Index your code
hub / github.com/python/cpython / ismount

Function ismount

Lib/posixpath.py:191–218  ·  view source on GitHub ↗

Test whether a path is a mount point

(path)

Source from the content-addressed store, hash-verified

189# (Does this work for all UNIXes? Is it even guaranteed to work by Posix?)
190
191def ismount(path):
192 """Test whether a path is a mount point"""
193 try:
194 s1 = os.lstat(path)
195 except (OSError, ValueError):
196 # It doesn't exist -- so not a mount point. :-)
197 return False
198 else:
199 # A symlink can never be a mount point
200 if stat.S_ISLNK(s1.st_mode):
201 return False
202
203 path = os.fspath(path)
204 if isinstance(path, bytes):
205 parent = join(path, b'..')
206 else:
207 parent = join(path, '..')
208 try:
209 s2 = os.lstat(parent)
210 except OSError:
211 parent = realpath(parent)
212 try:
213 s2 = os.lstat(parent)
214 except OSError:
215 return False
216
217 # path/.. on a different device as path or the same i-node as path
218 return s1.st_dev != s2.st_dev or s1.st_ino == s2.st_ino
219
220
221# Expand paths beginning with '~' or '~user'.

Callers

nothing calls this directly

Calls 3

lstatMethod · 0.80
joinFunction · 0.70
realpathFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…