From 3cf47419c9a6a548710f30a01e458ebdd64fc2e2 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Thu, 23 Jul 2009 08:24:36 -0700 Subject: Fix stat() to return proper size diff --git a/fusearchive.py b/fusearchive.py index 86297f5..ad7a946 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -158,9 +158,28 @@ def deflate( src, dest ): inp.close() out = open( dest, "w" ) - pickle.dump( { 'data': hashs }, out ) + pickle.dump( { + 'stat': os.stat( src ), + 'data': hashs + }, out ) out.close() +class FuseArchiveStat(fuse.Stat): + def __init__(self, stat, overstat): + self.st_mode = stat.st_mode + self.st_ino = stat.st_ino + self.st_dev = stat.st_dev + self.st_rdev = stat.st_rdev + self.st_nlink = stat.st_nlink + self.st_uid = stat.st_uid + self.st_gid = stat.st_gid + self.st_size = overstat.st_size + self.st_atime = stat.st_atime + self.st_mtime = stat.st_mtime + self.st_ctime = stat.st_mtime + self.st_blocks = stat.st_blocks + self.st_blksize = stat.st_blksize + class FuseArchive(Fuse): def __init__(self, *args, **kw): @@ -168,8 +187,25 @@ class FuseArchive(Fuse): Fuse.__init__(self, *args, **kw) self.root = None + # Fix getattr and fgetattr to? def getattr(self, path): - return os.lstat("./tree" + path) + treefile = "./tree" + path + stats = os.lstat( treefile ) + + if os.path.isfile( treefile ): + print "Reading file to get size: " + path + + #pdb.set_trace() + + # Override size + inp = open( treefile ) + magic = pickle.load( inp ) + inp.close() + + print "Overridding getattr" + stats = FuseArchiveStat( stats, magic[ 'stat' ] ) + + return stats def readlink(self, path): return os.readlink("./tree" + path) -- cgit v0.10.2