aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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: