aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-23 22:02:37 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-23 22:02:37 (GMT)
commit4873d2d77451c0b5846b2f129c7abf92f10e4d7d (patch)
tree4cd039bedc795c898eee9fbefa421e4454d7ae0e
parented2e6b90331ad530fe213ef9113cc128b375f54b (diff)
downloadfusearchive-4873d2d77451c0b5846b2f129c7abf92f10e4d7d.zip
fusearchive-4873d2d77451c0b5846b2f129c7abf92f10e4d7d.tar.gz
fusearchive-4873d2d77451c0b5846b2f129c7abf92f10e4d7d.tar.bz2
Fixed getattr to use fgetattr so we don't have to maintain 2 functions
-rwxr-xr-xfusearchive.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/fusearchive.py b/fusearchive.py
index f97911b..810e05f 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -26,7 +26,7 @@ fuse.feature_assert('stateful_files', 'has_init')
magic_blocksize = 1024 * 32
magic_depth = 5
-debug_level = 4
+debug_level = 1
def dmsg(level,message):
if level <= debug_level:
@@ -151,21 +151,16 @@ class FuseArchive(Fuse):
# Fix getattr and fgetattr to?
def getattr(self, path):
treefile = "./tree" + path
- stats = os.lstat( treefile )
if os.path.isfile( treefile ):
- dmsg( 3, "Reading file to get size: " + path )
+ dmsg( 3, "Delegating getattr to FuserArchiveFile" )
- #pdb.set_trace()
-
- # Override size
- inp = gzip.open( treefile )
- magic = pickle.load( inp )
- inp.close()
-
- dmsg( 3, "Overridding getattr" )
- stats = FuseArchiveStat( stats )
- stats.overstat( magic[ 'size' ] )
+ f = self.FuseArchiveFile( path, os.O_RDONLY, 0 )
+ stats = f.fgetattr()
+ f.release( 0 )
+ else:
+ dmsg( 3, "Using os.lstat to get stats" )
+ stats = os.lstat( treefile )
return stats
@@ -493,8 +488,17 @@ class FuseArchive(Fuse):
self._fflush()
def fgetattr(self):
- print "WARNING: fgetattr is broken!!!!"
- return os.lstat( "./tree" + self.orig_path )
+ dmsg( 3, "Overridding fgetattr" )
+ stats = FuseArchiveStat( os.lstat( "./tree" + self.orig_path ) )
+
+ if self.modified:
+ # We would need to fsync here to recalc size, but don't do
+ # it unless modified? otherwise simple getattr will be
+ # rewriting a ton of files
+ print "WARNING: self.modified causes fgetattr to be incorrect!"
+
+ stats.overstat( self.size )
+ return stats
def ftruncate(self, len):
if len > 0: