2.1.5.10.41 FSCTL_SIS_COPYFILE

The server provides:

  • Open: An Open of a DataStream or DirectoryStream.

  • InputBuffer: An array of bytes containing a single SI_COPYFILE structure indicating the source and destination files to copy, as specified in [MS-FSCC] section 2.3.89.

  • InputBufferSize: The number of bytes in InputBuffer.

On completion, the object store MUST return:

  • Status: An NTSTATUS code that specifies the result.

This routine uses the following local variables:

  • Opens: SourceOpen, DestinationOpen

The purpose of this operation is to make it look like a copy from the source file to the destination file has occurred when in reality no data is actually copied. This operation modifies the source file in such a way that the clusters associated with it can be shared across multiple files. The destination file is created and modified to point at the same shared clusters that the source file points to.<143>

Support for Single Instance Storage is optional. If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.<144>

Pseudocode for the operation is as follows:

  • If Open.IsAdministrator is FALSE, the operation MUST be failed with STATUS_ACCESS_DENIED.

  • If InputBufferSizes is less than sizeof(SI_COPYFILE), the operation MUST be failed with STATUS_INVALID_PARAMETER_1.

  • If InputBuffer.Flags contains any flags besides COPYFILE_SIS_LINK and COPYFILE_SIS_REPLACE, the operation MUST be failed with STATUS_INVALID_PARAMETER_2.

  • If InputBuffer.SourceFileNameLength or InputBuffer.DestinationFileNameLength is <= zero, the operation MUST be failed with STATUS_INVALID_PARAMETER_3.

  • If InputBuffer.SourceFileNameLength or InputBuffer.DestinationFileNameLength is > MAXUSHORT (0xffff), the operation MUST be failed with STATUS_INVALID_PARAMETER.

  • If FieldOffset(InputBuffer.SourceFileName) + InputBuffer.SourceFileNameLength + InputBuffer.DestinationFileNameLength is > InputBufferSize, the operation MUST be failed with STATUS_INVALID_PARAMETER_4.

  • SourceOpen set to the Open returned from a successful call to open a file as defined in section 2.1.5.1, setting the algorithm's parameters as follows:

    • RootOpen: Set to Open.RootOpen.

    • PathName: Set to InputBuffer.SourceFileName.

    • SecurityContext: Set to empty.<145>

    • DesiredAccess: Set to GENERIC_READ.

    • ShareAccess: If the source file is already controlled by SIS (meaning the source file already has a reparse point of type IO_REPARSE_TAG_SIS), then set to FILE_SHARE_READ, else set to zero.

    • CreateOptions: Set To FILE_NON_DIRECTORY_FILE | FILE_NO_INTERMEDIATE_BUFFERING.

    • CreateDisposition: Set to FILE_OPEN.

    • DesiredFileAttributes: Set to FILE_ATTRIBUTE_NORMAL.

    • IsCaseInsensitive: Set to TRUE.

    • TargetOplockKey: Set to Empty.

  • If the request fails, this operation MUST be failed with the returned STATUS.

  • The operation MUST be failed with STATUS_OBJECT_TYPE_MISMATCH under any of the following conditions:

    • If SourceOpen.File.LinkList contains more than one entry (meaning this file has hardlinks).

    • If SourceOpen.Stream.IsEncrypted is TRUE.

    • If SourceOpen.File.ReparseTag is empty or is not IO_REPARSE_TAG_SIS (as defined in [MS-FSCC] section 2.1.2.1) and InputBuffer.Flags.COPYFILE_SIS_LINK is TRUE.

  • If SourceOpen.File.ReparseTag is not empty and is not IO_REPARSE_TAG_SIS, the operation MUST be failed with STATUS_INVALID_PARAMETER.

  • DestinationOpen set to the Open returned from a successful call to create a file as defined in section 2.1.5.1, setting the algorithm's parameters as follows:

    • RootOpen: Set to Open.RootOpen.

    • PathName: Set to InputBuffer.DestinationFileName.

    • SecurityContext: Set to empty.<146>

    • DesiredAccess: Set to GENERIC_READ | GENERIC_WRITE | DELETE.

    • ShareAccess: Set to zero.

    • CreateOptions: Set to FILE_NON_DIRECTORY_FILE.

    • CreateDisposition: If InputBuffer.Flags.COPYFILE_SIS_REPLACE is TRUE, set to FILE_OVERWRITE_IF, else set to FILE_CREATE.

    • DesiredFileAttributes: Set to FILE_ATTRIBUTE_NORMAL.

    • IsCaseInsensitive: Set to TRUE.

    • TargetOplockKey: Set to Empty.

  • If the request fails, this operation MUST be failed with the returned STATUS.

  • If SourceOpen.File.Volume is not equal to DestinationOpen.File.Volume is not equal to Open.File.Volume, the operation MUST be failed with STATUS_NOT_SAME_DEVICE.

  • Share the clusters between the source and destination file.<147>

  • DestinationOpen.ReparseTag set to IO_REPARSE_TAG_SIS.

  • Upon successful completion of the operation, the object store MUST return:

    • Status set to STATUS_SUCCESS.