Fix bad interaction between llfuse and daemonization in arv-mount.
authorBrett Smith <brett@curoverse.com>
Tue, 24 Jun 2014 19:02:39 +0000 (15:02 -0400)
committerBrett Smith <brett@curoverse.com>
Tue, 24 Jun 2014 19:02:39 +0000 (15:02 -0400)
Following PEP 3143, daemon.DaemonContext drops all open file
descriptors by default.  This causes arv-mount to fail, because
llfuse.init() opens /dev/fuse, and llfuse.main() uses that file
descriptor.  We now daemonize before doing real work to prevent this
unintentional breakage.

This effectively reverts 83c873af.  An alternative approach would've
been to call DaemonContext with a preserve_files argument.  I decided
against that because I couldn't find a reliable way to determine
which file descriptors llfuse needs.  If we really need the daemon to
report errors, and debugging with --foreground isn't sufficient, I
think we should implement proper logging to a file or syslog.

No issue #.

services/fuse/bin/arv-mount

index b4afffab061fc2ceaf56bc7dcb93a105fa3d93cb..db8e852b4cea27f96c6424f3509b3549dd8b14b8 100755 (executable)
@@ -1,11 +1,13 @@
 #!/usr/bin/env python
 
-from arvados_fuse import *
-import arvados
-import subprocess
 import argparse
+import arvados
 import daemon
+import os
 import signal
+import subprocess
+
+from arvados_fuse import *
 
 if __name__ == '__main__':
     # Handle command line parameters
@@ -91,12 +93,9 @@ collections on the server.""")
 
         exit(rc)
     else:
-        if args.foreground:
-            # Initialize the fuse connection
-            llfuse.init(operations, args.mountpoint, opts)
-            llfuse.main()
-        else:
-            # Initialize the fuse connection
-            llfuse.init(operations, args.mountpoint, opts)
-            with daemon.DaemonContext():
-                llfuse.main()
+        os.chdir(args.mountpoint)
+        if not args.foreground:
+            daemon_ctx = daemon.DaemonContext(working_directory='.')
+            daemon_ctx.open()
+        llfuse.init(operations, '.', opts)
+        llfuse.main()