Commit b5eefe94 by rfkelly0

better error reporting for FUSE

parent e320e69b
...@@ -395,10 +395,16 @@ def unmount(path): ...@@ -395,10 +395,16 @@ def unmount(path):
FUSE filesystem. It works, but it would probably be better to use the FUSE filesystem. It works, but it would probably be better to use the
'unmount' method on the MountProcess class if you have it. 'unmount' method on the MountProcess class if you have it.
""" """
p = subprocess.Popen(["fusermount","-u",path],stderr=subprocess.PIPE) for num_tries in xrange(3):
(stdout,stderr) = p.communicate() p = subprocess.Popen(["fusermount","-u",path],stderr=subprocess.PIPE)
if p.returncode != 0 and "not mounted" not in stderr: (stdout,stderr) = p.communicate()
raise OSError("filesystem could not be unmounted: " + path) if p.returncode == 0:
return
if "not mounted" in stderr:
return
if "not found" in stderr:
return
raise OSError("filesystem could not be unmounted: %s (%s) " % (path,stderr,))
class MountProcess(subprocess.Popen): class MountProcess(subprocess.Popen):
...@@ -456,7 +462,7 @@ class MountProcess(subprocess.Popen): ...@@ -456,7 +462,7 @@ class MountProcess(subprocess.Popen):
super(MountProcess,self).__init__(cmd,**kwds) super(MountProcess,self).__init__(cmd,**kwds)
os.close(w) os.close(w)
if os.read(r,1) != "S": if os.read(r,1) != "S":
raise RuntimeError("A FUSE error occurred") raise RuntimeError("FUSE error: " + os.read(r,20))
def unmount(self): def unmount(self):
"""Cleanly unmount the FUSE filesystem, terminating this subprocess.""" """Cleanly unmount the FUSE filesystem, terminating this subprocess."""
...@@ -510,10 +516,13 @@ class MountProcess(subprocess.Popen): ...@@ -510,10 +516,13 @@ class MountProcess(subprocess.Popen):
opts["unmount_callback"] = unmount_callback opts["unmount_callback"] = unmount_callback
try: try:
mount(fs,path,**opts) mount(fs,path,**opts)
except Exception: except Exception, e:
pass os.write(w,"E"+str(e))
if not successful: os.close(w)
os.write(w,"E") else:
if not successful:
os.write(w,"E")
os.close(w)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment