MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / ismount

Function ismount

tools/python-3.11.9-amd64/Lib/posixpath.py:186–217  ·  view source on GitHub ↗

Test whether a path is a mount point

(path)

Source from the content-addressed store, hash-verified

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