Im implementing NFS and almoste done but the RFC section 3.3.8 says this in its description:
mode
One of UNCHECKED, GUARDED, and EXCLUSIVE. UNCHECKED
means that the file should be created without checking
for the existence of a duplicate file in the same
directory. In this case, how.obj_attributes is a sattr3
describing the initial attributes for the file. GUARDED
specifies that the server should check for the presence
of a duplicate file before performing the create and
should fail the request with NFS3ERR_EXIST if a
duplicate file exists. If the file does not exist, the
request is performed as described for UNCHECKED.
EXCLUSIVE specifies that the server is to follow
exclusive creation semantics, using the verifier to
ensure exclusive creation of the target. No attributes
may be provided in this case, since the server may use
the target file metadata to store the createverf3
verifier.
so the question if UNCHECKED is the mode should i just set the length of the file to Zero or should i let the file be as it is? and if its a directory should i remove all the content?
I believe the idea of
CREATEwithUNCHECKEDis to apply the semantics of good old Unix system callcreat— so, truncation of a file’s existing contents (if any) is implied. However I cannot find this specified all that clearly in the docs (!).Trying to
CREATEan existing directory is an error in any case — there’s a separateMKDIRfor that (in NFS 3, the same applies to special files, withMKNOD—CREATEis now for regular, normal, plain good old files only!-)