From: Robie B. <rb-...@ju...> - 2008-08-27 16:49:56
|
Could someone commit the patch below please? If you open a file to write but not append or truncate, then it appends anyway, thus writing data to the wrong place. This is due to an incorrect boolean test. To reproduce: $ echo abcdef > a $ cat a abcdef $ python Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> f = os.open('a', os.O_WRONLY) >>> f 3 >>> os.write(f, 'ghi') 3 >>> os.close(f) >>> $ cat a abcdef ghi Except that it should say "ghidef". I've tested and the behaviour is what I expect on a non-FUSE filesystem but is incorrect with FUSE and xmp.py. --- xmp.py.orig 2008-08-27 17:35:48.000000000 +0100 +++ xmp.py 2008-08-27 17:35:57.000000000 +0100 @@ -33,7 +33,7 @@ md = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'} 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 |