|
From: Guido V. <pir...@ya...> - 2006-01-18 22:57:11
|
Thank you Miklos for you prompt replies! Miklos Szeredi writes: [...] > Note: you don't have to implement the 'create' call, it is completely > optional. If you don't implement it, everything will work exactly the > same way as before. > > For some filesystems it is useful to have an atomic create+open call > (e.g. sshfs), but other filesystems may not need it. Yes, I know, but I'm happy if I can have something slightly more optimized :-) [...] >> - `truncate' and `open' (why not `open' and `ftruncate'?) are used when the >> file is already existing. > > The order should not matter, but this is the order that the Linux > kernel does it. Ok, I was just curious. > A little correction: > > all the above is true for the current implementation, BUT it may > change in the future, in that create() may be called for the case when > the file already exists. Ok, so I'll have to check if the file is already existing before doing my only-on-creation-action. > So if the filesystem implements the create() method, it should > implement with the semantics of open(), where the open flags always > contain O_CREAT, and NOT like creat(). I did not understand this sentence: creat() is equal an open() with the O_CREAT (and the O_TRUNC) flag. So here is a new question: in the future, should the implementation change so that create() will be called when the file already exists, what will happen in this case? Will the file be truncated? If it will, we'll be able to use creat() (which is open() with O_CREAT and O_TRUNC), otherwise we'll have to use open() with O_CREAT and without O_TRUNC. > Miklos Good bye, Guido |