浏览代码

fuse: allow additional mount options using "-o foo,bar"

Jonas Borgström 12 年之前
父节点
当前提交
6c5f494a82
共有 2 个文件被更改,包括 17 次插入7 次删除
  1. 8 5
      attic/archiver.py
  2. 9 2
      attic/fuse.py

+ 8 - 5
attic/archiver.py

@@ -12,8 +12,7 @@ from .cache import Cache
 from .key import key_creator
 from .helpers import location_validator, format_time, \
     format_file_mode, IncludePattern, ExcludePattern, exclude_path, adjust_patterns, to_localtime, \
-    get_cache_dir, get_keys_dir, format_timedelta, prune_split, Manifest, Location, remove_surrogates, \
-    daemonize
+    get_cache_dir, get_keys_dir, format_timedelta, prune_split, Manifest, Location, remove_surrogates
 from .remote import RepositoryServer, RemoteRepository, ConnectionClosed
 
 
@@ -212,9 +211,11 @@ class Archiver:
         self.print_verbose('done')
         operations = AtticOperations(key, repository, archive)
         self.print_verbose("Mounting filesystem")
-        if not args.foreground:
-            daemonize()
-        operations.mount(args.mountpoint)
+        try:
+            operations.mount(args.mountpoint, args.options, args.foreground)
+        except RuntimeError:
+            # Relevant error message already printed to stderr by fuse
+            self.exit_code = 1
         return self.exit_code
 
     def do_list(self, args):
@@ -426,6 +427,8 @@ class Archiver:
         subparser.add_argument('-f', '--foreground', dest='foreground',
                                action='store_true', default=False,
                                help='stay in foreground, do not daemonize')
+        subparser.add_argument('-o', dest='options', type=str,
+                               help='Extra mount options')
 
         subparser = subparsers.add_parser('verify', parents=[common_parser],
                                           description=self.do_verify.__doc__)

+ 9 - 2
attic/fuse.py

@@ -5,6 +5,8 @@ import os
 import stat
 import time
 
+from attic.helpers import daemonize
+
 
 class AtticOperations(llfuse.Operations):
     """Export Attic archive as a fuse filesystem
@@ -153,8 +155,13 @@ class AtticOperations(llfuse.Operations):
     def readlink(self, inode):
         return os.fsencode(self.items[inode][b'source'])
 
-    def mount(self, mountpoint):
-        llfuse.init(self, mountpoint, ['fsname=atticfs', 'ro'])
+    def mount(self, mountpoint, extra_options, foreground=False):
+        options = ['fsname=atticfs', 'ro']
+        if extra_options:
+            options.extend(extra_options.split(','))
+        llfuse.init(self, mountpoint, options)
+        if not foreground:
+            daemonize()
         try:
             llfuse.main(single=True)
         except: