]> arthur.barton.de Git - bup.git/blobdiff - cmd/fuse-cmd.py
index-cmd: prevent a division by zero while computing paths_per_second.
[bup.git] / cmd / fuse-cmd.py
index ffcd036ffffd275ebfd73aad7b30f8d448d6cf39..1621f1e527cadc95d5dbbb09cfa24fd59d82079a 100755 (executable)
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
-import sys, os, stat, errno, fuse, re, time, tempfile
+import sys, os, errno
 from bup import options, git, vfs
 from bup.helpers import *
+try:
+    import fuse
+except ImportError:
+    log('error: cannot find the python "fuse" module; please install it\n')
+    sys.exit(1)
 
 
 class Stat(fuse.Stat):
@@ -16,6 +21,9 @@ class Stat(fuse.Stat):
         self.st_atime = 0
         self.st_mtime = 0
         self.st_ctime = 0
+        self.st_blocks = 0
+        self.st_blksize = 0
+        self.st_rdev = 0
 
 
 cache = {}
@@ -56,6 +64,9 @@ class BupFs(fuse.Fuse):
             st.st_mode = node.mode
             st.st_nlink = node.nlinks()
             st.st_size = node.size()
+            st.st_mtime = node.mtime
+            st.st_ctime = node.ctime
+            st.st_atime = node.atime
             return st
         except vfs.NoSuchFile:
             return -errno.ENOENT
@@ -87,7 +98,9 @@ class BupFs(fuse.Fuse):
     def read(self, path, size, offset):
         log('--read(%r)\n' % path)
         n = cache_get(self.top, path)
-        return n.readbytes(offset, size)
+        o = n.open()
+        o.seek(offset)
+        return o.read(size)
 
 
 if not hasattr(fuse, '__version__'):
@@ -100,8 +113,9 @@ bup fuse [-d] [-f] <mountpoint>
 --
 d,debug   increase debug level
 f,foreground  run in foreground
+o,allow-other allow other users to access the filesystem
 """
-o = options.Options('bup fuse', optspec)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 if len(extra) != 1:
@@ -117,6 +131,7 @@ if opt.foreground:
     f.fuse_args.setmod('foreground')
 print f.multithreaded
 f.multithreaded = False
-f.fuse_args.add('allow_other')
+if opt.allow_other:
+    f.fuse_args.add('allow_other')
 
 f.main()