aboutsummaryrefslogtreecommitdiffstats
path: root/fusearchive.py
diff options
context:
space:
mode:
Diffstat (limited to 'fusearchive.py')
-rwxr-xr-xfusearchive.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 2b06e0e..25fc046 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -343,8 +343,8 @@ class FuseArchive(Fuse):
# init rw and offset
self.offset = 0
- self.read = False
- self.write = False
+ self.rd = False
+ self.wr = False
self.size = 0
# This is the current in-memory chunk and offset in to data[]
@@ -357,13 +357,19 @@ class FuseArchive(Fuse):
self.chunks = []
# TODO: Better flag handling here?
- md = flag2mode( flags )
- if re.match( '^r', md ):
- self.read = True
- elif re.match( '^w', md ):
- self.write = True
- elif re.match( '^a', md ):
- self.write = True
+ if flags | os.O_RDONLY:
+ self.rd = True
+
+ if flags | os.O_RDWR:
+ self.rd = True
+ self.wr = True
+
+ if flags | os.O_WRONLY:
+ self.wr = True
+
+ if flags | os.O_APPEND:
+ self.wr = True
+ # TODO: handle offset -1
self.offset = -1
if os.path.exists( "./tree" + self.orig_path ):
@@ -379,14 +385,14 @@ class FuseArchive(Fuse):
self.chunks = magic[ 'chunks' ]
self.chunk_size = magic[ 'chunk_size' ]
else:
- if re.match( '(a|w)', flag2mode( flags ) ):
+ if self.wr:
dmsg( 2, "File doesn't exist and we're going to write, creating temp empty file" )
self.flush()
self.direct_io = False
self.keep_cache = False
- pdb.set_trace()
+ #pdb.set_trace()
dmsg( 3, str(self) + " init complete" )
def _load_chunk( self, index ):
@@ -448,7 +454,7 @@ class FuseArchive(Fuse):
buf_offset = 0
buf_len = len(buf)
- dmg( 3, "Length: " + str( buf_len ) )
+ dmsg( 3, "Length: " + str( buf_len ) )
while( buf_offset < buf_len ):
dmsg( 3, "Pulling in chunk for writing" )
self._load_chunk( index )
@@ -470,7 +476,7 @@ class FuseArchive(Fuse):
self.flush()
def _fflush(self):
- if self.write:
+ if self.wr:
dmsg( 3, "_fflush!" )
# Save our main data
out = gzip.open( "./tree" + self.orig_path, "w" )
@@ -512,7 +518,7 @@ class FuseArchive(Fuse):
def lock(self, cmd, owner, **kw):
dmsg( 3, "WARNING: locking unsupported" )
- return
+ return 1
# The code here is much rather just a demonstration of the locking
# API than something which actually was seen to be useful.