private bool FSInfo_Query_FileFsAttributeInformation_IsSupported(Smb2FunctionalClient client, uint treeId, FILEID fileId, FileSystemAttributes_Values attribute) { FileFsAttributeInformation fsAttributeInfo = new FileFsAttributeInformation(); byte[] buffer; client.QueryFSAttributes( treeId, (byte)FileSystemInformationClasses.FileFsAttributeInformation, fileId, out buffer, checker: (Packet_Header header, QUERY_INFO_Response response) => { BaseTestSite.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, header.Status, "Query File system should return STATUS_SUCCESS, the server returns with {0}", Smb2Status.GetStatusCode(header.Status)); } ); fsAttributeInfo = TypeMarshal.ToStruct <FileFsAttributeInformation>(buffer); return(fsAttributeInfo.FileSystemAttributes.HasFlag(attribute)); }
/// <summary> /// A utility for test supported features in FileFsAttributeInformation /// </summary> /// <param name="fileType">An Open of a DataFile or DirectoryFile.</param> /// <param name="fileSystemAttribute">FileSystemAttribute to test.</param> /// <param name="isSupported">Is true, the FileSystemAttribute will be treated as supported.</param> private void FsInfo_Query_FileFsAttributeInformation_IsSupported(FileType fileType, FileSystemAttributes_Values fileSystemAttribute, bool isSupported) { 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: Query FileFsAttributeInformation FileFsAttributeInformation fsAttributeInfo = new FileFsAttributeInformation(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. Query FileFsAttributeInformation"); status = this.fsaAdapter.QueryFileFsAttributeInformation(out fsAttributeInfo); bool actualResult = (fsAttributeInfo.FileSystemAttributes & fileSystemAttribute) == fileSystemAttribute; //Step 3: verify test result BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify if FileSystemAttributes flag is correctly set."); string feature = fileSystemAttribute.ToString(); string attribute = string.Format("FileSystemAttributes.{0}", fileSystemAttribute.ToString()); if (isSupported) { string comment = string.Format("{0} is supported and {1} MUST be set.", feature, attribute); this.fsaAdapter.AssertAreEqual(this.Manager, true, actualResult, comment); } else { string comment = string.Format("{0} is NOT supported and {1} MUST NOT be set.", feature, attribute); this.fsaAdapter.AssertAreEqual(this.Manager, false, actualResult, comment); } }