From f460c4e31c8cab2f3e1aef58e77c99a1258e6ffb Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 23 Aug 2008 10:47:52 +0000 Subject: [PATCH] - Remove a hack around sending FSCTL_ to an opened volume handle, it works good enough without the need to open another handle to the file system. svn path=/trunk/; revision=35558 --- reactos/lib/fslib/vfatlib/check/io.c | 44 ++++------------------------ 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/reactos/lib/fslib/vfatlib/check/io.c b/reactos/lib/fslib/vfatlib/check/io.c index cea6654d56e..19b446cb32a 100644 --- a/reactos/lib/fslib/vfatlib/check/io.c +++ b/reactos/lib/fslib/vfatlib/check/io.c @@ -72,6 +72,8 @@ void fs_open(PUNICODE_STRING DriveRoot,int rw) return; } + // Query geometry and partition info, to have bytes per sector, etc + CurrentOffset.QuadPart = 0LL; changes = last = NULL; @@ -80,43 +82,12 @@ void fs_open(PUNICODE_STRING DriveRoot,int rw) BOOLEAN fs_isdirty(PUNICODE_STRING DriveRoot) { - OBJECT_ATTRIBUTES ObjectAttributes; ULONG DirtyMask = 0; - WCHAR TempRootBuf[128]; - UNICODE_STRING TempRoot; - HANDLE FileSystem; - IO_STATUS_BLOCK IoSb; NTSTATUS Status; - - /* Add backslash to the end, so FS will be opened */ - TempRoot.Length = 0; - TempRoot.MaximumLength = sizeof(TempRootBuf); - TempRoot.Buffer = TempRootBuf; - RtlCopyUnicodeString(&TempRoot, DriveRoot); - if (TempRoot.Length == (TempRoot.MaximumLength-1)) return FALSE; - wcscat(TempRoot.Buffer, L"\\"); - TempRoot.Length += sizeof(WCHAR); - - InitializeObjectAttributes(&ObjectAttributes, - &TempRoot, - 0, - NULL, - NULL); - - Status = NtOpenFile(&FileSystem, - FILE_GENERIC_READ, - &ObjectAttributes, - &IoSb, - 0, - 0); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtOpenFile() failed with status 0x%.08x\n", Status); - return FALSE; - } + IO_STATUS_BLOCK IoSb; /* Check if volume is dirty */ - Status = NtFsControlFile(FileSystem, + Status = NtFsControlFile(fd/*FileSystem*/, NULL, NULL, NULL, &IoSb, FSCTL_IS_VOLUME_DIRTY, NULL, 0, &DirtyMask, sizeof(DirtyMask)); @@ -124,18 +95,13 @@ BOOLEAN fs_isdirty(PUNICODE_STRING DriveRoot) if (!NT_SUCCESS(Status)) { DPRINT1("NtFsControlFile() failed with Status 0x%08x\n", Status); - /* Close FS handle */ - NtClose(FileSystem); return FALSE; } - /* Close FS handle */ - NtClose(FileSystem); - + /* Convert Dirty mask to a boolean value */ return (DirtyMask & 1); } - void fs_read(loff_t pos,int size,void *data) { CHANGE *walk;