{ PFCB Fcb; TYPE_OF_OPEN TypeOfOpen; LARGE_INTEGER LargeLength; PAGED_CODE(); UNREFERENCED_PARAMETER( Wait ); UNREFERENCED_PARAMETER( DeviceObject ); // // Decode the type of file object we're being asked to process and // make sure that is is only a user file open. // TypeOfOpen = CdFastDecodeFileObject( FileObject, &Fcb ); if ((TypeOfOpen != UserFileOpen) || !CheckForReadOperation) { IoStatus->Status = STATUS_INVALID_PARAMETER; return TRUE; } LargeLength.QuadPart = Length; // // Check whether the file locks will allow for fast io. // if ((Fcb->FileLock == NULL) || FsRtlFastCheckLockForRead( Fcb->FileLock,
BOOLEAN CdFastUnlockAllByKey ( IN PFILE_OBJECT FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject ) /*++ Routine Description: This is a call back routine for doing the fast unlock all by key call. Arguments: FileObject - Supplies the file object used in this operation ProcessId - Supplies the process ID used in this operation Key - Supplies the key used in this operation Status - 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 = FALSE; TYPE_OF_OPEN TypeOfOpen; PFCB Fcb; PAGED_CODE(); IoStatus->Information = 0; // // Decode the type of file object we're being asked to process and // make sure that is is only a user file open. // TypeOfOpen = CdFastDecodeFileObject( FileObject, &Fcb ); if (TypeOfOpen != UserFileOpen) { IoStatus->Status = STATUS_INVALID_PARAMETER; return TRUE; } // // Only deal with 'good' Fcb's. // if (!CdVerifyFcbOperation( NULL, Fcb )) { return FALSE; } // // If there is no lock then return immediately. // if (Fcb->FileLock == NULL) { IoStatus->Status = STATUS_RANGE_NOT_LOCKED; return TRUE; } FsRtlEnterFileSystem(); try { // // We check whether we can proceed based on the state of the file oplocks. // if ((Fcb->Oplock != NULL) && !FsRtlOplockIsFastIoPossible( &Fcb->Oplock )) { try_return( NOTHING ); } // // If we don't have a file lock, then get one now. // if ((Fcb->FileLock == NULL) && !CdCreateFileLock( NULL, Fcb, FALSE )) { try_return( NOTHING ); } // // Now call the FsRtl routine to do the actual processing of the // Lock request. The call will always succeed. // Results = TRUE; IoStatus->Status = FsRtlFastUnlockAllByKey( Fcb->FileLock, FileObject, ProcessId, Key, NULL ); // // Set the flag indicating if Fast I/O is possible // CdLockFcb( IrpContext, Fcb ); Fcb->IsFastIoPossible = CdIsFastIoPossible( Fcb ); CdUnlockFcb( IrpContext, Fcb ); try_exit: NOTHING; } finally { FsRtlExitFileSystem(); } return Results; }
BOOLEAN CdFastQueryNetworkInfo ( __in PFILE_OBJECT FileObject, __in BOOLEAN Wait, __out PFILE_NETWORK_OPEN_INFORMATION Buffer, __out PIO_STATUS_BLOCK IoStatus, __in PDEVICE_OBJECT DeviceObject ) /*++ Routine Description: This routine is for the fast query call for network file information. Arguments: FileObject - Supplies the file object used in this operation Wait - Indicates if we are allowed to wait for the information Buffer - Supplies the output buffer to receive the basic information IoStatus - Receives the final status of the operation Return Value: BOOLEAN - TRUE if the operation succeeded and FALSE if the caller needs to take the long route. --*/ { BOOLEAN Result = FALSE; TYPE_OF_OPEN TypeOfOpen; PFCB Fcb; PAGED_CODE(); UNREFERENCED_PARAMETER( DeviceObject ); ASSERT_FILE_OBJECT( FileObject ); FsRtlEnterFileSystem(); // // Decode the file object to find the type of open and the data // structures. // TypeOfOpen = CdFastDecodeFileObject( FileObject, &Fcb ); // // We only support this request on user file or directory objects. // if ((TypeOfOpen != UserFileOpen) && ((TypeOfOpen != UserDirectoryOpen) || !FlagOn( Fcb->FcbState, FCB_STATE_INITIALIZED))) { FsRtlExitFileSystem(); return FALSE; } // // Acquire the file shared to access the Fcb. // if (!ExAcquireResourceSharedLite( Fcb->Resource, Wait )) { FsRtlExitFileSystem(); return FALSE; } // // Use a try-finally to facilitate cleanup. // try { // // Only deal with 'good' Fcb's. // if (CdVerifyFcbOperation( NULL, Fcb )) { // // Fill in the input buffer from the Fcb fields. // Buffer->CreationTime.QuadPart = Buffer->LastWriteTime.QuadPart = Buffer->ChangeTime.QuadPart = Fcb->CreationTime; Buffer->LastAccessTime.QuadPart = 0; Buffer->FileAttributes = Fcb->FileAttributes; // // Check whether this is a directory. // if (FlagOn( Fcb->FileAttributes, FILE_ATTRIBUTE_DIRECTORY )) { Buffer->AllocationSize.QuadPart = Buffer->EndOfFile.QuadPart = 0; } else { Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart; Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart; } // // Update the IoStatus block with the size of this data. // IoStatus->Status = STATUS_SUCCESS; IoStatus->Information = sizeof( FILE_NETWORK_OPEN_INFORMATION ); Result = TRUE; } } finally { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); } return Result; }
BOOLEAN CdFastLock ( IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, BOOLEAN FailImmediately, BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject ) /*++ Routine Description: This is a call back routine for doing the fast lock call. Arguments: FileObject - Supplies the file object used in this operation FileOffset - Supplies the file offset used in this operation Length - Supplies the length used in this operation ProcessId - Supplies the process ID used in this operation 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 = FALSE; PFCB Fcb; TYPE_OF_OPEN TypeOfOpen; PAGED_CODE(); ASSERT_FILE_OBJECT( FileObject ); IoStatus->Information = 0; // // Decode the type of file object we're being asked to process and // make sure that is is only a user file open. // TypeOfOpen = CdFastDecodeFileObject( FileObject, &Fcb ); if (TypeOfOpen != UserFileOpen) { IoStatus->Status = STATUS_INVALID_PARAMETER; return TRUE; } // // Only deal with 'good' Fcb's. // if (!CdVerifyFcbOperation( NULL, Fcb )) { return FALSE; } FsRtlEnterFileSystem(); // // Use a try-finally to facilitate cleanup. // try { // // We check whether we can proceed based on the state of the file oplocks. // if ((Fcb->Oplock != NULL) && !FsRtlOplockIsFastIoPossible( &Fcb->Oplock )) { try_return( NOTHING ); } // // If we don't have a file lock, then get one now. // if ((Fcb->FileLock == NULL) && !CdCreateFileLock( NULL, Fcb, FALSE )) { try_return( NOTHING ); } // // Now call the FsRtl routine to perform the lock request. // if (Results = FsRtlFastLock( Fcb->FileLock, FileObject, FileOffset, Length, ProcessId, Key, FailImmediately, ExclusiveLock, IoStatus, NULL, FALSE )) { // // Set the flag indicating if Fast I/O is questionable. We // only change this flag if the current state is possible. // Retest again after synchronizing on the header. // if (Fcb->IsFastIoPossible == FastIoIsPossible) { CdLockFcb( NULL, Fcb ); Fcb->IsFastIoPossible = CdIsFastIoPossible( Fcb ); CdUnlockFcb( NULL, Fcb ); } } try_exit: NOTHING; } finally { FsRtlExitFileSystem(); } return Results; }
BOOLEAN NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastIoCheckIfPossible ( IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject ) /*++ Routine Description: This routine checks if fast i/o is possible for a read/write operation Arguments: FileObject - Supplies the file object used in the query FileOffset - Supplies the starting byte offset for the read/write operation Length - Supplies the length, in bytes, of the read/write operation Wait - Indicates if we can wait LockKey - Supplies the lock key CheckForReadOperation - Indicates if this is a check for a read or write operation IoStatus - Receives the status of the operation if our return value is FastIoReturnError Return Value: BOOLEAN - TRUE if fast I/O is possible and FALSE if the caller needs to take the long route. --*/ { PFCB Fcb; TYPE_OF_OPEN TypeOfOpen; LARGE_INTEGER LargeLength; PAGED_CODE(); // // Decode the type of file object we're being asked to process and // make sure that is is only a user file open. // TypeOfOpen = CdFastDecodeFileObject( FileObject, &Fcb ); if ((TypeOfOpen != UserFileOpen) || !CheckForReadOperation) { IoStatus->Status = STATUS_INVALID_PARAMETER; return TRUE; } LargeLength.QuadPart = Length; // // Check whether the file locks will allow for fast io. // if ((Fcb->FileLock == NULL) || FsRtlFastCheckLockForRead( Fcb->FileLock, FileOffset, &LargeLength, LockKey, FileObject, PsGetCurrentProcess() )) { return TRUE; } return FALSE; }