private void FsCtl_Get_Compression_IsCompressionSupported(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 with FSCTL_GET_COMPRESSION FSCTL_GET_COMPRESSION_Reply compressionReply = new FSCTL_GET_COMPRESSION_Reply(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_GET_COMPRESSION_Reply>(compressionReply).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. FSCTL request with FSCTL_GET_COMPRESSION"); status = this.fsaAdapter.FsCtlGetCompression(outputBufferSize, out bytesReturned, out outputBuffer); //Step 3: Verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify returned NTSTATUS code."); // 2.1.5.9.7 FSCTL_GET_COMPRESSION // <64> Section 2.1.5.9.7: This is only implemented by the NTFS and ReFS file systems. if (this.fsaAdapter.FileSystem == FileSystem.NTFS || this.fsaAdapter.FileSystem == FileSystem.REFS) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "FSCTL_GET_COMPRESSION is supported, status set to STATUS_SUCCESS."); } else { 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."); } }
private void AlternateDataStream_FsCtl_Get_Compression(FileType fileType) { //Prerequisites: Create streams on a newly created file //Step 1: FSCTL request with FSCTL_SET_COMPRESSION FSCTL_SET_COMPRESSION_Request setCompressionRequest = new FSCTL_SET_COMPRESSION_Request(); setCompressionRequest.CompressionState = FSCTL_SET_COMPRESSION_Request_CompressionState_Values.COMPRESSION_FORMAT_DEFAULT; uint inputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_SET_COMPRESSION_Request>(setCompressionRequest).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. FSCTL request with FSCTL_SET_COMPRESSION", ++testStep); status = this.fsaAdapter.FsCtlSetCompression(setCompressionRequest, inputBufferSize); if (this.fsaAdapter.IsCompressionSupported == false) { if (this.fsaAdapter.FileSystem == FileSystem.REFS) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.NOT_SUPPORTED, status, ("For ReFS, it is only supported and returns STATUS_SUCCESS when CompressionState is set to COMPRESSION_FORMAT_NONE. " + "The method fails with STATUS_NOT_SUPPORTED for any other value of CompressionState.")); } else { 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 (fileType == FileType.DirectoryFile && this.fsaAdapter.FileSystem == FileSystem.CSVFS) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.ACCESS_DENIED, status, "CSVFS does not support setting compressed attribute on the folders."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "COMPRESSION is supported, status set to STATUS_SUCCESS."); } } //Step 2: FSCTL request with FSCTL_GET_COMPRESSION FSCTL_GET_COMPRESSION_Reply compressionReply = new FSCTL_GET_COMPRESSION_Reply(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FSCTL_GET_COMPRESSION_Reply>(compressionReply).Length; long bytesReturned; byte[] outputBuffer = new byte[0]; BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. FSCTL request with FSCTL_GET_COMPRESSION", ++testStep); status = this.fsaAdapter.FsCtlGetCompression(outputBufferSize, out bytesReturned, out outputBuffer); // 2.1.5.9.7 FSCTL_GET_COMPRESSION // <64> Section 2.1.5.9.7: This is only implemented by the NTFS and ReFS file systems. if (this.fsaAdapter.FileSystem == FileSystem.NTFS || this.fsaAdapter.FileSystem == FileSystem.REFS) { this.fsaAdapter.AssertAreEqual(this.Manager, MessageStatus.SUCCESS, status, "FSCTL_GET_COMPRESSION is supported, status set to STATUS_SUCCESS."); compressionReply = TypeMarshal.ToStruct<FSCTL_GET_COMPRESSION_Reply>(outputBuffer); // [MS-FSCC] 2.3.49 FSCTL_SET_COMPRESSION Request // <39> Section 2.3.49: Equivalent to COMPRESSION_FORMAT_LZNT1. this.fsaAdapter.AssertAreEqual(this.Manager, CompressionState_Values.COMPRESSION_FORMAT_LZNT1, compressionReply.CompressionState, "FSCTL_GET_COMPRESSION.CompressionState should match with what has been assigned to the file."); } else { 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."); } }