summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1716d18)
Add a new --meta option to "bup fuse", and when specified, report the
original mode, uid, gid, atime, mtime, and ctime for the mounted
paths.
Since negative timestamps cause access errors, and cause "ls -l" to
report question marks for the stat values, set a floor of 0 for all
timestamps reported to python-fuse.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
: permit other users to access the filesystem. Necessary for
exporting the filesystem via Samba, for example.
: permit other users to access the filesystem. Necessary for
exporting the filesystem via Samba, for example.
+\--meta
+: report some of the original metadata (when available) for the
+ mounted paths (currently the uid, gid, mode, and timestamps).
+ Without this, only generic values will be presented. This option
+ is not yet enabled by default because it may negatively affect
+ performance, and note that any timestamps before 1970-01-01 UTC
+ (i.e. before the Unix epoch) will be presented as 1970-01-01 UTC.
+
# EXAMPLES
rm -rf /tmp/buptest
mkdir /tmp/buptest
# EXAMPLES
rm -rf /tmp/buptest
mkdir /tmp/buptest
#!/usr/bin/env python
import sys, os, errno
#!/usr/bin/env python
import sys, os, errno
-from bup import options, git, vfs
+from bup import options, git, vfs, xstat
from bup.helpers import *
try:
import fuse
from bup.helpers import *
try:
import fuse
- def __init__(self, top):
+ def __init__(self, top, meta=False):
fuse.Fuse.__init__(self)
self.top = top
fuse.Fuse.__init__(self)
self.top = top
def getattr(self, path):
log('--getattr(%r)\n' % path)
def getattr(self, path):
log('--getattr(%r)\n' % path)
st = Stat()
st.st_mode = node.mode
st.st_nlink = node.nlinks()
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
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
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:])
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
git.check_repo_or_die()
top = vfs.RefList(None)
git.check_repo_or_die()
top = vfs.RefList(None)
+f = BupFs(top, meta=opt.meta)
f.fuse_args.mountpoint = extra[0]
if opt.debug:
f.fuse_args.add('debug')
f.fuse_args.mountpoint = extra[0]
if opt.debug:
f.fuse_args.add('debug')
WVPASS mkdir src
WVPASS date > src/foo
WVPASS mkdir src
WVPASS date > src/foo
+WVPASS chmod 644 src/foo
+WVPASS touch -t 201111111111 src/foo
+# FUSE, python-fuse, something, can't handle negative epoch times.
+# Use pre-epoch to make sure bup properly "bottoms out" at 0 for now.
+WVPASS date > src/pre-epoch
+WVPASS chmod 644 src/pre-epoch
+WVPASS touch -t 196907202018 src/pre-epoch
WVPASS bup index src
WVPASS bup save -n src -d "$savestamp1" --strip src
WVPASS bup index src
WVPASS bup save -n src -d "$savestamp1" --strip src
latest"
result=$(WVPASS ls mnt/src/latest) || exit $?
latest"
result=$(WVPASS ls mnt/src/latest) || exit $?
-WVPASSEQ "$result" "foo"
+WVPASSEQ "$result" "foo
+pre-epoch"
# Right now we don't detect new saves.
WVPASS bup save -n src -d "$savestamp2" --strip src
# Right now we don't detect new saves.
WVPASS bup save -n src -d "$savestamp2" --strip src
WVPASSEQ "$result" "$savename1
latest"
WVPASSEQ "$result" "$savename1
latest"
+WVPASS fusermount -uz mnt
+
+WVSTART "extended metadata"
+WVPASS bup fuse --meta mnt
+result=$(WVPASS ls -l mnt/src/latest/) || exit $?
+readonly user=$(WVPASS id -un) || $?
+readonly group=$(WVPASS id -gn) || $?
+WVPASSEQ "$result" "total 0
+-rw-r--r-- 1 $user $group 29 Nov 11 2011 foo
+-rw-r--r-- 1 $user $group 29 Dec 31 1969 pre-epoch"
+
WVPASS fusermount -uz mnt
WVPASS rm -rf "$tmpdir"
WVPASS fusermount -uz mnt
WVPASS rm -rf "$tmpdir"