diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2009-07-22 22:14:25 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2009-07-22 22:14:25 (GMT) |
commit | 3b1dc7c5cf93092da7d07c4522424f85ee6c351b (patch) | |
tree | a841f563f47639f15f5ff83aea4416aa0594b91b | |
parent | b2b477b6810931c4c1bb3c911e9a20f248cb1451 (diff) | |
download | fusearchive-3b1dc7c5cf93092da7d07c4522424f85ee6c351b.zip fusearchive-3b1dc7c5cf93092da7d07c4522424f85ee6c351b.tar.gz fusearchive-3b1dc7c5cf93092da7d07c4522424f85ee6c351b.tar.bz2 |
Basic file ops work, permissions still not preserved
-rwxr-xr-x | fusearchive.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/fusearchive.py b/fusearchive.py index 24beeeb..b427a5f 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -7,16 +7,12 @@ # See the file COPYING. # -import os, sys +import os, sys, shutil, fcntl, fuse, re, tempfile from errno import * from stat import * -import shutil -import fcntl -import fuse -import re -import tempfile from fuse import Fuse +import pdb if not hasattr(fuse, '__version__'): raise RuntimeError, \ @@ -151,19 +147,30 @@ class FuseArchive(Fuse): print "Init file: " + path self.orig_path = path; ( fdnum, self.tmp_name ) = tempfile.mkstemp(); - os.close( fdnum ); + #os.close( fdnum ); - if os.path.exists( ".tree/" + self.orig_path ): - shutil.copy( ".tree/" + path, self.tmp_name ) + if os.path.exists( "./tree" + self.orig_path ): + shutil.copy( "./tree" + path, self.tmp_name ) print "Shadow file: " + self.tmp_name + " for " + self.orig_path - self.file = os.fdopen( os.open( self.tmp_name, flags, *mode), - flag2mode(flags)) + print "Going to open shadow file with flags: " + str(flags) + " mode " + str(mode) + # pdb.set_trace() + print "Flag2mode is: " + str( flag2mode( flags ) ) + + # Just use the fdnum they gave us instead of reopening it, + # since that might fail + # fdnum = os.open( self.tmp_name, flags, *mode ) + #print "Got fdnum: " + str(fdnum) + self.file = os.fdopen( fdnum, flag2mode( flags ) ) + print "Open" + self.fd = self.file.fileno() self.direct_io = False self.keep_cache = False + print str(self) + " init complete" + def read(self, length, offset): print "Reading from " + self.orig_path self.file.seek(offset) @@ -183,7 +190,8 @@ class FuseArchive(Fuse): print "Copying working file back to storage: " + \ self.tmp_name + " -> " + self.orig_path - shutil.copy( self.tmp_name, ".tree/" + self.orig_path ); + #pdb.set_trace() + shutil.copy( self.tmp_name, "./tree" + self.orig_path ); print "Deleting old file: " + self.tmp_name os.unlink( self.tmp_name ); |