private void FsCtl_Set_IntegrityInformation_WriteProtected(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Open file string fileToOpen = fileType == FileType.DataFile ? "ExistingFile.txt" : "ExistingFolder"; CreateOptions fileCreateOption = fileType == FileType.DataFile ? CreateOptions.NON_DIRECTORY_FILE : CreateOptions.DIRECTORY_FILE; BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Open " + fileToOpen); status = this.fsaAdapter.CreateFile( fileToOpen, FileAttribute.NORMAL, fileCreateOption, FileAccess.GENERIC_READ | FileAccess.GENERIC_WRITE, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.OPEN); string comment = string.Format("Open {0} is expected to success.", fileToOpen); this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, comment); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTStatus code."); if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { if (this.fsaAdapter.IsVolumeReadonly == true) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.MEDIA_WRITE_PROTECTED, status, "If Open.File.Volume.IsReadOnly is TRUE, the operation MUST be failed with STATUS_MEDIA_WRITE_PROTECTED."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "Status set to STATUS_SUCCESS."); } } }
private void FsCtl_Set_IntegrityInformation_UndefinedChecksumAlgorithm(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = (FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM)0x0003; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with undefined checksum algorithm 0x003."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTStatus code."); if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { if (this.fsaAdapter.ReFSVersion == 2) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "[MS-FSCC] section 2.3.57: for ReFS v2 any value except CHECKSUM_TYPE_NONE or CHECKSUM_TYPE_UNCHANGED will set the integrity value to a file-system-selected integrity mechanism and is not guaranteed to use the user specified checksum value."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_PARAMETER, status, "The operation MUST be failed with STATUS_INVALID_PARAMETER if InputBuffer.ChecksumAlgorithm is not one of the predefined values in [MS-FSCC] section 2.3.51."); } } }
private void FsCtl_Set_IntegrityInformation_IsIntegritySupported(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTStatus code."); if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "Integrity is supported, status set to STATUS_SUCCESS."); } }
private void FsCtl_Set_IntegrityInformation_ChecksumTypeNoneAndUnchanged(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with CHECKSUM_TYPE_NONE FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_NONE; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with CHECKSUM_TYPE_NONE."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); // Check if Integrity is supported if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER getIntegrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(getIntegrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify ChecksumAlgorithm getIntegrityInfo = TypeMarshal.ToStruct<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); bool isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_NONE); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify ChecksumAlgorithm."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_NONE."); //Step 5: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_UNCHANGED; inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION with CHECKSUM_TYPE_UNCHANGED."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 6: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 7: Verify ChecksumAlgorithm getIntegrityInfo = TypeMarshal.ToStruct<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_NONE); BaseTestSite.Log.Add(LogEntryKind.TestStep, "7. Verify ChecksumAlgorithm."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_NONE."); }
public void FsCtl_Set_IntegrityInformation_InvalidParameter_NonEmptyFile() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create DataFile"); status = this.fsaAdapter.CreateFile(FileType.DataFile); //Step 2: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION FSCTL_SET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); // Check if Integrity is supported if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER getIntegrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(getIntegrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify ChecksumAlgorithm is correctly set getIntegrityInfo = TypeMarshal.ToStruct<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); bool isChecksumTypeNone = (getIntegrityInfo.ChecksumAlgorithm == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify ChecksumAlgorithm is correctly set."); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumTypeNone, "ChecksumAlgorithm is CHECKSUM_TYPE_NONE."); //Step 5: Write some data so that the file is not empty long bytesWritten = 0; BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. Write some data so that the file is not empty."); status = this.fsaAdapter.WriteFile(0, 10240, out bytesWritten); //Step 6: FSCTL request FSCTL_SET_INTEGRITY_INFORMATION integrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_NONE; integrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.NONE; BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. FSCTL request FSCTL_SET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(integrityInfo, inputBufferSize); //Step 7: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "7. Verify returned NTStatus code."); this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "FSCTL_SET_INTEGRITY_INFORMATION request should succeed when change the checksum state of a non-empty file."); }
private void FsCtl_Get_IntegrityInformation_OutputValue_ChecksumEnforcement(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create file BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); status = this.fsaAdapter.CreateFile(fileType, true); //Step 2: FsCtlSetIntegrityInfo with CHECKSUM_ENFORCEMENT_OFF flag FSCTL_SET_INTEGRITY_INFORMATION_BUFFER setIntegrityInfo = new FSCTL_SET_INTEGRITY_INFORMATION_BUFFER(); setIntegrityInfo.Flags = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; setIntegrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_INTEGRITY_INFORMATION_BUFFER>(setIntegrityInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FsCtlSetIntegrityInfo with CHECKSUM_ENFORCEMENT_OFF flag."); status = this.fsaAdapter.FsCtlSetIntegrityInfo(setIntegrityInfo, inputBufferSize); if (!IsCurrentTransportSupportIntegrity(status)) return; if (this.fsaAdapter.IsIntegritySupported == false) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); return; } //Step 3: FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION FSCTL_GET_INTEGRITY_INFORMATION_BUFFER integrityInfo = new FSCTL_GET_INTEGRITY_INFORMATION_BUFFER(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(integrityInfo).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request with FSCTL_GET_INTEGRITY_INFORMATION."); status = this.fsaAdapter.FsCtlGetIntegrityInfo(outputBufferSize, out bytesReturned, out outputBuffer); //Step 4: Verify test result integrityInfo = TypeMarshal.ToStruct<FSCTL_GET_INTEGRITY_INFORMATION_BUFFER>(outputBuffer); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify CHECKSUM_ENFORCEMENT_OFF flag."); bool isChecksumEnforcementSet = ((integrityInfo.Flags & FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF) == FSCTL_GET_INTEGRITY_INFORMATION_BUFFER_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF); string streamType = (fileType == FileType.DataFile ? "DataStream" : "DirectoryStream"); string comment = string.Format("If Open.Stream.StreamType is {0} and Open.Stream.ChecksumEnforcementOff is TRUE, then the object store MUST set OutputBuffer.Flags to CHECKSUM_ENFORCEMENT_OFF.", streamType); this.fsaAdapter.AssertAreEqual(this.Manager, true, isChecksumEnforcementSet, comment); }