diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2009-07-23 15:24:36 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2009-07-23 15:24:36 (GMT) |
commit | 3cf47419c9a6a548710f30a01e458ebdd64fc2e2 (patch) | |
tree | a10b697699aea1402dbd7d0b94943806089800e5 | |
parent | f0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12 (diff) | |
download | fusearchive-3cf47419c9a6a548710f30a01e458ebdd64fc2e2.zip fusearchive-3cf47419c9a6a548710f30a01e458ebdd64fc2e2.tar.gz fusearchive-3cf47419c9a6a548710f30a01e458ebdd64fc2e2.tar.bz2 |
Fix stat() to return proper size
-rwxr-xr-x | fusearchive.py | 40 |
1 files changed, 38 insertions, 2 deletions
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) |