Commit 930a94dd by rfkelly0

fs.expose.fuse: fix opening of files with mode "w+"

parent 4a459983
...@@ -890,8 +890,6 @@ class FS(object): ...@@ -890,8 +890,6 @@ class FS(object):
def flags_to_mode(flags): def flags_to_mode(flags):
"""Convert an os.O_* flag bitmask into an FS mode string.""" """Convert an os.O_* flag bitmask into an FS mode string."""
if flags & os.O_EXCL:
raise UnsupportedError("open",msg="O_EXCL is not supported")
if flags & os.O_WRONLY: if flags & os.O_WRONLY:
if flags & os.O_TRUNC: if flags & os.O_TRUNC:
mode = "w" mode = "w"
...@@ -908,4 +906,6 @@ def flags_to_mode(flags): ...@@ -908,4 +906,6 @@ def flags_to_mode(flags):
mode = "r+" mode = "r+"
else: else:
mode = "r" mode = "r"
if flags & os.O_EXCL:
mode += "x"
return mode return mode
...@@ -165,7 +165,10 @@ class FSOperations(Operations): ...@@ -165,7 +165,10 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def create(self, path, mode, fi): def create(self, path, mode, fi):
path = path.decode(NATIVE_ENCODING) path = path.decode(NATIVE_ENCODING)
fh = self._reg_file(self.fs.open(path,"w"),path) # FUSE doesn't seem to pass correct mode information here - at least,
# I haven't figured out how to distinguish between "w" and "w+".
# Go with the most permissive option.
fh = self._reg_file(self.fs.open(path,"w+"),path)
fi.fh = fh fi.fh = fh
fi.keep_cache = 0 fi.keep_cache = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment