public void FileInfo_Query_FileAlignmentInformation()
        {
            // Create a new file
            string fileName = this.fsaAdapter.ComposeRandomFileName(8, ".txt", CreateOptions.NON_DIRECTORY_FILE);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, $"1. Create a file {fileName}");

            FILEID        fileId;
            uint          treeId    = 0;
            ulong         sessionId = 0;
            MessageStatus status    = this.fsaAdapter.CreateFile(
                fileName,
                (FileAttribute)0,
                CreateOptions.NON_DIRECTORY_FILE,
                (FileAccess.GENERIC_READ | FileAccess.GENERIC_WRITE),
                (ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE | ShareAccess.FILE_SHARE_DELETE),
                CreateDisposition.OPEN_IF,
                out fileId,
                out treeId,
                out sessionId);

            this.fsaAdapter.AssertAreEqual(this.Manager,
                                           MessageStatus.SUCCESS,
                                           status,
                                           $"Create file with name {fileName} is expected to succeed.");

            long byteCount;

            byte[] outputBuffer;
            FileAlignmentInformation fileAlignmentInfo = new FileAlignmentInformation();
            uint outputBufferSize = (uint)TypeMarshal.ToBytes <FileAlignmentInformation>(fileAlignmentInfo).Length;

            BaseTestSite.Log.Add(LogEntryKind.TestStep, $"2. Query FileAlignmentInformation of the file {fileName}.");
            status = this.fsaAdapter.QueryFileInformation(
                FileInfoClass.FILE_ALIGNMENT_INFORMATION,
                outputBufferSize,
                out byteCount,
                out outputBuffer);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, $"3. Verify the query status and outputbuffer.");
            this.TestSite.Assert.AreEqual(
                MessageStatus.SUCCESS,
                status,
                $"Query FileAlignmentInformation of file {fileName} is expected to succeed.");

            // [MS-FSCC] section 2.4.3 AlignmentRequirement (4 bytes):  A 32-bit unsigned integer that MUST contain one of the following values.
            fileAlignmentInfo = TypeMarshal.ToStruct <FileAlignmentInformation>(outputBuffer);
            this.TestSite.Assert.AreEqual(
                Enum.IsDefined(typeof(AlignmentRequirement_Values), fileAlignmentInfo.AlignmentRequirement),
                true,
                $"AlignmentRequirement MUST contain one of AlignmentRequirement_Values. "
                );

            this.TestSite.Assert.AreEqual(
                byteCount,
                outputBufferSize,
                $"[MS-FSA] section 2.1.5.11.2: Upon successful completion of the operation, the object store MUST return: ByteCount set to sizeof(FileAlignmentInformation)."
                );
        }
Ejemplo n.º 2
0
 public FileAllInformation(byte[] buffer, int offset)
 {
     BasicInformation     = new FileBasicInformation(buffer, offset + 0);
     StandardInformation  = new FileStandardInformation(buffer, offset + 40);
     InternalInformation  = new FileInternalInformation(buffer, offset + 64);
     EaInformation        = new FileEaInformation(buffer, offset + 72);
     AccessInformation    = new FileAccessInformation(buffer, offset + 76);
     PositionInformation  = new FilePositionInformation(buffer, offset + 80);
     ModeInformation      = new FileModeInformation(buffer, offset + 88);
     AlignmentInformation = new FileAlignmentInformation(buffer, offset + 92);
     NameInformation      = new FileNameInformation(buffer, offset + 96);
 }
Ejemplo n.º 3
0
 public FileAllInformation()
 {
     BasicInformation     = new FileBasicInformation();
     StandardInformation  = new FileStandardInformation();
     InternalInformation  = new FileInternalInformation();
     EaInformation        = new FileEaInformation();
     AccessInformation    = new FileAccessInformation();
     PositionInformation  = new FilePositionInformation();
     ModeInformation      = new FileModeInformation();
     AlignmentInformation = new FileAlignmentInformation();
     NameInformation      = new FileNameInformation();
 }