faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

Is there any way to find the mount point of a filesystem given the path to a file within the file system?

Jul 12th, 2000 18:35
unknown unknown, John Clonts


I didn't find anything already extant, so here's this:
def mountpoint(s):
    import os
    if (os.path.ismount(s) or len(s)==0): return s
    else: return mountpoint(os.path.split(s)[0])
def testit():
    print mountpoint("/home/john/scheme/cmucl")
    print mountpoint("/usr/local")
    print mountpoint("/lib/")
    print mountpoint("lib")