Compartilhar via


3.2.4.15 Application Requests Writing to a File, Named Pipe, or Device

The application provides:

  • A valid Client.Open, representing the file to which the application attempts to write.

  • An offset, in bytes and relative to the start of the file, marking the location within the file where the application attempts to write.

  • The data and the number of bytes to be written.

  • Whether or not the write is to be done in write-through mode.

  • An optional time-out value, in milliseconds, designating how long to wait for the write to complete.

CIFS provides several commands for writing data to a file, named pipe, or device. These are:

  • SMB_COM_WRITE (section 2.2.4.12) (deprecated)

    The client MUST construct an SMB_COM_WRITE Request (section 2.2.4.12.1) message as defined in section 2.2.4.12.1. This command provides the basic Write operation.

  • SMB_COM_WRITE_AND_UNLOCK (section 2.2.4.21) (deprecated)

    This command is used to write to a locked byte range in the file and then unlock the range. The application MAY provide an indication of the number of additional bytes immediately following the bytes written and unlocked that it attempts to write. The byte range to be written MUST be locked prior to writing. The client MUST construct the SMB_COM_WRITE_AND_UNLOCK Request (section 2.2.4.21.1) as defined in section 2.2.4.21.1.

  • SMB_COM_WRITE_RAW (section 2.2.4.25) (deprecated)

    The client MUST construct an SMB_COM_WRITE_RAW Request (section 2.2.4.25.1). The behavior of the SMB_COM_WRITE_RAW Request (section 2.2.4.25.1) is described in section 3.2.4.15.1.

  • SMB_COM_WRITE_MPX (section 2.2.4.23) (obsolescent)

    The client MUST construct an SMB_COM_WRITE_MPX Request (section 2.2.4.23.1) as defined in section 2.2.4.26.1. The behavior of the SMB_COM_WRITE_MPX Request (section 2.2.4.23.1) is described in section 3.2.4.15.2.

  • SMB_COM_WRITE_AND_CLOSE (section 2.2.4.40) (deprecated)

    The client MUST construct an SMB_COM_WRITE_AND_CLOSE (section 2.2.4.40) command as defined in section 2.2.4.40.1. This command has the effect of writing to a range of bytes and then closing the file associated with the supplied FID. This command behaves identically to an SMB_COM_WRITE (section 2.2.4.12) command followed by an SMB_COM_CLOSE (section 2.2.4.5) command.

  • SMB_COM_WRITE_ANDX (section 2.2.4.43)

    The client MUST construct an SMB_COM_WRITE_ANDX Request (section 2.2.4.43.1) message as defined in section 2.2.4.43.1, with the following additional requirements:

    • If the client uses a 64-bit offset value, SMB_Parameters.WordCount MUST be set to 0x0E and the SMB_Parameters.Words.Offset and SMB_Parameters.Words.OffsetHigh fields MUST be set to the lower 32 bits and the higher 32 bits, respectively, of the supplied offset value.

    • If the client uses a 32-bit offset value, SMB_Parameters.WordCount MUST be set to 0x0C, the SMB_Parameters.Words.Offset field MUST be assigned the offset value supplied by the application, and the SMB_Parameters.Words.OffsetHigh field MUST NOT be included in the request.

    • The SMB_Parameters.Words.WriteMode field MUST reflect any behavior that the application requests from the server. See the description of the WriteMode field in section 2.2.4.25.1.

    • The SMB_Parameters.Words.DataLength field MUST be set to the length, in bytes, of the data to be written.

    • The SMB_Parameters.Words.DataOffset field MUST be set to the offset, in bytes and relative to the start of the SMB Header block, of the data to be written to the file.

    • The SMB_Data.Bytes.Pad field MUST contain padding bytes used to align the SMB_Data.Bytes.Data field to an appropriate boundary.

    • The SMB_Data.Bytes.Data field MUST contain the data to be written.

    • If the write is to a named pipe, and if the write spans multiple requests, the client SHOULD set the SMB_Parameters.Words.Remaining field to the number of bytes remaining to be written and MUST set the RAW_MODE bit in the SMB_Parameters.Words.WriteMode field. For the first write request the client MUST set the MSG_START bit in the SMB_Parameters.Words.WriteMode field.<206>

      If the application writes to a named pipe or device and if a time-out value is supplied, the SMB_Parameters.Words.Timeout field MUST be assigned the value supplied by the application. Otherwise, it MUST be set to 0x00000000.

  • SMB_COM_WRITE_PRINT_FILE (deprecated)

    This command is used to write data to an open print queue spool file. The first data written to the print file MUST be printer-specific control data. The length of the control data block MUST be specified in the SMB_Parameters.Words.SetupLength field. A single SMB_COM_WRITE_PRINT_FILE command can contain both printer-specific control data and print file data, as long as the control data is completely written first.

    The client MUST construct an SMB_COM_WRITE_PRINT_FILE request message as defined in section 2.2.4.68.1.

  • TRANS_RAW_WRITE_NMPIPE

    The client MUST construct the TRANS_RAW_WRITE_NMPIPE subcommand as defined in section 2.2.5.7. The request MUST be transported to the server using the Transaction subprotocol. TRANS_RAW_WRITE_NMPIPE allows for a raw write of data to a named pipe. This method of writing data to a named pipe ignores message boundaries even if the pipe was set up as a message mode pipe.

  • TRANS_WRITE_NMPIPE

    The client MUST construct the TRANS_WRITE_NMPIPE subcommand as defined in section 2.2.5.9.1. The request MUST be transported to the server using the Transaction subprotocol. TRANS_WRITE_NMPIPE allows data to be written to a named pipe in the mode set on the named pipe. If the named pipe is in message mode, this subcommand MUST write a message from the pipe.

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