]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse/impl_b: tweaks from testing on hardy
authorrobk-tahoe <robk-tahoe@allmydata.com>
Wed, 24 Sep 2008 18:07:38 +0000 (11:07 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Wed, 24 Sep 2008 18:07:38 +0000 (11:07 -0700)
from testing on linux (specifically ubuntu hardy) the libfuse dll has a
different name, specifically libfuse.so.2. this patch tries libfuse.so
and then falls back to trying .2 if the former fails.

it also changes the unmount behaviour, to simply return from the handler's
loop_forever() loop upon being unmounted, rather than raising an EOFError,
since none of the client code I looked at actually handled that exception,
but did seem to expect to fall off of main() when loop_forever() returned.
Additionally, from my testing unmount typically led to an OSError from the
fuse fd read, rather than an empty read, as the code seemed to expect.

also removed a spurious import pyflakes quibbled about.

contrib/fuse/impl_b/pyfuse/handler.py

index f5c8e65ded421fc172aff00ade505be51cd5273e..46643e26d8cafea48a06592b86922e985f176510 100644 (file)
@@ -1,5 +1,5 @@
 from kernel import *
-import os, errno, sys, stat
+import os, errno, sys
 
 def fuse_mount(mountpoint, opts=None):
     if not isinstance(mountpoint, str):
@@ -7,7 +7,10 @@ def fuse_mount(mountpoint, opts=None):
     if opts is not None and not isinstance(opts, str):
         raise TypeError
     import dl
-    fuse = dl.open('libfuse.so')
+    try:
+        fuse = dl.open('libfuse.so')
+    except dl.error:
+        fuse = dl.open('libfuse.so.2')
     if fuse.sym('fuse_mount_compat22'):
         fnname = 'fuse_mount_compat22'
     else:
@@ -59,9 +62,16 @@ class Handler(object):
 
     def loop_forever(self):
         while True:
-            msg = os.read(self.fd, FUSE_MAX_IN)
+            try:
+                msg = os.read(self.fd, FUSE_MAX_IN)
+            except OSError, ose:
+                if ose.errno == errno.ENODEV:
+                    # on hardy, at least, this is what happens upon fusermount -u
+                    #raise EOFError("out-kernel connection closed")
+                    return
             if not msg:
-                raise EOFError("out-kernel connection closed")
+                #raise EOFError("out-kernel connection closed")
+                return
             self.handle_message(msg)
 
     def handle_message(self, msg):