From 36322cffcd944d6089e0cee5d0d338721d136114 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 21 Apr 1999 19:16:31 +0000 Subject: [PATCH] fixed GetFileAttributes() svn path=/trunk/; revision=404 --- reactos/drivers/fs/vfat/iface.c | 35 ++++++++++- reactos/lib/kernel32/file/dir.c | 2 +- reactos/lib/kernel32/file/file.c | 4 +- reactos/ntoskrnl/io/file.c | 103 +++++++++++++++++-------------- 4 files changed, 91 insertions(+), 53 deletions(-) diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c index 96d4b68c020..1ef4fe02f84 100644 --- a/reactos/drivers/fs/vfat/iface.c +++ b/reactos/drivers/fs/vfat/iface.c @@ -1609,7 +1609,26 @@ NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject, PositionInfo->CurrentByteOffset)); return(STATUS_SUCCESS); } - + +NTSTATUS FsdGetBasicInformation(PFILE_OBJECT FileObject, + PVfatFCB FCB, + PDEVICE_OBJECT DeviceObject, + PFILE_BASIC_INFORMATION BasicInfo) +{ + DPRINT("FsdGetBasicInformation()\n"); + +// BasicInfo->CreationTime = +// BasicInfo->LastAccessTime = +// BasicInfo->LastWriteTime = +// BasicInfo->ChangeTime = + + BasicInfo->FileAttributes = FCB->entry.Attrib; + + DPRINT("Getting attributes %x\n", BasicInfo->FileAttributes); + + return(STATUS_SUCCESS); +} + NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) /* @@ -1655,10 +1674,20 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) DeviceObject, SystemBuffer); break; + case FileBasicInformation: + RC = FsdGetBasicInformation(FileObject, + FCB, + DeviceObject, + SystemBuffer); + break; default: RC=STATUS_NOT_IMPLEMENTED; } + Irp->IoStatus.Status = RC; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return RC; } @@ -1710,11 +1739,13 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp) RC = STATUS_NOT_IMPLEMENTED; } + Irp->IoStatus.Status = RC; + Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); return RC; } - + STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath) diff --git a/reactos/lib/kernel32/file/dir.c b/reactos/lib/kernel32/file/dir.c index 66c5900bc2e..1e1172f2c62 100644 --- a/reactos/lib/kernel32/file/dir.c +++ b/reactos/lib/kernel32/file/dir.c @@ -19,7 +19,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index bf9e63f7877..7b087c0af62 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -402,7 +402,7 @@ DWORD STDCALL GetFileAttributesW(LPCWSTR lpFileName) NTSTATUS errCode; hFile = CreateFileW(lpFileName, - GENERIC_READ, + FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, @@ -419,7 +419,7 @@ DWORD STDCALL GetFileAttributesW(LPCWSTR lpFileName) { CloseHandle(hFile); SetLastError(RtlNtStatusToDosError(errCode)); - return 0; + return 0xFFFFFFFF; } CloseHandle(hFile); return (DWORD)FileBasic.FileAttributes; diff --git a/reactos/ntoskrnl/io/file.c b/reactos/ntoskrnl/io/file.c index 5a4053bef46..2b1637baf9e 100644 --- a/reactos/ntoskrnl/io/file.c +++ b/reactos/ntoskrnl/io/file.c @@ -37,58 +37,65 @@ NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass) { - NTSTATUS Status; - PFILE_OBJECT FileObject; - PIRP Irp; - PIO_STACK_LOCATION StackPtr; - KEVENT Event; + PIRP Irp; + PDEVICE_OBJECT DeviceObject; + PFILE_OBJECT FileObject; + NTSTATUS Status; + KEVENT Event; + PIO_STACK_LOCATION StackPtr; - DPRINT("ZwQueryInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n", - FileHandle, - IoStatusBlock, - FileInformation, - Length, - FileInformationClass); + DPRINT("ZwQueryInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n", + FileHandle, + IoStatusBlock, + FileInformation, + Length, + FileInformationClass); - /* Get the file object from the file handle */ - Status = ObReferenceObjectByHandle(FileHandle, - FILE_READ_ATTRIBUTES, - IoFileType, - UserMode, - (PVOID *) &FileObject, - NULL); - if (!NT_SUCCESS(Status)) - { - return Status; - } - DPRINT("FileObject %x\n", FileObject); - - /* initialize an event object to wait on for the request */ - KeInitializeEvent(&Event, NotificationEvent, FALSE); + Status = ObReferenceObjectByHandle(FileHandle, + FILE_READ_ATTRIBUTES, + IoFileType, + UserMode, + (PVOID *)&FileObject, + NULL); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + DPRINT("FileObject %x\n", FileObject); - /* build the IRP to be sent to the driver for the request */ - Irp = IoBuildSynchronousFsdRequest(IRP_MJ_QUERY_INFORMATION, - FileObject->DeviceObject, - FileInformation, - Length, - 0, - &Event, - IoStatusBlock); - StackPtr = IoGetNextIrpStackLocation(Irp); - StackPtr->FileObject = FileObject; - StackPtr->Parameters.QueryFile.Length = Length; - StackPtr->Parameters.QueryFile.FileInformationClass = FileInformationClass; + KeInitializeEvent(&Event,NotificationEvent,FALSE); + DeviceObject = FileObject->DeviceObject; - /* Pass the IRP to the FSD (and wait for it if required) */ - DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject); - Status = IoCallDriver(FileObject->DeviceObject, Irp); - if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) - { - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); - Status = Irp->IoStatus.Status; - } + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); + if (Irp==NULL) + { + ObDereferenceObject(FileObject); + return STATUS_UNSUCCESSFUL; + } - return Status; + Irp->UserIosb = IoStatusBlock; + Irp->UserEvent = &Event; + Irp->UserBuffer=FileInformation; + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION; + StackPtr->MinorFunction = 0; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = FileObject; + + StackPtr->Parameters.QueryFile.FileInformationClass = + FileInformationClass; + StackPtr->Parameters.QueryFile.Length = Length; + + Status = IoCallDriver(FileObject->DeviceObject,Irp); + if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) + { + KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL); + Status = Irp->IoStatus.Status; + } + return(Status); } NTSTATUS NtSetInformationFile(HANDLE FileHandle, @@ -116,7 +123,7 @@ NTSTATUS ZwSetInformationFile(HANDLE FileHandle, PIO_STACK_LOCATION StackPtr; KEVENT Event; - DPRINT("ZwSetInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n", + DPRINT("ZwSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n", FileHandle, IoStatusBlock, FileInformation,