From: robk-tahoe Date: Wed, 7 May 2008 23:42:20 +0000 (-0700) Subject: tahoefuse: fix typo which could cause data corruption X-Git-Tag: allmydata-tahoe-1.1.0~149 X-Git-Url: https://git.rkrishnan.org/pf/content/%22file:/statistics?a=commitdiff_plain;h=abae0345adb03033d28052fd34191a4c4632364a;p=tahoe-lafs%2Ftahoe-lafs.git tahoefuse: fix typo which could cause data corruption a typo in the 'flags2mode' code would wind up passing the O_APPEND flag into the os open() call, which would cause the file to be opened in 'strict append' mode, i.e. all writes extend the file, regardless of calls to seek. this causes a problem for tahoefuse in that the seek() calls made to filehandles open through fuse would be ignored when write()s occurred. this was evidenced by corruption seen when using rsync. it turns out that rsync actually makes overlapping writes in some cases, i.e. even when writing a new fresh file out, it still doesn't write a simple contiguous span of data, but will make writes overlapping data already written. this is probably related to the way it manages data blocks internally for rolling checksums etc. at any rate, this bug would thus cause rsync in those cases to write a chunk of duplicate data into the file - leading to tahoe securely and reliably storing the wrong data. fixing this, so that non-append file opens do not pass O_APPEND seems to eliminate this problem. --- diff --git a/mac/tahoefuse.py b/mac/tahoefuse.py index 5fce5d44..e0d6f3a5 100644 --- a/mac/tahoefuse.py +++ b/mac/tahoefuse.py @@ -65,7 +65,7 @@ def flag2mode(flags): md = {os.O_RDONLY: 'rb', os.O_WRONLY: 'wb', os.O_RDWR: 'w+b'} m = md[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)] - if flags | os.O_APPEND: + if flags & os.O_APPEND: m = m.replace('w', 'a', 1) return m