Compartir a través de


3.2.4.6 Application Requests to Create or Overwrite a File

To create or overwrite a file on a remote share, the application provides the following:

  • The Client.TreeConnect representing the share within which to create the file.

  • The pathname of the file being created, relative to Client.TreeConnect.ShareName.

  • The Client.Session representing the security context of the user opening the file.

  • The requested access mode (read, write, and so on).

  • An optional Boolean indicating whether the attributes and time stamps of the file are to be returned in the response.

  • An optional Boolean indicating whether the total length of the file's extended attributes is to be returned in the response.

  • The share access for the created file.

  • The create disposition for the open.

  • An optional set of create options for the open.

  • An optional list of extended attributes.

  • An optional list of search attributes.

  • The request for an exclusive or batch OpLock, if any.

  • A Boolean indicating whether or not the file attribute data is to be returned in the response.

  • A Boolean indicating whether or not the parent directory of the target is to be opened.

  • An optional requested level of impersonation.

  • The security flags.

  • An optional allocation size.

  • An optional timeout value.

  • An optional security descriptor.

  • The print file mode Boolean.

To create the file, the client MUST issue one of the following command requests:

When opening a named pipe, the SMB_COM_NT_CREATE_ANDX command requires that the FileName field MUST contain only the relative name of the pipe; that is, the "\PIPE\" prefix MUST NOT be present. This is in contrast with other commands, such as SMB_COM_OPEN_ANDX and TRANS2_OPEN2, which require that the "\PIPE\" prefix be present in the path name.

Any of the commands or subcommands listed in this section can be used to create a file. Directories can also be created. Most of these commands provide the option to open or overwrite a file if it already exists. For SMB_COM_OPEN_ANDX (section 2.2.4.41) and TRANS2_OPEN2 (section 2.2.6.1) commands, the client MUST construct the AccessMode field of the request by translating the input parameters as specified in section 3.2.4.5.

In early dialects of the SMB Protocol the Open and Create operations were somewhat separate. In CIFS, there is considerable overlap between the set of commands used to open an existing file, the commands used to overwrite an existing file, and those used to create a new file.

The request MUST be sent to the server as described in section 3.2.4.1.