From: robk-tahoe Date: Wed, 24 Sep 2008 18:07:38 +0000 (-0700) Subject: fuse/impl_b: tweaks from testing on hardy X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/rgr-080307.php?a=commitdiff_plain;h=97229238b0b9cac48139239f2fc70fbbe3d9a34b;p=tahoe-lafs%2Ftahoe-lafs.git fuse/impl_b: tweaks from testing on hardy 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. --- diff --git a/contrib/fuse/impl_b/pyfuse/handler.py b/contrib/fuse/impl_b/pyfuse/handler.py index f5c8e65d..46643e26 100644 --- a/contrib/fuse/impl_b/pyfuse/handler.py +++ b/contrib/fuse/impl_b/pyfuse/handler.py @@ -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):