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.
This commit is contained in:
robk-tahoe 2008-09-24 11:07:38 -07:00
parent 5882ce99f4
commit 97229238b0

View 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):