本文整理汇总了C++中DebugUnwind函数的典型用法代码示例。如果您正苦于以下问题:C++ DebugUnwind函数的具体用法?C++ DebugUnwind怎么用?C++ DebugUnwind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DebugUnwind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FatCommonQueryVolumeInfo
//.........这里部分代码省略.........
(VOID) FatDecodeFileObject( IrpSp->FileObject, &Vcb, &Fcb, &Ccb );
ASSERT( Vcb != NULL );
try {
//
// Make sure the vcb is in a usable condition. This will raise
// and error condition if the volume is unusable
//
// Also verify the Root Dcb since we need info from there.
//
FatVerifyFcb( IrpContext, Vcb->RootDcb );
//
// Based on the information class we'll do different actions. Each
// of the procedures that we're calling fills up the output buffer
// if possible and returns true if it successfully filled the buffer
// and false if it couldn't wait for any I/O to complete.
//
switch (FsInformationClass) {
case FileFsVolumeInformation:
//
// This is the only routine we need the Vcb shared because of
// copying the volume label. All other routines copy fields that
// cannot change or are just manifest constants.
//
if (!FatAcquireSharedVcb( IrpContext, Vcb )) {
DebugTrace(0, Dbg, "Cannot acquire Vcb\n", 0);
Status = FatFsdPostRequest( IrpContext, Irp );
IrpContext = NULL;
Irp = NULL;
} else {
WeAcquiredVcb = TRUE;
Status = FatQueryFsVolumeInfo( IrpContext, Vcb, Buffer, &Length );
}
break;
case FileFsSizeInformation:
Status = FatQueryFsSizeInfo( IrpContext, Vcb, Buffer, &Length );
break;
case FileFsDeviceInformation:
Status = FatQueryFsDeviceInfo( IrpContext, Vcb, Buffer, &Length );
break;
case FileFsAttributeInformation:
Status = FatQueryFsAttributeInfo( IrpContext, Vcb, Buffer, &Length );
break;
case FileFsFullSizeInformation:
Status = FatQueryFsFullSizeInfo( IrpContext, Vcb, Buffer, &Length );
break;
default:
Status = STATUS_INVALID_PARAMETER;
break;
}
//
// Set the information field to the number of bytes actually filled in.
//
if (Irp != NULL) {
Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length;
}
} finally {
DebugUnwind( FatCommonQueryVolumeInfo );
if ( WeAcquiredVcb ) { FatReleaseVcb( IrpContext, Vcb ); }
if (!AbnormalTermination()) {
FatCompleteRequest( IrpContext, Irp, Status );
}
DebugTrace(-1, Dbg, "FatCommonQueryVolumeInfo -> %08lx\n", Status);
}
return Status;
}
示例2: LfsReadLogRecord
//.........这里部分代码省略.........
//
if (Lfcb == NULL) {
ExRaiseStatus( STATUS_ACCESS_DENIED );
}
//
// Check that the client Id is valid.
//
LfsValidateClientId( Lfcb, Lch );
//
// Check that the given Lsn is in the legal range for this client.
//
ClientRecord = LfsAdd2Ptr( Lfcb->ClientArray,
Lch->ClientArrayByteOffset,
PLFS_CLIENT_RECORD );
if (!LfsVerifyClientLsnInRange( Lfcb, ClientRecord, FirstLsn )) {
ExRaiseStatus( STATUS_DISK_CORRUPT_ERROR );
}
//
// We can give up the Lfcb as we know the Lsn is within the file.
//
LfsReleaseLch( Lch );
//
// Allocate and initialize a context structure.
//
LfsAllocateLcb( &Lcb );
LfsInitializeLcb( Lcb,
Lch->ClientId,
ContextMode );
//
// Find the log record indicated by the given Lsn.
//
LfsFindLogRecord( Lfcb,
Lcb,
FirstLsn,
RecordType,
TransactionId,
UndoNextLsn,
PreviousLsn,
BufferLength,
Buffer );
//
// Update the client's arguments.
//
*Context = Lcb;
Lcb = NULL;
} finally {
DebugUnwind( LfsReadLogRecord );
//
// Release the log file control block if held.
//
LfsReleaseLch( Lch );
//
// Deallocate the context block if an error occurred.
//
if (Lcb != NULL) {
LfsDeallocateLcb( Lcb );
}
LfsDebugTrace( 0, Dbg, "Context -> %08lx\n", *Context );
LfsDebugTrace( 0, Dbg, "Buffer Length -> %08lx\n", *BufferLength );
LfsDebugTrace( 0, Dbg, "Buffer -> %08lx\n", *Buffer );
LfsDebugTrace( -1, Dbg, "LfsReadLogRecord: Exit\n", 0 );
}
} except (LfsExceptionFilter( GetExceptionInformation() )) {
Status = GetExceptionCode();
}
if (Status != STATUS_SUCCESS) {
ExRaiseStatus( Status );
}
return;
}
示例3: LfsFindLogRecord
//.........这里部分代码省略.........
//
// We now have the log record desired. If the Lsn in the
// log record doesn't match the desired Lsn then the disk is
// corrupt.
//
if ( Lsn.QuadPart != Lcb->RecordHeader->ThisLsn.QuadPart ) { //**** xxNeq( Lsn, Lcb->RecordHeader->ThisLsn )
ExRaiseStatus( STATUS_DISK_CORRUPT_ERROR );
}
//
// Check that the length field isn't greater than the total available space
// in the log file.
//
LogRecordLength = Lcb->RecordHeader->ClientDataLength + Lfcb->RecordHeaderLength; //**** xxFromUlong( Lcb->RecordHeader->ClientDataLength + Lfcb->RecordHeaderLength );
if ( LogRecordLength >= Lfcb->TotalAvailable ) { //**** xxGeq( LogRecordLength, Lfcb->TotalAvailable )
ExRaiseStatus( STATUS_DISK_CORRUPT_ERROR );
}
//
// If the entire log record is on this log page, put a pointer to
// the log record in the context block.
//
if (!FlagOn( Lcb->RecordHeader->Flags, LOG_RECORD_MULTI_PAGE )) {
//
// If client size indicates that we have to go beyond the end of the current
// page, we raise an error.
//
PageOffset = LfsLsnToPageOffset( Lfcb, Lsn );
if ((PageOffset + Lcb->RecordHeader->ClientDataLength + Lfcb->RecordHeaderLength)
> (ULONG)Lfcb->LogPageSize) {
ExRaiseStatus( STATUS_DISK_CORRUPT_ERROR );
}
Lcb->CurrentLogRecord = LfsAdd2Ptr( Lcb->RecordHeader, LFS_RECORD_HEADER_SIZE, PVOID );
Lcb->AuxilaryBuffer = FALSE;
//
// Else we copy the data and remember that we allocated a buffer.
//
} else {
NewBuffer = FsRtlAllocatePool( PagedPool, Lcb->RecordHeader->ClientDataLength );
LfsCopyReadLogRecord( Lfcb,
Lcb->RecordHeader,
NewBuffer );
Lcb->CurrentLogRecord = NewBuffer;
Lcb->AuxilaryBuffer = TRUE;
NewBuffer = NULL;
}
//
// We need to update the caller's parameters and the context block.
//
*RecordType = Lcb->RecordHeader->RecordType;
*TransactionId = Lcb->RecordHeader->TransactionId;
*UndoNextLsn = Lcb->RecordHeader->ClientUndoNextLsn;
*PreviousLsn = Lcb->RecordHeader->ClientPreviousLsn;
*Buffer = Lcb->CurrentLogRecord;
*BufferLength = Lcb->RecordHeader->ClientDataLength;
} finally {
DebugUnwind( LfsFindLogRecord );
//
// If an error occurred we unpin the record header and the log
// We also free the buffer if allocated by us.
//
if (NewBuffer != NULL) {
ExFreePool( NewBuffer );
}
LfsDebugTrace( 0, Dbg, "Buffer Length -> %08lx\n", *BufferLength );
LfsDebugTrace( 0, Dbg, "Buffer -> %08lx\n", *Buffer );
LfsDebugTrace( -1, Dbg, "LfsFindLogRecord: Exit\n", 0 );
}
return;
}
示例4: FatCommonLockControl
//.........这里部分代码省略.........
//
IrpSp = IoGetCurrentIrpStackLocation( Irp );
DebugTrace(+1, Dbg, "FatCommonLockControl\n", 0);
DebugTrace( 0, Dbg, "Irp = %08lx\n", Irp);
DebugTrace( 0, Dbg, "MinorFunction = %08lx\n", IrpSp->MinorFunction);
//
// Decode the type of file object we're being asked to process
//
TypeOfOpen = FatDecodeFileObject( IrpSp->FileObject, &Vcb, &Fcb, &Ccb );
//
// If the file is not a user file open then we reject the request
// as an invalid parameter
//
if (TypeOfOpen != UserFileOpen) {
FatCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );
DebugTrace(-1, Dbg, "FatCommonLockControl -> STATUS_INVALID_PARAMETER\n", 0);
return STATUS_INVALID_PARAMETER;
}
//
// Acquire exclusive access to the Fcb and enqueue the Irp if we didn't
// get access
//
if (!FatAcquireSharedFcb( IrpContext, Fcb )) {
Status = FatFsdPostRequest( IrpContext, Irp );
DebugTrace(-1, Dbg, "FatCommonLockControl -> %08lx\n", Status);
return Status;
}
try {
//
// We check whether we can proceed
// based on the state of the file oplocks.
//
Status = FsRtlCheckOplock( &Fcb->Specific.Fcb.Oplock,
Irp,
IrpContext,
FatOplockComplete,
NULL );
if (Status != STATUS_SUCCESS) {
OplockPostIrp = TRUE;
try_return( NOTHING );
}
//
// Now call the FsRtl routine to do the actual processing of the
// Lock request
//
Status = FsRtlProcessFileLock( &Fcb->Specific.Fcb.FileLock, Irp, NULL );
//
// Set the flag indicating if Fast I/O is possible
//
Fcb->Header.IsFastIoPossible = FatIsFastIoPossible( Fcb );
try_exit:
NOTHING;
}
finally {
DebugUnwind( FatCommonLockControl );
//
// Only if this is not an abnormal termination do we delete the
// irp context
//
if (!AbnormalTermination() && !OplockPostIrp) {
FatCompleteRequest( IrpContext, FatNull, 0 );
}
//
// Release the Fcb, and return to our caller
//
FatReleaseFcb( IrpContext, Fcb );
DebugTrace(-1, Dbg, "FatCommonLockControl -> %08lx\n", Status);
}
return Status;
}
示例5: LfsReadNextLogRecord
//.........这里部分代码省略.........
//
// We can give up the Lfcb as we know the Lsn is within the file.
//
LfsReleaseLfcb( Lfcb );
//
// Cleanup the context block so we can do the next search.
//
Lcb->CurrentLogRecord = NULL;
Lcb->AuxilaryBuffer = FALSE;
//
// Perform the work of getting the log record.
//
LfsFindLogRecord( Lfcb,
Lcb,
*Lsn,
RecordType,
TransactionId,
UndoNextLsn,
PreviousLsn,
BufferLength,
Buffer );
FoundNextLsn = TRUE;
}
} finally {
DebugUnwind( LfsReadNextLogRecord );
//
// If we exited due to an error, we have to restore the context
// block.
//
if (UnwindRememberLcbFields) {
if (AbnormalTermination()) {
//
// If the record header in the context block is not
// the same as we started with. Then we unpin that
// data.
//
if (Lcb->RecordHeaderBcb != NULL) {
CcUnpinData( Lcb->RecordHeaderBcb );
}
if (Lcb->CurrentLogRecord != NULL
&& Lcb->AuxilaryBuffer == TRUE) {
ExFreePool( Lcb->CurrentLogRecord );
}
Lcb->RecordHeaderBcb = UnwindRecordHeaderBcb;
Lcb->RecordHeader = UnwindRecordHeader;
Lcb->CurrentLogRecord = UnwindCurrentLogRecord;
Lcb->AuxilaryBuffer = UnwindAuxilaryBuffer;
示例6: LfsWriteLfsRestart
//.........这里部分代码省略.........
//
// We allocate another restart area and
// copy the current area into it. Attach the new area to the Lfcb.
//
LfsAllocateRestartArea( &NewRestart, ThisRestartSize );
//
// We allocate a Lbcb structure and update the values to
// reflect this restart area.
//
LfsAllocateLbcb( Lfcb, &NewLbcb );
SetFlag( NewLbcb->LbcbFlags, LBCB_RESTART_LBCB );
//
// If this is the second page, then add a system page to the offset.
//
if (!Lfcb->InitialRestartArea) {
NewLbcb->FileOffset = Lfcb->SystemPageSize + NewLbcb->FileOffset;
}
(ULONG)NewLbcb->Length = ThisRestartSize;
NewLbcb->PageHeader = (PVOID) Lfcb->RestartArea;
//
// Lets put the current lsn in the Lbcb.
//
NewLbcb->LastEndLsn = NewLbcb->LastLsn = Lfcb->NextRestartLsn;
Lfcb->NextRestartLsn.QuadPart = 1 + Lfcb->NextRestartLsn.QuadPart;
//
// Copy the existing restart area into the new area.
//
RtlCopyMemory( NewRestart, Lfcb->RestartArea, ThisRestartSize );
Lfcb->RestartArea = NewRestart;
Lfcb->ClientArray = LfsAdd2Ptr( NewRestart, Lfcb->ClientArrayOffset, PLFS_CLIENT_RECORD );
NewRestart = NULL;
//
// Update the Lfcb to indicate that the other restart area
// on the disk is to be used.
//
Lfcb->InitialRestartArea = !Lfcb->InitialRestartArea;
//
// Add this Lbcb to the end of the workque and flush to that point.
//
InsertTailList( &Lfcb->LbcbWorkque, &NewLbcb->WorkqueLinks );
//
// If we don't support a packed log file then we need to make
// sure that all file records written out ahead of this
// restart area make it out to disk and we don't add anything
// to this page.
//
if (!FlagOn( Lfcb->Flags, LFCB_PACK_LOG )
&& !IsListEmpty( &Lfcb->LbcbActive )) {
ActiveLbcb = CONTAINING_RECORD( Lfcb->LbcbActive.Flink,
LBCB,
ActiveLinks );
if (FlagOn( ActiveLbcb->LbcbFlags, LBCB_NOT_EMPTY )) {
RemoveEntryList( &ActiveLbcb->ActiveLinks );
ClearFlag( ActiveLbcb->LbcbFlags, LBCB_ON_ACTIVE_QUEUE );
}
}
if (WaitForIo) {
LfsFlushLbcb( Lfcb, NewLbcb );
}
} __finally {
DebugUnwind( LfsWriteLfsRestart );
if (NewRestart != NULL) {
ExFreePool( NewRestart );
}
LfsDebugTrace( -1, Dbg, "LfsWriteLfsRestart: Exit\n", 0 );
}
return;
}
示例7: FatFastLock
//.........这里部分代码省略.........
Key - Supplies the key used in this operation
FailImmediately - Indicates if the request should fail immediately
if the lock cannot be granted.
ExclusiveLock - Indicates if this is a request for an exclusive or
shared lock
IoStatus - Receives the Status if this operation is successful
Return Value:
BOOLEAN - TRUE if this operation completed and FALSE if caller
needs to take the long route.
--*/
{
BOOLEAN Results;
PVCB Vcb;
PFCB Fcb;
PCCB Ccb;
DebugTrace(+1, Dbg, "FatFastLock\n", 0);
//
// Decode the type of file object we're being asked to process and make
// sure it is only a user file open.
//
if (FatDecodeFileObject( FileObject, &Vcb, &Fcb, &Ccb ) != UserFileOpen) {
IoStatus->Status = STATUS_INVALID_PARAMETER;
IoStatus->Information = 0;
DebugTrace(-1, Dbg, "FatFastLock -> TRUE (STATUS_INVALID_PARAMETER)\n", 0);
return TRUE;
}
//
// Acquire exclusive access to the Fcb this operation can always wait
//
FsRtlEnterFileSystem();
try {
//
// We check whether we can proceed
// based on the state of the file oplocks.
//
if (!FsRtlOplockIsFastIoPossible( &(Fcb)->Specific.Fcb.Oplock )) {
try_return( Results = FALSE );
}
//
// Now call the FsRtl routine to do the actual processing of the
// Lock request
//
if (Results = FsRtlFastLock( &Fcb->Specific.Fcb.FileLock,
FileObject,
FileOffset,
Length,
ProcessId,
Key,
FailImmediately,
ExclusiveLock,
IoStatus,
NULL,
FALSE )) {
//
// Set the flag indicating if Fast I/O is possible
//
Fcb->Header.IsFastIoPossible = FatIsFastIoPossible( Fcb );
}
try_exit:
NOTHING;
}
finally {
DebugUnwind( FatFastLock );
//
// Release the Fcb, and return to our caller
//
FsRtlExitFileSystem();
DebugTrace(-1, Dbg, "FatFastLock -> %08lx\n", Results);
}
return Results;
}
示例8: LfsFindNextLsn
//.........这里部分代码省略.........
LfsTruncateOffsetToLogPage( Lfcb, EndOfLogRecord, &LogHeaderOffset );
//
// Remember the sequence number for this page.
//
SequenceNumber = LfsLsnToSeqNumber( Lfcb, RecordHeader->ThisLsn );
//
// Remember if we wrapped.
//
if ( EndOfLogRecord <= LsnOffset ) { //**** xxLeq( EndOfLogRecord, LsnOffset )
SequenceNumber = SequenceNumber + 1; //**** xxAdd( SequenceNumber, LfsLi1 );
}
//
// Pin the log page header for this page.
//
LfsPinOrMapData( Lfcb,
LogHeaderOffset,
(ULONG)Lfcb->LogPageSize,
FALSE,
FALSE,
FALSE,
&UsaError,
(PVOID *)&LogRecordPage,
&LogRecordPageBcb );
//
// If the Lsn we were given was not the last Lsn on this page, then
// the starting offset for the next Lsn is on a quad word boundary
// following the last file offset for the current Lsn. Otherwise
// the file offset is the start of the data on the next page.
//
if ( RecordHeader->ThisLsn.QuadPart == LogRecordPage->Copy.LastLsn.QuadPart ) { //**** xxEql( RecordHeader->ThisLsn, LogRecordPage->Copy.LastLsn )
BOOLEAN Wrapped;
LfsNextLogPageOffset( Lfcb,
LogHeaderOffset,
&LogHeaderOffset,
&Wrapped );
LsnOffset = LogHeaderOffset + Lfcb->LogPageDataOffset; //**** xxAdd( LogHeaderOffset, Lfcb->LogPageDataOffset );
//
// If we wrapped, we need to increment the sequence number.
//
if (Wrapped) {
SequenceNumber = SequenceNumber + 1; //**** xxAdd( SequenceNumber, LfsLi1 );
}
} else {
LiQuadAlign( EndOfLogRecord, &LsnOffset );
}
//
// Compute the Lsn based on the file offset and the sequence count.
//
Lsn->QuadPart = LfsFileOffsetToLsn( Lfcb, LsnOffset, SequenceNumber );
//
// If this Lsn is within the legal range for the file, we return TRUE.
// Otherwise FALSE indicates that there are no more Lsn's.
//
if (LfsIsLsnInFile( Lfcb, *Lsn )) {
FoundNextLsn = TRUE;
}
} finally {
DebugUnwind( LfsFindNextLsn );
//
// Unpin the log page header if held.
//
if (LogRecordPageBcb != NULL) {
CcUnpinData( LogRecordPageBcb );
}
DebugTrace( 0, Dbg, "Lsn (Low) -> %08lx\n", Lsn->LowPart );
DebugTrace( 0, Dbg, "Lsn (High) -> %08lx\n", Lsn->HighPart );
DebugTrace( -1, Dbg, "LfsFindNextLsn: Exit -> %08x\n", FoundNextLsn );
}
return FoundNextLsn;
}
示例9: NtfsFastUnlockSingle
//.........这里部分代码省略.........
// make sure that is is only a user file open.
//
if ((Scb = NtfsFastDecodeUserFileOpen( FileObject )) == NULL) {
IoStatus->Status = STATUS_INVALID_PARAMETER;
DebugTrace( -1, Dbg, ("NtfsFastUnlockSingle -> TRUE (STATUS_INVALID_PARAMETER)\n") );
return TRUE;
}
Fcb = Scb->Fcb;
//
// Acquire exclusive access to the Fcb this operation can always wait
//
FsRtlEnterFileSystem();
if (Scb->ScbType.Data.FileLock == NULL) {
(VOID) ExAcquireResourceExclusive( Fcb->Resource, TRUE );
ResourceAcquired = TRUE;
} else {
//(VOID) ExAcquireResourceShared( Fcb->Resource, TRUE );
}
try {
//
// We check whether we can proceed based on the state of the file oplocks.
//
if ((Scb->ScbType.Data.Oplock != NULL) &&
!FsRtlOplockIsFastIoPossible( &Scb->ScbType.Data.Oplock )) {
try_return( Results = FALSE );
}
//
// If we don't have a file lock, then get one now.
//
if (Scb->ScbType.Data.FileLock == NULL
&& !NtfsCreateFileLock( Scb, FALSE )) {
try_return( Results = FALSE );
}
//
// Now call the FsRtl routine to do the actual processing of the
// Lock request. The call will always succeed.
//
Results = TRUE;
IoStatus->Status = FsRtlFastUnlockSingle( Scb->ScbType.Data.FileLock,
FileObject,
FileOffset,
Length,
ProcessId,
Key,
NULL,
FALSE );
//
// Set the flag indicating if Fast I/O is possible. We are
// only concerned if there are no longer any filelocks on this
// file.
//
if (!FsRtlAreThereCurrentFileLocks( Scb->ScbType.Data.FileLock ) &&
(Scb->Header.IsFastIoPossible != FastIoIsPossible)) {
NtfsAcquireFsrtlHeader( Scb );
Scb->Header.IsFastIoPossible = NtfsIsFastIoPossible( Scb );
NtfsReleaseFsrtlHeader( Scb );
}
try_exit: NOTHING;
} finally {
DebugUnwind( NtfsFastUnlockSingle );
//
// Release the Fcb, and return to our caller
//
if (ResourceAcquired) {
ExReleaseResource( Fcb->Resource );
}
FsRtlExitFileSystem();
DebugTrace( -1, Dbg, ("NtfsFastUnlockSingle -> %08lx\n", Results) );
}
return Results;
}
示例10: FatCommonLockControl
//.........这里部分代码省略.........
DebugTrace(-1, Dbg, "FatCommonLockControl -> STATUS_INVALID_PARAMETER\n", 0);
return STATUS_INVALID_PARAMETER;
}
//
// Acquire exclusive access to the Fcb and enqueue the Irp if we didn't
// get access
//
if (!FatAcquireSharedFcb( IrpContext, Fcb )) {
Status = FatFsdPostRequest( IrpContext, Irp );
DebugTrace(-1, Dbg, "FatCommonLockControl -> %08lx\n", Status);
return Status;
}
try {
//
// We check whether we can proceed
// based on the state of the file oplocks.
//
#if (NTDDI_VERSION >= NTDDI_WIN8)
if (((IRP_MN_LOCK == IrpSp->MinorFunction) &&
((ULONGLONG)IrpSp->Parameters.LockControl.ByteOffset.QuadPart <
(ULONGLONG)Fcb->Header.AllocationSize.QuadPart)) ||
((IRP_MN_LOCK != IrpSp->MinorFunction) &&
FsRtlAreThereWaitingFileLocks( &Fcb->Specific.Fcb.FileLock ))) {
//
// Check whether we can proceed based on the state of file oplocks if doing
// an operation that interferes with oplocks. Those operations are:
//
// 1. Lock a range within the file's AllocationSize.
// 2. Unlock a range when there are waiting locks on the file. This one
// is not guaranteed to interfere with oplocks, but it could, as
// unlocking this range might cause a waiting lock to be granted
// within AllocationSize!
//
#endif
Status = FsRtlCheckOplock( FatGetFcbOplock(Fcb),
Irp,
IrpContext,
FatOplockComplete,
NULL );
#if (NTDDI_VERSION >= NTDDI_WIN8)
}
#endif
if (Status != STATUS_SUCCESS) {
OplockPostIrp = TRUE;
try_return( NOTHING );
}
//
// Now call the FsRtl routine to do the actual processing of the
// Lock request
//
Status = FsRtlProcessFileLock( &Fcb->Specific.Fcb.FileLock, Irp, NULL );
//
// Set the flag indicating if Fast I/O is possible
//
Fcb->Header.IsFastIoPossible = FatIsFastIoPossible( Fcb );
try_exit: NOTHING;
} finally {
DebugUnwind( FatCommonLockControl );
//
// Only if this is not an abnormal termination do we delete the
// irp context
//
if (!AbnormalTermination() && !OplockPostIrp) {
FatCompleteRequest( IrpContext, FatNull, 0 );
}
//
// Release the Fcb, and return to our caller
//
FatReleaseFcb( IrpContext, Fcb );
DebugTrace(-1, Dbg, "FatCommonLockControl -> %08lx\n", Status);
}
return Status;
}
示例11: FatPrepareWriteDirectoryFile
//.........这里部分代码省略.........
if (ByteCount > ClusterSize) {
BytesToPin = ClusterSize;
} else {
BytesToPin = ByteCount;
}
ASSERT( (Vbo.QuadPart / ClusterSize) ==
(Vbo.QuadPart + BytesToPin - 1)/ClusterSize );
if (!CcPinRead( Dcb->Specific.Dcb.DirectoryFile,
&Vbo,
BytesToPin,
BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT),
Bcb,
&LocalBuffer )) {
//
// Could not read the data without waiting (cache miss).
//
FatRaiseStatus( IrpContext, STATUS_CANT_WAIT );
}
//
// Update our caller with the beginning of their request.
//
if (*Buffer == NULL) {
*Buffer = LocalBuffer;
}
DbgDoit( IrpContext->PinCount += 1 )
if (Zero) {
//
// We set this guy dirty right now so that we can raise CANT_WAIT when
// it needs to be done. It'd be beautiful if we could noop the read IO
// since we know we don't care about it.
//
RtlZeroMemory( LocalBuffer, BytesToPin );
CcSetDirtyPinnedData( *Bcb, NULL );
}
ByteCount -= BytesToPin;
Vbo.QuadPart += BytesToPin;
if (ByteCount > 0) {
FatUnpinBcb( IrpContext, *Bcb );
}
}
//
// This lets us get the data pinned until we complete the request
// and writes the dirty bit through to the disk.
//
FatSetDirtyBcb( IrpContext, *Bcb, Dcb->Vcb, Reversible );
*Status = STATUS_SUCCESS;
} finally {
DebugUnwind( FatPrepareWriteDirectoryFile );
if (AbnormalTermination()) {
//
// These steps are carefully arranged - FatTruncateFileAllocation can raise.
// Make sure we unpin the buffer. If FTFA raises, the effect should be benign.
//
FatUnpinBcb(IrpContext, *Bcb);
if (UnwindWeAllocatedDiskSpace == TRUE) {
//
// Inform the cache manager of the change.
//
FatTruncateFileAllocation( IrpContext, Dcb, InitialAllocation );
Dcb->Header.FileSize.LowPart =
Dcb->Header.AllocationSize.LowPart;
CcSetFileSizes( Dcb->Specific.Dcb.DirectoryFile,
(PCC_FILE_SIZES)&Dcb->Header.AllocationSize );
}
}
DebugTrace(-1, Dbg, "FatPrepareWriteDirectoryFile -> (VOID), *Bcb = %08lx\n", *Bcb);
}
return;
}
示例12: LfsGetLbcb
//.........这里部分代码省略.........
if (Int64ShllMod32( Lfcb->SeqNumber, Lfcb->FileDataBits ) == 0) {
LfsDebugTrace( 0, Dbg, "Log sequence number about to wrap: Lfcb -> %08lx\n", Lfcb );
KeBugCheck( FILE_SYSTEM );
}
//
// If this number is greater or equal to the wrap sequence number in
// the Lfcb, set the wrap flag in the Lbcb.
//
if (!FlagOn( Lfcb->Flags, LFCB_LOG_WRAPPED )
&& ( Lfcb->SeqNumber >= Lfcb->SeqNumberForWrap )) {
SetFlag( Lbcb->LbcbFlags, LBCB_LOG_WRAPPED );
SetFlag( Lfcb->Flags, LFCB_LOG_WRAPPED );
}
}
//
// Now initialize the rest of the Lbcb fields.
//
Lbcb->FileOffset = Lfcb->NextLogPage;
Lbcb->SeqNumber = Lfcb->SeqNumber;
Lbcb->BufferOffset = Lfcb->LogPageDataOffset;
//
// Store the next page in the Lfcb.
//
LfsNextLogPageOffset( Lfcb,
Lfcb->NextLogPage,
&Lfcb->NextLogPage,
&WrappedOrUsaError );
Lbcb->Length = Lfcb->LogPageSize;
Lbcb->PageHeader = PageHeader;
Lbcb->LogPageBcb = PageHeaderBcb;
Lbcb->ResourceThread = ExGetCurrentResourceThread();
//
// If we are reusing a previous page then set a flag in
// the Lbcb to indicate that we should flush a copy
// first.
//
if (FlagOn( Lfcb->Flags, LFCB_REUSE_TAIL )) {
SetFlag( Lbcb->LbcbFlags, LBCB_FLUSH_COPY );
ClearFlag( Lfcb->Flags, LFCB_REUSE_TAIL );
(ULONG)Lbcb->BufferOffset = Lfcb->ReusePageOffset;
Lbcb->Flags = ((PLFS_RECORD_PAGE_HEADER) PageHeader)->Flags;
Lbcb->LastLsn = ((PLFS_RECORD_PAGE_HEADER) PageHeader)->Copy.LastLsn;
Lbcb->LastEndLsn = ((PLFS_RECORD_PAGE_HEADER) PageHeader)->Header.Packed.LastEndLsn;
}
//
// Put the Lbcb on the active queue
//
InsertTailList( &Lfcb->LbcbActive, &Lbcb->ActiveLinks );
SetFlag( Lbcb->LbcbFlags, LBCB_ON_ACTIVE_QUEUE );
} finally {
DebugUnwind( LfsGetLbcb );
//
// If an error occurred, we need to clean up any blocks which
// have not been added to the active queue.
//
if (AbnormalTermination()) {
if (Lbcb != NULL) {
LfsDeallocateLbcb( Lfcb, Lbcb );
Lbcb = NULL;
}
//
// Unpin the system page if pinned.
//
if (PageHeaderBcb != NULL) {
CcUnpinData( PageHeaderBcb );
}
}
LfsDebugTrace( -1, Dbg, "LfsGetLbcb: Exit\n", 0 );
}
return Lbcb;
}
示例13: FatSetFsLabelInfo
//.........这里部分代码省略.........
//
FatSetDirtyBcb( IrpContext, DirentBcb, Vcb, TRUE );
}
//
// Now reconstruct the volume label dirent.
//
FatConstructLabelDirent( IrpContext,
Dirent,
&OemLabel );
//
// Unpin the Bcb here so that we will get any IO errors
// here before changing the VPB label.
//
FatUnpinBcb( IrpContext, DirentBcb );
FatUnpinRepinnedBcbs( IrpContext );
//
// Now set the upcased label in the VPB
//
RtlCopyMemory( &Vcb->Vpb->VolumeLabel[0],
&UpcasedLabel.Buffer[0],
UpcasedLabel.Length );
Vcb->Vpb->VolumeLabelLength = UpcasedLabel.Length;
} else {
//
// Otherwise we're trying to delete the label
// Locate the current volume label if there already is one
//
FatLocateVolumeLabel( IrpContext,
Vcb,
&Dirent,
&DirentBcb,
&ByteOffset );
//
// Check that we really got one
//
if (Dirent == NULL) {
try_return( Status = STATUS_SUCCESS );
}
//
// Now delete the current label.
//
Dirent->FileName[0] = FAT_DIRENT_DELETED;
ASSERT( (Vcb->RootDcb->Specific.Dcb.UnusedDirentVbo == 0xffffffff) ||
RtlAreBitsSet( &Vcb->RootDcb->Specific.Dcb.FreeDirentBitmap,
ByteOffset / sizeof(DIRENT),
1 ) );
RtlClearBits( &Vcb->RootDcb->Specific.Dcb.FreeDirentBitmap,
ByteOffset / sizeof(DIRENT),
1 );
FatSetDirtyBcb( IrpContext, DirentBcb, Vcb, TRUE );
//
// Unpin the Bcb here so that we will get any IO errors
// here before changing the VPB label.
//
FatUnpinBcb( IrpContext, DirentBcb );
FatUnpinRepinnedBcbs( IrpContext );
//
// Now set the label in the VPB
//
Vcb->Vpb->VolumeLabelLength = 0;
}
Status = STATUS_SUCCESS;
FatSortDirectory(IrpContext, Vcb->RootDcb);
try_exit: NOTHING;
} finally {
DebugUnwind( FatSetFsALabelInfo );
FatUnpinBcb( IrpContext, DirentBcb );
DebugTrace(-1, Dbg, "FatSetFsALabelInfo -> STATUS_SUCCESS\n", 0);
}
return Status;
}
示例14: FatCommonSetVolumeInfo
//.........这里部分代码省略.........
//
// Get the current stack location
//
IrpSp = IoGetCurrentIrpStackLocation( Irp );
DebugTrace(+1, Dbg, "FatCommonSetVolumeInfo...\n", 0);
DebugTrace( 0, Dbg, "Irp = %08lx\n", Irp );
DebugTrace( 0, Dbg, "->Length = %08lx\n", IrpSp->Parameters.SetVolume.Length);
DebugTrace( 0, Dbg, "->FsInformationClass = %08lx\n", IrpSp->Parameters.SetVolume.FsInformationClass);
DebugTrace( 0, Dbg, "->Buffer = %08lx\n", Irp->AssociatedIrp.SystemBuffer);
//
// Reference our input parameters to make things easier
//
Length = IrpSp->Parameters.SetVolume.Length;
FsInformationClass = IrpSp->Parameters.SetVolume.FsInformationClass;
Buffer = Irp->AssociatedIrp.SystemBuffer;
//
// Decode the file object to get the Vcb
//
TypeOfOpen = FatDecodeFileObject( IrpSp->FileObject, &Vcb, &Fcb, &Ccb );
if (TypeOfOpen != UserVolumeOpen) {
FatCompleteRequest( IrpContext, Irp, STATUS_ACCESS_DENIED );
DebugTrace(-1, Dbg, "FatCommonSetVolumeInfo -> STATUS_ACCESS_DENIED\n", 0);
return STATUS_ACCESS_DENIED;
}
//
// Acquire exclusive access to the Vcb and enqueue the Irp if we didn't
// get access
//
if (!FatAcquireExclusiveVcb( IrpContext, Vcb )) {
DebugTrace(0, Dbg, "Cannot acquire Vcb\n", 0);
Status = FatFsdPostRequest( IrpContext, Irp );
DebugTrace(-1, Dbg, "FatCommonSetVolumeInfo -> %08lx\n", Status );
return Status;
}
try {
//
// Make sure the vcb is in a usable condition. This will raise
// and error condition if the volume is unusable
//
// Also verify the Root Dcb since we need info from there.
//
FatVerifyFcb( IrpContext, Vcb->RootDcb );
//
// Based on the information class we'll do different actions. Each
// of the procedures that we're calling performs the action if
// possible and returns true if it successful and false if it couldn't
// wait for any I/O to complete.
//
switch (FsInformationClass) {
case FileFsLabelInformation:
Status = FatSetFsLabelInfo( IrpContext, Vcb, Buffer );
break;
default:
Status = STATUS_INVALID_PARAMETER;
break;
}
FatUnpinRepinnedBcbs( IrpContext );
} finally {
DebugUnwind( FatCommonSetVolumeInfo );
FatReleaseVcb( IrpContext, Vcb );
if (!AbnormalTermination()) {
FatCompleteRequest( IrpContext, Irp, Status );
}
DebugTrace(-1, Dbg, "FatCommonSetVolumeInfo -> %08lx\n", Status);
}
return Status;
}
示例15: UdfLoadSparingTables
//.........这里部分代码省略.........
TRUE )) {
DebugTrace(( 0, Dbg, "UdfLoadSparingTables, sparing table %u didn't verify destag!\n",
SparingTable ));
break;
}
if (!UdfUdfIdentifierContained( &Header->RegID,
&UdfSparingTableIdentifier,
UDF_VERSION_150,
UDF_VERSION_RECOGNIZED,
OSCLASS_INVALID,
OSIDENTIFIER_INVALID)) {
DebugTrace(( 0, Dbg, "UdfLoadSparingTables, sparing table %u didn't verify regid!\n",
SparingTable ));
break;
}
//
// Calculate the total number bytes this map spans and check it against what
// we were told the sparing table sizes are.
//
DebugTrace(( 0, Dbg, "UdfLoadSparingTables, Sparing table %u has %u entries\n",
SparingTable,
Header->TableEntries ));
TotalBytes = sizeof(SPARING_TABLE_HEADER) + Header->TableEntries * sizeof(SPARING_TABLE_ENTRY);
if (Map->TableSize < TotalBytes) {
DebugTrace(( 0, Dbg, "UdfLoadSparingTables, sparing table #ents %u overflows allocation!\n",
Header->TableEntries ));
break;
}
//
// So far so good, advance past the header.
//
ByteOffset = sizeof(SPARING_TABLE_HEADER);
Entry = Add2Ptr( SectorBuffer, sizeof(SPARING_TABLE_HEADER), PSPARING_TABLE_ENTRY );
} else {
//
// Pick up in the new sector.
//
Entry = (PSPARING_TABLE_ENTRY) SectorBuffer;
}
RemainingBytes = Min( SectorSize( Vcb ), TotalBytes - ByteOffset );
}
//
// Add the mapping. Since sparing tables are an Lbn->Psn mapping,
// very odd, and I want to simplify things by putting the sparing
// in right at IO dispatch, translate this to a Psn->Psn mapping.
//
if (Entry->Original != UDF_SPARING_AVALIABLE &&
Entry->Original != UDF_SPARING_DEFECTIVE) {
Psn = Partition->Physical.Start + SectorsFromBlocks( Vcb, Entry->Original );
DebugTrace(( 0, Dbg, "UdfLoadSparingTables, mapping from Psn %x (Lbn %x) -> Psn %x\n",
Psn,
Entry->Original,
Entry->Mapped ));
FsRtlAddLargeMcbEntry( Pcb->SparingMcb,
Psn,
Entry->Mapped,
UDF_SPARING_PACKET_LENGTH );
}
//
// Advance to the next, and drop out if we've hit the end.
//
ByteOffset += sizeof(SPARING_TABLE_ENTRY);
RemainingBytes -= sizeof(SPARING_TABLE_ENTRY);
Entry++;
} while ( ByteOffset < TotalBytes );
}
} finally {
DebugUnwind( UdfLoadSparingTables );
UdfFreePool( &SectorBuffer );
}
DebugTrace(( -1, Dbg, "UdfLoadSparingTables -> STATUS_SUCCESS\n" ));
return STATUS_SUCCESS;
}