Beispiel #1
0
VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive)
{
    PCACHE_BLOCK    CacheBlock;

    TRACE("Dumping block list for BIOS drive 0x%x.\n", CacheDrive->DriveNumber);
    TRACE("BytesPerSector: %d.\n", CacheDrive->BytesPerSector);
    TRACE("BlockSize: %d.\n", CacheDrive->BlockSize);
    TRACE("CacheSizeLimit: %d.\n", CacheSizeLimit);
    TRACE("CacheSizeCurrent: %d.\n", CacheSizeCurrent);
    TRACE("CacheBlockCount: %d.\n", CacheBlockCount);

    CacheBlock = CONTAINING_RECORD(CacheDrive->CacheBlockHead.Flink, CACHE_BLOCK, ListEntry);
    while (&CacheBlock->ListEntry != &CacheDrive->CacheBlockHead)
    {
        TRACE("Cache Block: CacheBlock: 0x%x\n", CacheBlock);
        TRACE("Cache Block: Block Number: %d\n", CacheBlock->BlockNumber);
        TRACE("Cache Block: Access Count: %d\n", CacheBlock->AccessCount);
        TRACE("Cache Block: Block Data: 0x%x\n", CacheBlock->BlockData);
        TRACE("Cache Block: Locked In Cache: %d\n", CacheBlock->LockedInCache);

        if (CacheBlock->BlockData == NULL)
        {
            BugCheck("CacheBlock->BlockData == NULL\n");
        }

        CacheBlock = CONTAINING_RECORD(CacheBlock->ListEntry.Flink, CACHE_BLOCK, ListEntry);
    }
}
Beispiel #2
0
NTSTATUS
DfsCommonClose (
    IN PIRP_CONTEXT IrpContext,
    IN PIRP Irp
) {
    NTSTATUS Status;

    PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
    PFILE_OBJECT FileObject = IrpSp->FileObject;

    TYPE_OF_OPEN TypeOfOpen;
    PDFS_VCB Vcb;
    PDFS_FCB Fcb;

    BOOLEAN DontComplete = FALSE;
    BOOLEAN pktLocked;

    DfsDbgTrace(+1, Dbg, "DfsCommonClose: Entered\n", 0);

    DfsDbgTrace( 0, Dbg, "Irp          = %08lx\n", Irp);
    DfsDbgTrace( 0, Dbg, "->FileObject = %08lx\n", FileObject);


    //
    //  This action is a noop for unopened file objects.  Nothing needs
    //  to be done for FS device opens, either.
    //

    TypeOfOpen = DfsDecodeFileObject( FileObject, &Vcb, &Fcb);
    if (TypeOfOpen == UnopenedFileObject ||
        TypeOfOpen == FilesystemDeviceOpen ) {

        DfsDbgTrace(-1, Dbg, "DfsCommonClose:  Filesystem file object\n", 0);
        DfsCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
        return STATUS_SUCCESS;
    }

    try {

        //
        //  Case on the type of open that we are trying to close.
        //

        switch (TypeOfOpen) {

        case LogicalRootDeviceOpen:

            DfsDbgTrace(0, Dbg, "DfsCommonClose: Close LogicalRootDevice\n", 0);

            ExInterlockedDecrementLong(&Vcb->DirectAccessOpenCount, &DfsData.DfsLock);
            ExInterlockedDecrementLong(&Vcb->OpenFileCount, &DfsData.DfsLock);

            if (Vcb->VcbState & VCB_STATE_FLAG_LOCKED) {
                ASSERT (Vcb->FileObjectWithVcbLocked == FileObject);
                Vcb->VcbState &= ~VCB_STATE_FLAG_LOCKED;
                Vcb->FileObjectWithVcbLocked = NULL;
            }

            try_return( Status = STATUS_SUCCESS );

        case RedirectedFileOpen:

            DfsDbgTrace(0, Dbg, "DfsCommonClose:  File -> %wZ\n", &Fcb->FullFileName);

            //
            //  Decrement the OpenFileCount for the Vcb through which this
            //  file was opened.
            //

            ExInterlockedDecrementLong(&Vcb->OpenFileCount, &DfsData.DfsLock);

            //
            //  Decrement the RefCount on the DFS_MACHINE_ENTRY through which
            //  this file was opened
            //

            PktAcquireExclusive( TRUE, &pktLocked );

            ExAcquireResourceExclusive( &DfsData.Resource, TRUE );

            DfsDecrementMachEntryCount(Fcb->DfsMachineEntry, TRUE);

            ExReleaseResource( &DfsData.Resource );

            PktRelease();


            //
            //  Close the redirected file by simply passing through
            //  to the redirected device.  We detach the DFS_FCB from the
            //  file object before the close so it cannot be looked
            //  up in some other thread.
            //

            DfsDetachFcb( FileObject, Fcb);
            Status = DfsFilePassThrough(Fcb, Irp);

            DontComplete = TRUE;

            DfsDeleteFcb( IrpContext, Fcb );

            break;

        default:
            BugCheck("Dfs close, unexpected open type");
        }

        Status = STATUS_SUCCESS;

    try_exit: NOTHING;

    } finally {

        //
        //  If this is a normal termination, then complete the request.
        //  Even if we're not to complete the IRP, we still need to
        //  delete the IRP_CONTEXT.
        //

        if (!AbnormalTermination()) {
            if (DontComplete) {
                DfsCompleteRequest( IrpContext, NULL, 0 );
            } else {
                DfsCompleteRequest( IrpContext, Irp, Status );
            }
        }

        DfsDbgTrace(-1, Dbg, "DfsCommonClose:  Exit -> %08lx\n", Status);
    }
    return Status;
}