VOID NtfsSetFileObject ( IN PFILE_OBJECT FileObject, IN TYPE_OF_OPEN TypeOfOpen, IN PSCB Scb, IN PCCB Ccb OPTIONAL ) /*++ Routine Description: This routine sets the file system pointers within the file object Arguments: FileObject - Supplies a pointer to the file object being modified. TypeOfOpen - Supplies the type of open denoted by the file object. This is only used by this procedure for sanity checking. Scb - Supplies a pointer to Scb for the file object. Ccb - Optionally supplies a pointer to a ccb Return Value: None. --*/ { ASSERT_FILE_OBJECT( FileObject ); ASSERT_SCB( Scb ); ASSERT_OPTIONAL_CCB( Ccb ); PAGED_CODE(); DebugTrace( +1, Dbg, ("NtfsSetFileObject, FileObject = %08lx\n", FileObject) ); // // Load up the FileObject fields. // FileObject->FsContext = Scb; FileObject->FsContext2 = Ccb; FileObject->Vpb = Scb->Vcb->Vpb; // // Typically the I/O manager has already set this flag correctly. The notable // exception is when the user did an open by file ID of file record 3, so // we're doing a DASD open, but the I/O manager didn't notice, since it only // checks for a zero length filename. // if (TypeOfOpen == UserVolumeOpen) { SetFlag( FileObject->Flags, FO_VOLUME_OPEN ); } // // Now store TypeOfOpen if there is a Ccb // ASSERT((Ccb != NULL) || (TypeOfOpen == StreamFileOpen) || (TypeOfOpen == UnopenedFileObject)); if (Ccb != NULL) { Ccb->TypeOfOpen = (UCHAR)TypeOfOpen; } // // If this file has the temporary attribute bit set, don't lazy // write it unless absolutely necessary. // if (FlagOn( Scb->ScbState, SCB_STATE_TEMPORARY )) { SetFlag( FileObject->Flags, FO_TEMPORARY_FILE ); } // // And return to our caller // DebugTrace( -1, Dbg, ("NtfsSetFileObject -> VOID\n") ); return; }
BOOLEAN UdfFastQueryBasicInfo ( IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, IN OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject ) /*++ Routine Description: This routine is for the fast query call for basic 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; PCCB Ccb; PAGED_CODE(); ASSERT_FILE_OBJECT( FileObject ); FsRtlEnterFileSystem(); // // Decode the file object to find the type of open and the data // structures. // TypeOfOpen = UdfDecodeFileObject( FileObject, &Fcb, &Ccb ); // // We only support this request on user file or directory objects. // ASSERT( FlagOn( Fcb->FcbState, FCB_STATE_INITIALIZED )); if (TypeOfOpen != UserFileOpen && TypeOfOpen != UserDirectoryOpen) { FsRtlExitFileSystem(); return FALSE; } // // Acquire the file shared to access the Fcb. // if (!ExAcquireResourceShared( Fcb->Resource, Wait )) { FsRtlExitFileSystem(); return FALSE; } // // Use a try-finally to facilitate cleanup. // try { // // Only deal with 'good' Fcb's. // if (UdfVerifyFcbOperation( NULL, Fcb )) { // // Fill in the input buffer from the Fcb fields. // Buffer->CreationTime = Fcb->Timestamps.CreationTime; Buffer->LastWriteTime = Buffer->ChangeTime = Fcb->Timestamps.ModificationTime; Buffer->LastAccessTime = Fcb->Timestamps.AccessTime; Buffer->FileAttributes = Fcb->FileAttributes | UdfGetExtraFileAttributes( Ccb ); // // Update the IoStatus block with the size of this data. // IoStatus->Status = STATUS_SUCCESS; IoStatus->Information = sizeof( FILE_BASIC_INFORMATION ); Result = TRUE; } } finally { ExReleaseResource( Fcb->Resource ); FsRtlExitFileSystem(); } return Result; }
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; }