rivenz / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

mode information for fuse create call #108

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
the following code (with comment) is in the fuse wrapper:

    def create(self, path, mode, fi):
        path = path.decode(NATIVE_ENCODING)
        # 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,"wb+"),path)
        fi.fh = fh
        fi.keep_cache = 0

so, mode is the python name, but you're really interested in fi.flags, i think. 
if you switch on fi.flags like you do in calls to open you should be okay.

secondly, this method does not support O_EXCL opens, which breaks things like 
using the filesystem for locking.

Original issue reported on code.google.com by jtolds on 26 Jan 2012 at 10:05

GoogleCodeExporter commented 8 years ago
> so, mode is the python name, but you're really interested in fi.flags, i 
think.
> if you switch on fi.flags like you do in calls to open you should be okay.

Hmm, right you are.  I tried it and it still passes all the tests - wonder why 
I didn't do that in the first place?  Anyway, fixed in trunk.

> secondly, this method does not support O_EXCL opens, which breaks things
> like using the filesystem for locking.

I'd like to support this but AFAIK we don't offer any such functionality 
through the PyFilesystem API.

Original comment by rfkel...@gmail.com on 27 Jan 2012 at 6:58

GoogleCodeExporter commented 8 years ago
so, in base.py:flags_to_mode, it appears you recently started explicitly 
rejecting O_EXCL, but i don't see any reason not to just pass an x in the mode 
string through, even if it's nonstandard. 

i realize a design goal is to support as many filesystems and operating systems 
as possible, but i don't think it's necessary to deliberately implement only 
the least common denominator to do so. it would be nice to pass things through 
to the fs.base.FS implementation if that specific feature is supported by it.

fwiw, you will only have to deal with O_EXCL on fuse 'create' calls. a normal 
open will never see it.

Original comment by jtolds on 27 Jan 2012 at 5:05