-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
import sys, os, errno
-from bup import options, git, vfs
-from bup.helpers import *
+
+from bup import options, git, vfs, xstat
+from bup.helpers import log
+
try:
import fuse
except ImportError:
- log('bup: error: The python "fuse" module is missing.\n' +
- 'To use bup fuse, first install the python-fuse package.\n')
+ log('error: cannot find the python "fuse" module; please install it\n')
sys.exit(1)
class BupFs(fuse.Fuse):
- def __init__(self, top):
+ def __init__(self, top, meta=False):
fuse.Fuse.__init__(self)
self.top = top
+ self.meta = meta
def getattr(self, path):
log('--getattr(%r)\n' % path)
st = Stat()
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
+ st.st_size = node.size() # Until/unless we store the size in m.
+ if self.meta:
+ m = node.metadata()
+ if m:
+ st.st_mode = m.mode
+ st.st_uid = m.uid
+ st.st_gid = m.gid
+ st.st_atime = max(0, xstat.fstime_floor_secs(m.atime))
+ st.st_mtime = max(0, xstat.fstime_floor_secs(m.mtime))
+ st.st_ctime = max(0, xstat.fstime_floor_secs(m.ctime))
return st
except vfs.NoSuchFile:
return -errno.ENOENT
d,debug increase debug level
f,foreground run in foreground
o,allow-other allow other users to access the filesystem
+meta report original metadata for paths when available
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
git.check_repo_or_die()
top = vfs.RefList(None)
-f = BupFs(top)
+f = BupFs(top, meta=opt.meta)
f.fuse_args.mountpoint = extra[0]
if opt.debug:
f.fuse_args.add('debug')