ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
21 participants
115 discussions
Start a n
N
ew thread
[reactos] 01/01: [SDK] Raise KERNEL_VERSION_PATCH_LEVEL to 14 in the version.cmake
by Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=43a6843e9dcb29d2a3eda…
commit 43a6843e9dcb29d2a3eda1c95ebeaf526c46b6f9 Author: Joachim Henze <Joachim.Henze(a)reactos.org> AuthorDate: Mon Sep 30 18:15:39 2019 +0200 Commit: Joachim Henze <Joachim.Henze(a)reactos.org> CommitDate: Mon Sep 30 18:15:39 2019 +0200 [SDK] Raise KERNEL_VERSION_PATCH_LEVEL to 14 in the version.cmake --- sdk/include/reactos/version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/reactos/version.cmake b/sdk/include/reactos/version.cmake index 9057e2e0a77..4ccb3e79e65 100644 --- a/sdk/include/reactos/version.cmake +++ b/sdk/include/reactos/version.cmake @@ -2,7 +2,7 @@ string(TIMESTAMP KERNEL_VERSION_BUILD %Y%m%d UTC) set(KERNEL_VERSION_MAJOR "0") set(KERNEL_VERSION_MINOR "4") -set(KERNEL_VERSION_PATCH_LEVEL "13") +set(KERNEL_VERSION_PATCH_LEVEL "14") set(COPYRIGHT_YEAR "2019") # KERNEL_VERSION_BUILD_TYPE is "dev" for Git builds
5 years, 2 months
1
0
0
0
[reactos] 01/01: [NTOS:MM] i386: Fix '_MI_NO_EXECUTE' typo
by Serge Gautherie
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e413df4f4e7802ce604d8…
commit e413df4f4e7802ce604d88c3eb90c4c1401ad192 Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr> AuthorDate: Mon Sep 23 22:20:27 2019 +0200 Commit: Victor Perevertkin <victor(a)perevertkin.ru> CommitDate: Mon Sep 30 10:46:58 2019 +0300 [NTOS:MM] i386: Fix '_MI_NO_EXECUTE' typo Addendum to 65dbfc286818e18095b7cc0c85f63cde6b3e629d. --- ntoskrnl/include/internal/i386/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/include/internal/i386/mm.h b/ntoskrnl/include/internal/i386/mm.h index 63bce805829..1db55cba96a 100644 --- a/ntoskrnl/include/internal/i386/mm.h +++ b/ntoskrnl/include/internal/i386/mm.h @@ -8,7 +8,7 @@ #define _MI_HAS_NO_EXECUTE 1 #else #define _MI_PAGING_LEVELS 2 -#define _MI_NO_EXECUTE 0 +#define _MI_HAS_NO_EXECUTE 0 #endif /* Memory layout base addresses */
5 years, 2 months
1
0
0
0
[reactos] 03/03: [SDK] Make our MEMORY_SECTION_NAME definitions consistent. I choose the definition which is also used by Wine & Chromium.
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3f63f236baa5edaa26aed…
commit 3f63f236baa5edaa26aed223635202a6dd0741db Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 29 14:18:11 2019 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 29 14:18:11 2019 +0200 [SDK] Make our MEMORY_SECTION_NAME definitions consistent. I choose the definition which is also used by Wine & Chromium. CORE-12043 --- sdk/include/ndk/mmtypes.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/include/ndk/mmtypes.h b/sdk/include/ndk/mmtypes.h index 2e96dcad3e7..5c271938320 100644 --- a/sdk/include/ndk/mmtypes.h +++ b/sdk/include/ndk/mmtypes.h @@ -315,7 +315,6 @@ typedef struct _MEMORY_WORKING_SET_LIST typedef struct { UNICODE_STRING SectionFileName; - WCHAR NameBuffer[ANYSIZE_ARRAY]; } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; //
5 years, 2 months
1
0
0
0
[reactos] 02/03: [NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName(). Also take into account the UNICODE_STRING structure while computing whole size This is based on Thomas' patch.
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b78ca210ef49c020e343…
commit 3b78ca210ef49c020e34321ba9206c83340f26c0 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 29 14:16:44 2019 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 29 14:16:44 2019 +0200 [NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName(). Also take into account the UNICODE_STRING structure while computing whole size This is based on Thomas' patch. CORE-12043 --- ntoskrnl/mm/ARM3/section.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index e50aa518e5d..6bc1a6ef8db 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1923,11 +1923,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle, { _SEH2_TRY { - RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); - SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength; + RtlInitEmptyUnicodeString(&SectionName->SectionFileName, + (PWSTR)(SectionName + 1), + MemoryInformationLength - sizeof(MEMORY_SECTION_NAME)); RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); - if (ReturnLength) *ReturnLength = ModuleFileName.Length; + if (ReturnLength) *ReturnLength = ModuleFileName.Length + sizeof(MEMORY_SECTION_NAME); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -1938,11 +1939,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle, } else { - RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); - SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength; + RtlInitEmptyUnicodeString(&SectionName->SectionFileName, + (PWSTR)(SectionName + 1), + MemoryInformationLength - sizeof(MEMORY_SECTION_NAME)); RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); - if (ReturnLength) *ReturnLength = ModuleFileName.Length; + if (ReturnLength) *ReturnLength = ModuleFileName.Length + sizeof(MEMORY_SECTION_NAME); }
5 years, 2 months
1
0
0
0
[reactos] 01/03: [NTDLL_WINETESTS] Section name query test is broken on W2K3 and will lead to a crash Comment out the test for now and add a more "appropriate" test code for now
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ad547c960fce62b49c641…
commit ad547c960fce62b49c64172f12e1230566be14db Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sun Sep 29 14:13:55 2019 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sun Sep 29 14:13:55 2019 +0200 [NTDLL_WINETESTS] Section name query test is broken on W2K3 and will lead to a crash Comment out the test for now and add a more "appropriate" test code for now --- modules/rostests/winetests/ntdll/info.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/rostests/winetests/ntdll/info.c b/modules/rostests/winetests/ntdll/info.c index 14ddf20d1eb..3d2c6318840 100644 --- a/modules/rostests/winetests/ntdll/info.c +++ b/modules/rostests/winetests/ntdll/info.c @@ -1883,7 +1883,9 @@ static void test_queryvirtualmemory(void) { NTSTATUS status; SIZE_T readcount; +#ifndef __REACTOS__ static const WCHAR windowsW[] = {'w','i','n','d','o','w','s'}; +#endif static const char teststring[] = "test string"; static char datatestbuf[42] = "abc"; static char rwtestbuf[42]; @@ -1892,8 +1894,10 @@ static void test_queryvirtualmemory(void) HMODULE module; char buffer_name[sizeof(MEMORY_SECTION_NAME) + MAX_PATH * sizeof(WCHAR)]; MEMORY_SECTION_NAME *msn = (MEMORY_SECTION_NAME *)buffer_name; +#ifndef __REACTOS__ BOOL found; int i; +#endif module = GetModuleHandleA( "ntdll.dll" ); trace("Check flags of the PE header of NTDLL.DLL at %p\n", module); @@ -1994,6 +1998,7 @@ static void test_queryvirtualmemory(void) memset(buffer_name, 0x77, sizeof(buffer_name)); readcount = 0; status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemorySectionName, msn, sizeof(buffer_name), &readcount); +#ifndef __REACTOS__ ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ok( readcount > 0, "Expected readcount to be > 0\n"); trace ("Section Name: %s\n", wine_dbgstr_w(msn->SectionFileName.Buffer)); @@ -2001,6 +2006,11 @@ static void test_queryvirtualmemory(void) for (found = FALSE, i = (msn->SectionFileName.Length - sizeof(windowsW)) / sizeof(WCHAR); i >= 0; i--) found |= !memcmp( &msn->SectionFileName.Buffer[i], windowsW, sizeof(windowsW) ); ok( found, "Section name does not contain \"Windows\"\n"); +#else + /* W2K3 will return this, because the buffer is not ULONG-aligned */ + ok( status == STATUS_DATATYPE_MISALIGNMENT, "Expected STATUS_DATATYPE_MISALIGNMENT, got %08x\n", status); + ok( readcount == 0, "Expected readcount to be 0: %ld\n", readcount); +#endif trace("Check section name of non mapped memory\n"); memset(msn, 0, sizeof(*msn));
5 years, 2 months
1
0
0
0
[reactos] 01/01: [SHELLFOLDERS] Gracefully handle NULL pidl in CDrivesFolder::BindToObject. CORE-16403
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a66bee2837e4bed6f5940…
commit a66bee2837e4bed6f5940bad22667a4b5d4a6603 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Sep 8 15:40:46 2019 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Sep 29 12:42:26 2019 +0200 [SHELLFOLDERS] Gracefully handle NULL pidl in CDrivesFolder::BindToObject. CORE-16403 Fixes one of many crashes in shell32_winetest:shlfolder. --- dll/win32/shell32/folders/CDrivesFolder.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index ccb0b52883c..d8c35a79150 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -536,6 +536,9 @@ HRESULT WINAPI CDrivesFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcRese TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", this, pidl, pbcReserved, shdebugstr_guid(&riid), ppvOut); + if (!pidl) + return E_INVALIDARG; + if (_ILIsSpecialFolder(pidl)) return m_regFolder->BindToObject(pidl, pbcReserved, riid, ppvOut);
5 years, 2 months
1
0
0
0
[reactos] 01/01: [USBPORT] USBPORT_InvalidateEndpointHandler(): Properly enumerate endpoints
by Serge Gautherie
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed9f0dca14ea2e002868b…
commit ed9f0dca14ea2e002868bad30e4f6b6e9dec7e0c Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr> AuthorDate: Tue Sep 24 07:15:06 2019 +0200 Commit: Victor Perevertkin <victor(a)perevertkin.ru> CommitDate: Sun Sep 29 13:39:12 2019 +0300 [USBPORT] USBPORT_InvalidateEndpointHandler(): Properly enumerate endpoints --- drivers/usb/usbport/endpoint.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/usbport/endpoint.c b/drivers/usb/usbport/endpoint.c index 40efddf1652..a31443421c6 100644 --- a/drivers/usb/usbport/endpoint.c +++ b/drivers/usb/usbport/endpoint.c @@ -1357,9 +1357,9 @@ USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, { KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql); - Entry = &FdoExtension->EndpointList; - - while (Entry && Entry != &FdoExtension->EndpointList) + for (Entry = FdoExtension->EndpointList.Flink; + Entry && Entry != &FdoExtension->EndpointList; + Entry = Entry->Flink) { endpoint = CONTAINING_RECORD(Entry, USBPORT_ENDPOINT, @@ -1376,8 +1376,6 @@ USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IsAddEntry = TRUE; } } - - Entry = endpoint->EndpointLink.Flink; } KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
5 years, 2 months
1
0
0
0
[reactos] 02/02: [FREELDR] Optimize and refactor the FAT driver. Do not read the whole cluster chain for file on opening. This removes restriction for opening files which span within a large amount of clusters (>65k). That happened because FrLdrTempAlloc cannot allocate more than about 256 KiB of memory.
by Victor Perevertkin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=220bc820eb888455c8d8d…
commit 220bc820eb888455c8d8d554962c273f5f602188 Author: Victor Perevertkin <victor(a)perevertkin.ru> AuthorDate: Fri Jul 19 02:57:11 2019 +0300 Commit: Victor Perevertkin <victor(a)perevertkin.ru> CommitDate: Sun Sep 29 13:24:31 2019 +0300 [FREELDR] Optimize and refactor the FAT driver. Do not read the whole cluster chain for file on opening. This removes restriction for opening files which span within a large amount of clusters (>65k). That happened because FrLdrTempAlloc cannot allocate more than about 256 KiB of memory. Adjacent clusters for file are now read using one disk driver call. --- boot/freeldr/freeldr/include/fs/fat.h | 7 +- boot/freeldr/freeldr/lib/fs/fat.c | 319 ++++++++++++++++------------------ 2 files changed, 150 insertions(+), 176 deletions(-) diff --git a/boot/freeldr/freeldr/include/fs/fat.h b/boot/freeldr/freeldr/include/fs/fat.h index 7117cb2bad8..85e2998ecb8 100644 --- a/boot/freeldr/freeldr/include/fs/fat.h +++ b/boot/freeldr/freeldr/include/fs/fat.h @@ -147,11 +147,12 @@ typedef struct _FAT_VOLUME_INFO *PFAT_VOLUME_INFO; typedef struct { - UCHAR Attributes; /* File attributes */ + PFAT_VOLUME_INFO Volume; ULONG FileSize; /* File size */ ULONG FilePointer; /* File pointer */ - ULONG* FileFatChain; /* File fat chain array */ - PFAT_VOLUME_INFO Volume; + ULONG CurrentCluster; /* The cluster for file pointer */ + ULONG StartCluster; /* The first cluster for file */ + UCHAR Attributes; /* File attributes */ } FAT_FILE_INFO, * PFAT_FILE_INFO; #define ATTR_NORMAL 0x00 diff --git a/boot/freeldr/freeldr/lib/fs/fat.c b/boot/freeldr/freeldr/lib/fs/fat.c index b973a64dd70..35233c414b5 100644 --- a/boot/freeldr/freeldr/lib/fs/fat.c +++ b/boot/freeldr/freeldr/lib/fs/fat.c @@ -1,21 +1,10 @@ /* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> - * Copyright (C) 2009 Herv� Poussineau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * PROJECT: FreeLoader + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: FAT filesystem driver for FreeLoader + * COPYRIGHT: Copyright 1998-2003 Brian Palmer (brianp(a)sginet.com) + * Copyright 2009 Herv� Poussineau + * Copyright 2019 Victor Perevertkin (victor.perevertkin(a)reactos.org) */ #include <freeldr.h> @@ -28,13 +17,17 @@ PVOID FatBufferDirectory(PFAT_VOLUME_INFO Volume, ULONG DirectoryStartCluster BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID DirectoryBuffer, ULONG EntryCount, PCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer); ARC_STATUS FatLookupFile(PFAT_VOLUME_INFO Volume, PCSTR FileName, PFAT_FILE_INFO FatFileInfoPointer); void FatParseShortFileName(PCHAR Buffer, PDIRENTRY DirEntry); -BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPointer); -ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster); -ULONG* FatGetClusterChainArray(PFAT_VOLUME_INFO Volume, ULONG StartCluster); -BOOLEAN FatReadClusterChain(PFAT_VOLUME_INFO Volume, ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer); +static BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, UINT32 Cluster, PUINT32 ClusterPointer); +static ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, UINT32 StartCluster); +static BOOLEAN FatReadClusterChain(PFAT_VOLUME_INFO Volume, UINT32 StartClusterNumber, UINT32 NumberOfClusters, PVOID Buffer, PUINT32 LastClusterNumber); BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer); BOOLEAN FatReadVolumeSectors(PFAT_VOLUME_INFO Volume, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer); +#define FAT_IS_END_CLUSTER(clnumber) \ + (((Volume->FatType == FAT12) && (clnumber >= 0xff8)) || \ + ((Volume->FatType == FAT16 || Volume->FatType == FATX16) && (clnumber >= 0xfff8)) || \ + ((Volume->FatType == FAT32 || Volume->FatType == FATX32) && (clnumber >= 0x0ffffff8))) + #define TAG_FAT_CHAIN 'CtaT' #define TAG_FAT_FILE 'FtaF' #define TAG_FAT_VOLUME 'VtaF' @@ -494,7 +487,7 @@ PVOID FatBufferDirectory(PFAT_VOLUME_INFO Volume, ULONG DirectoryStartCluster, U } else { - if (!FatReadClusterChain(Volume, DirectoryStartCluster, 0xFFFFFFFF, DirectoryBuffer->Data)) + if (!FatReadClusterChain(Volume, DirectoryStartCluster, 0xFFFFFFFF, DirectoryBuffer->Data, NULL)) { FrLdrTempFree(DirectoryBuffer, TAG_FAT_BUFFER); return NULL; @@ -682,6 +675,9 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory FatFileInfoPointer->Attributes = DirEntry->Attr; FatFileInfoPointer->FileSize = DirEntry->Size; FatFileInfoPointer->FilePointer = 0; + StartCluster = ((ULONG)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow; + FatFileInfoPointer->CurrentCluster = StartCluster; + FatFileInfoPointer->StartCluster = StartCluster; TRACE("MSDOS Directory Entry:\n"); TRACE("FileName[11] = %c%c%c%c%c%c%c%c%c%c%c\n", DirEntry->FileName[0], DirEntry->FileName[1], DirEntry->FileName[2], DirEntry->FileName[3], DirEntry->FileName[4], DirEntry->FileName[5], DirEntry->FileName[6], DirEntry->FileName[7], DirEntry->FileName[8], DirEntry->FileName[9], DirEntry->FileName[10]); @@ -696,21 +692,7 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory TRACE("Date = %d\n", DirEntry->Date); TRACE("ClusterLow = 0x%x\n", DirEntry->ClusterLow); TRACE("Size = %d\n", DirEntry->Size); - - // - // Get the cluster chain - // - StartCluster = ((ULONG)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow; TRACE("StartCluster = 0x%x\n", StartCluster); - FatFileInfoPointer->FileFatChain = FatGetClusterChainArray(Volume, StartCluster); - - // - // See if memory allocation failed - // - if (FatFileInfoPointer->FileFatChain == NULL) - { - return FALSE; - } return TRUE; } @@ -761,6 +743,8 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID D FatFileInfoPointer->Attributes = DirEntry->Attr; FatFileInfoPointer->FileSize = DirEntry->Size; FatFileInfoPointer->FilePointer = 0; + FatFileInfoPointer->CurrentCluster = DirEntry->StartCluster; + FatFileInfoPointer->StartCluster = DirEntry->StartCluster; TRACE("FATX Directory Entry:\n"); TRACE("FileNameSize = %d\n", DirEntry->FileNameSize); @@ -774,19 +758,6 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID D TRACE("LastAccessTime = %d\n", DirEntry->LastAccessTime); TRACE("LastAccessDate = %d\n", DirEntry->LastAccessDate); - /* - * Get the cluster chain - */ - FatFileInfoPointer->FileFatChain = FatGetClusterChainArray(Volume, DirEntry->StartCluster); - - /* - * See if memory allocation failed - */ - if (NULL == FatFileInfoPointer->FileFatChain) - { - return FALSE; - } - return TRUE; } } @@ -875,12 +846,9 @@ ARC_STATUS FatLookupFile(PFAT_VOLUME_INFO Volume, PCSTR FileName, PFAT_FILE_INFO // if (!(FatFileInfo.Attributes & ATTR_DIRECTORY)) { - FrLdrTempFree(FatFileInfo.FileFatChain, TAG_FAT_CHAIN); return ENOTDIR; } - DirectoryStartCluster = FatFileInfo.FileFatChain[0]; - FrLdrTempFree(FatFileInfo.FileFatChain, TAG_FAT_CHAIN); - FatFileInfo.FileFatChain = NULL; + DirectoryStartCluster = FatFileInfo.StartCluster; } } @@ -979,7 +947,8 @@ PUCHAR FatGetFatSector(PFAT_VOLUME_INFO Volume, UINT32 FatSectorNumber) * FatGetFatEntry() * returns the Fat entry for a given cluster number */ -BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPointer) +static +BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, UINT32 Cluster, PUINT32 ClusterPointer) { UINT32 FatOffset, ThisFatSecNum, ThisFatEntOffset, fat; PUCHAR ReadBuffer; @@ -1047,8 +1016,7 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi ReadBuffer = FatGetFatSector(Volume, ThisFatSecNum); if (!ReadBuffer) { - Success = FALSE; - break; + return FALSE; } // Get the fat entry @@ -1069,7 +1037,8 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi return TRUE; } -ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster) +static +ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, UINT32 StartCluster) { ULONG ClusterCount = 0; @@ -1080,9 +1049,7 @@ ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster) // // If end of chain then break out of our cluster counting loop // - if (((Volume->FatType == FAT12) && (StartCluster >= 0xff8)) || - ((Volume->FatType == FAT16 || Volume->FatType == FATX16) && (StartCluster >= 0xfff8)) || - ((Volume->FatType == FAT32 || Volume->FatType == FATX32) && (StartCluster >= 0x0ffffff8))) + if (FAT_IS_END_CLUSTER(StartCluster)) { break; } @@ -1106,119 +1073,76 @@ ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster) return ClusterCount; } -ULONG* FatGetClusterChainArray(PFAT_VOLUME_INFO Volume, ULONG StartCluster) +static +BOOLEAN FatReadAdjacentClusters( + PFAT_VOLUME_INFO Volume, + UINT32 StartClusterNumber, + UINT32 MaxClusters, + PVOID Buffer, + PUINT32 ClustersRead, + PUINT32 LastClusterNumber) { - ULONG ClusterCount; - ULONG ArraySize; - ULONG* ArrayPointer; - ULONG Idx; + UINT32 NextClusterNumber; + UINT32 ClustersToRead = 1; + UINT32 PrevClusterNumber = StartClusterNumber; + UINT32 ClusterStartSector = ((PrevClusterNumber - 2) * Volume->SectorsPerCluster) + Volume->DataSectorStart; - TRACE("FatGetClusterChainArray() StartCluster = %d\n", StartCluster); - - ClusterCount = FatCountClustersInChain(Volume, StartCluster) + 1; // Lets get the 0x0ffffff8 on the end of the array - ArraySize = ClusterCount * sizeof(ULONG); - - // - // Allocate array memory - // - ArrayPointer = FrLdrTempAlloc(ArraySize, TAG_FAT_CHAIN); + *ClustersRead = 0; + *LastClusterNumber = 0; - if (ArrayPointer == NULL) + if (!FatGetFatEntry(Volume, StartClusterNumber, &NextClusterNumber)) { - return NULL; + return FALSE; } - // - // Loop through and set array values - // - for (Idx=0; Idx<ClusterCount; Idx++) + // getting the number of adjacent clusters + while (!FAT_IS_END_CLUSTER(NextClusterNumber) && ClustersToRead < MaxClusters && (NextClusterNumber == PrevClusterNumber + 1)) { - // - // Set current cluster - // - ArrayPointer[Idx] = StartCluster; - - // - // Don't try to get next cluster for last cluster - // - if (((Volume->FatType == FAT12) && (StartCluster >= 0xff8)) || - ((Volume->FatType == FAT16 || Volume->FatType == FATX16) && (StartCluster >= 0xfff8)) || - ((Volume->FatType == FAT32 || Volume->FatType == FATX32) && (StartCluster >= 0x0ffffff8))) + ClustersToRead++; + PrevClusterNumber = NextClusterNumber; + if (!FatGetFatEntry(Volume, PrevClusterNumber, &NextClusterNumber)) { - Idx++; - break; + return FALSE; } + } - // - // Get next cluster - // - if (!FatGetFatEntry(Volume, StartCluster, &StartCluster)) - { - FrLdrTempFree(ArrayPointer, TAG_FAT_CHAIN); - return NULL; - } + if (!FatReadVolumeSectors(Volume, ClusterStartSector, ClustersToRead * Volume->SectorsPerCluster, Buffer)) + { + return FALSE; } - return ArrayPointer; + *ClustersRead = ClustersToRead; + *LastClusterNumber = NextClusterNumber; + + return !FAT_IS_END_CLUSTER(NextClusterNumber) && ClustersToRead < MaxClusters; } /* * FatReadClusterChain() * Reads the specified clusters into memory */ -BOOLEAN FatReadClusterChain(PFAT_VOLUME_INFO Volume, ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer) +static +BOOLEAN FatReadClusterChain(PFAT_VOLUME_INFO Volume, UINT32 StartClusterNumber, UINT32 NumberOfClusters, PVOID Buffer, PUINT32 LastClusterNumber) { - ULONG ClusterStartSector; + UINT32 ClustersRead, NextClusterNumber, ClustersLeft = NumberOfClusters; TRACE("FatReadClusterChain() StartClusterNumber = %d NumberOfClusters = %d Buffer = 0x%x\n", StartClusterNumber, NumberOfClusters, Buffer); - while (NumberOfClusters > 0) - { + ASSERT(NumberOfClusters > 0); - //TRACE("FatReadClusterChain() StartClusterNumber = %d NumberOfClusters = %d Buffer = 0x%x\n", StartClusterNumber, NumberOfClusters, Buffer); - // - // Calculate starting sector for cluster - // - ClusterStartSector = ((StartClusterNumber - 2) * Volume->SectorsPerCluster) + Volume->DataSectorStart; - - // - // Read cluster into memory - // - if (!FatReadVolumeSectors(Volume, ClusterStartSector, Volume->SectorsPerCluster, Buffer)) - { - return FALSE; - } - - // - // Decrement count of clusters left to read - // - NumberOfClusters--; - - // - // Increment buffer address by cluster size - // - Buffer = (PVOID)((ULONG_PTR)Buffer + (Volume->SectorsPerCluster * Volume->BytesPerSector)); - - // - // Get next cluster - // - if (!FatGetFatEntry(Volume, StartClusterNumber, &StartClusterNumber)) - { - return FALSE; - } + while (FatReadAdjacentClusters(Volume, StartClusterNumber, ClustersLeft, Buffer, &ClustersRead, &NextClusterNumber)) + { + ClustersLeft -= ClustersRead; + Buffer = (PVOID)((ULONG_PTR)Buffer + (ClustersRead * Volume->SectorsPerCluster * Volume->BytesPerSector)); + StartClusterNumber = NextClusterNumber; + } - // - // If end of chain then break out of our cluster reading loop - // - if (((Volume->FatType == FAT12) && (StartClusterNumber >= 0xff8)) || - ((Volume->FatType == FAT16 || Volume->FatType == FATX16) && (StartClusterNumber >= 0xfff8)) || - ((Volume->FatType == FAT32 || Volume->FatType == FATX32) && (StartClusterNumber >= 0x0ffffff8))) - { - break; - } + if (LastClusterNumber) + { + *LastClusterNumber = NextClusterNumber; } - return TRUE; + return (ClustersRead > 0); } /* @@ -1268,14 +1192,11 @@ BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULON * Reads BytesToRead from open file and * returns the number of bytes read in BytesRead */ +static BOOLEAN FatReadFile(PFAT_FILE_INFO FatFileInfo, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer) { PFAT_VOLUME_INFO Volume = FatFileInfo->Volume; - ULONG ClusterNumber; - ULONG OffsetInCluster; - ULONG LengthInCluster; - ULONG NumberOfClusters; - ULONG BytesPerCluster; + UINT32 NextClusterNumber, BytesPerCluster; TRACE("FatReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer); @@ -1342,15 +1263,15 @@ BOOLEAN FatReadFile(PFAT_FILE_INFO FatFileInfo, ULONG BytesToRead, ULONG* BytesR // // Do the math for our first read // - ClusterNumber = (FatFileInfo->FilePointer / BytesPerCluster); - ClusterNumber = FatFileInfo->FileFatChain[ClusterNumber]; - OffsetInCluster = (FatFileInfo->FilePointer % BytesPerCluster); - LengthInCluster = (BytesToRead > (BytesPerCluster - OffsetInCluster)) ? (BytesPerCluster - OffsetInCluster) : BytesToRead; + UINT32 OffsetInCluster = FatFileInfo->FilePointer % BytesPerCluster; + UINT32 LengthInCluster = min(BytesToRead, BytesPerCluster - OffsetInCluster); + + ASSERT(LengthInCluster <= BytesPerCluster && LengthInCluster > 0); // // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer // - if (!FatReadPartialCluster(Volume, ClusterNumber, OffsetInCluster, LengthInCluster, Buffer)) + if (!FatReadPartialCluster(Volume, FatFileInfo->CurrentCluster, OffsetInCluster, LengthInCluster, Buffer)) { return FALSE; } @@ -1361,6 +1282,18 @@ BOOLEAN FatReadFile(PFAT_FILE_INFO FatFileInfo, ULONG BytesToRead, ULONG* BytesR BytesToRead -= LengthInCluster; FatFileInfo->FilePointer += LengthInCluster; Buffer = (PVOID)((ULONG_PTR)Buffer + LengthInCluster); + + // get the next cluster if needed + if ((LengthInCluster + OffsetInCluster) == BytesPerCluster) + { + if (!FatGetFatEntry(Volume, FatFileInfo->CurrentCluster, &NextClusterNumber)) + { + return FALSE; + } + + FatFileInfo->CurrentCluster = NextClusterNumber; + TRACE("FatReadFile() FatFileInfo->CurrentCluster = 0x%x\n", FatFileInfo->CurrentCluster); + } } // @@ -1371,27 +1304,33 @@ BOOLEAN FatReadFile(PFAT_FILE_INFO FatFileInfo, ULONG BytesToRead, ULONG* BytesR // // Determine how many full clusters we need to read // - NumberOfClusters = (BytesToRead / BytesPerCluster); + UINT32 NumberOfClusters = BytesToRead / BytesPerCluster; + + TRACE("Going to read: %u clusters\n", NumberOfClusters); if (NumberOfClusters > 0) { - ClusterNumber = (FatFileInfo->FilePointer / BytesPerCluster); - ClusterNumber = FatFileInfo->FileFatChain[ClusterNumber]; + UINT32 BytesReadHere = NumberOfClusters * BytesPerCluster; - // - // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer - // - if (!FatReadClusterChain(Volume, ClusterNumber, NumberOfClusters, Buffer)) + ASSERT(!FAT_IS_END_CLUSTER(FatFileInfo->CurrentCluster)); + + if (!FatReadClusterChain(Volume, FatFileInfo->CurrentCluster, NumberOfClusters, Buffer, &NextClusterNumber)) { return FALSE; } + if (BytesRead != NULL) { - *BytesRead += (NumberOfClusters * BytesPerCluster); + *BytesRead += BytesReadHere; } - BytesToRead -= (NumberOfClusters * BytesPerCluster); - FatFileInfo->FilePointer += (NumberOfClusters * BytesPerCluster); - Buffer = (PVOID)((ULONG_PTR)Buffer + (NumberOfClusters * BytesPerCluster)); + BytesToRead -= BytesReadHere; + Buffer = (PVOID)((ULONG_PTR)Buffer + BytesReadHere); + + ASSERT(!FAT_IS_END_CLUSTER(NextClusterNumber) || BytesToRead == 0); + + FatFileInfo->FilePointer += BytesReadHere; + FatFileInfo->CurrentCluster = NextClusterNumber; + TRACE("FatReadFile() FatFileInfo->CurrentCluster = 0x%x\n", FatFileInfo->CurrentCluster); } } @@ -1400,13 +1339,12 @@ BOOLEAN FatReadFile(PFAT_FILE_INFO FatFileInfo, ULONG BytesToRead, ULONG* BytesR // if (BytesToRead > 0) { - ClusterNumber = (FatFileInfo->FilePointer / BytesPerCluster); - ClusterNumber = FatFileInfo->FileFatChain[ClusterNumber]; + ASSERT(!FAT_IS_END_CLUSTER(FatFileInfo->CurrentCluster)); // // Now do the read and update BytesRead, BytesToRead, FilePointer, & Buffer // - if (!FatReadPartialCluster(Volume, ClusterNumber, 0, BytesToRead, Buffer)) + if (!FatReadPartialCluster(Volume, FatFileInfo->CurrentCluster, 0, BytesToRead, Buffer)) { return FALSE; } @@ -1460,7 +1398,6 @@ ARC_STATUS FatClose(ULONG FileId) { PFAT_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); - if (FileHandle->FileFatChain) FrLdrTempFree(FileHandle->FileFatChain, TAG_FAT_CHAIN); FrLdrTempFree(FileHandle, TAG_FAT_FILE); return ESUCCESS; @@ -1544,6 +1481,7 @@ ARC_STATUS FatRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count) ARC_STATUS FatSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) { PFAT_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId); + PFAT_VOLUME_INFO Volume = FileHandle->Volume; LARGE_INTEGER NewPosition = *Position; switch (SeekMode) @@ -1551,7 +1489,7 @@ ARC_STATUS FatSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) case SeekAbsolute: break; case SeekRelative: - NewPosition.QuadPart += (ULONGLONG)FileHandle->FilePointer; + NewPosition.QuadPart += (UINT64)FileHandle->FilePointer; break; default: ASSERT(FALSE); @@ -1563,7 +1501,42 @@ ARC_STATUS FatSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) if (NewPosition.LowPart >= FileHandle->FileSize) return EINVAL; + TRACE("FatSeek() NewPosition = %u, OldPointer = %u, SeekMode = %d\n", NewPosition.LowPart, FileHandle->FilePointer, SeekMode); + + { + UINT32 OldClusterIdx = FileHandle->FilePointer / (Volume->SectorsPerCluster * Volume->BytesPerSector); + UINT32 NewClusterIdx = NewPosition.LowPart / (Volume->SectorsPerCluster * Volume->BytesPerSector); + + TRACE("FatSeek() OldClusterIdx: %u, NewClusterIdx: %u\n", OldClusterIdx, NewClusterIdx); + + if (NewClusterIdx != OldClusterIdx) + { + UINT32 CurrentClusterIdx, ClusterNumber; + + if (NewClusterIdx > OldClusterIdx) + { + CurrentClusterIdx = OldClusterIdx; + ClusterNumber = FileHandle->CurrentCluster; + } + else + { + CurrentClusterIdx = 0; + ClusterNumber = FileHandle->StartCluster; + } + + for (; CurrentClusterIdx < NewClusterIdx; CurrentClusterIdx++) + { + if (!FatGetFatEntry(Volume, ClusterNumber, &ClusterNumber)) + { + return EIO; + } + } + FileHandle->CurrentCluster = ClusterNumber; + } + } + FileHandle->FilePointer = NewPosition.LowPart; + return ESUCCESS; }
5 years, 2 months
1
0
0
0
[reactos] 01/02: [FREELDR] Add FAT caching to FAT filesystem driver. This significantly increases the reading speed
by Victor Perevertkin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=195dc3048464db0ff5895…
commit 195dc3048464db0ff58954d3920d1759230dec3c Author: Victor Perevertkin <victor(a)perevertkin.ru> AuthorDate: Tue Jul 9 17:22:28 2019 +0300 Commit: Victor Perevertkin <victor(a)perevertkin.ru> CommitDate: Sun Sep 29 13:24:31 2019 +0300 [FREELDR] Add FAT caching to FAT filesystem driver. This significantly increases the reading speed --- boot/freeldr/freeldr/lib/fs/fat.c | 145 +++++++++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 43 deletions(-) diff --git a/boot/freeldr/freeldr/lib/fs/fat.c b/boot/freeldr/freeldr/lib/fs/fat.c index f16f03a57e1..b973a64dd70 100644 --- a/boot/freeldr/freeldr/lib/fs/fat.c +++ b/boot/freeldr/freeldr/lib/fs/fat.c @@ -39,21 +39,27 @@ BOOLEAN FatReadVolumeSectors(PFAT_VOLUME_INFO Volume, ULONG SectorNumber, ULO #define TAG_FAT_FILE 'FtaF' #define TAG_FAT_VOLUME 'VtaF' #define TAG_FAT_BUFFER 'BtaF' +#define TAG_FAT_CACHE 'HtaF' + +#define FAT_MAX_CACHE_SIZE (256 * 1024) // 256 KiB, note: it should fit maximum FAT12 FAT size (6144 bytes) typedef struct _FAT_VOLUME_INFO { - ULONG BytesPerSector; /* Number of bytes per sector */ - ULONG SectorsPerCluster; /* Number of sectors per cluster */ + PUCHAR FatCache; /* A part of 1st FAT cached in memory */ + PULONG FatCacheIndex; /* Cached sector's indexes */ + ULONG FatCacheSize; /* Size of the cache in sectors */ ULONG FatSectorStart; /* Starting sector of 1st FAT table */ ULONG ActiveFatSectorStart; /* Starting sector of active FAT table */ - ULONG NumberOfFats; /* Number of FAT tables */ ULONG SectorsPerFat; /* Sectors per FAT table */ ULONG RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */ ULONG RootDirSectors; /* Number of sectors of the root directory (non-fat32) */ ULONG RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */ ULONG DataSectorStart; /* Starting sector of the data area */ - ULONG FatType; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */ ULONG DeviceId; + UINT16 BytesPerSector; /* Number of bytes per sector */ + UINT8 FatType; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */ + UINT8 NumberOfFats; /* Number of FAT tables */ + UINT8 SectorsPerCluster; /* Number of sectors per cluster */ } FAT_VOLUME_INFO; PFAT_VOLUME_INFO FatVolumes[MAX_FDS]; @@ -139,7 +145,7 @@ VOID FatSwapFatXDirEntry(PFATX_DIRENTRY Obj) BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR BootSector, ULONGLONG PartitionSectorCount) { char ErrMsg[80]; - ULONG FatSize; + ULONG FatSize, i; PFAT_BOOTSECTOR FatVolumeBootSector; PFAT32_BOOTSECTOR Fat32VolumeBootSector; PFATX_BOOTSECTOR FatXVolumeBootSector; @@ -315,6 +321,39 @@ BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR BootSector, ULONG } } + Volume->FatCacheSize = min(Volume->SectorsPerFat, FAT_MAX_CACHE_SIZE / Volume->BytesPerSector); + TRACE("FAT cache is %d sectors, %d bytes\n", Volume->FatCacheSize, Volume->FatCacheSize * Volume->BytesPerSector); + + Volume->FatCache = FrLdrTempAlloc(Volume->FatCacheSize * Volume->BytesPerSector, TAG_FAT_CACHE); + if (!Volume->FatCache) + { + FileSystemError("Cannot allocate memory for FAT cache"); + return FALSE; + } + + Volume->FatCacheIndex = FrLdrTempAlloc(Volume->FatCacheSize * sizeof(*Volume->FatCacheIndex), TAG_FAT_VOLUME); + if (!Volume->FatCacheIndex) + { + FileSystemError("Cannot allocate memory for FAT cache index"); + FrLdrTempFree(Volume->FatCache, TAG_FAT_CACHE); + return FALSE; + } + + // read the beginning of the FAT (or the whole one) to cache + if (!FatReadVolumeSectors(Volume, Volume->ActiveFatSectorStart, Volume->FatCacheSize, Volume->FatCache)) + { + FileSystemError("Error when reading FAT cache"); + FrLdrTempFree(Volume->FatCache, TAG_FAT_CACHE); + FrLdrTempFree(Volume->FatCacheIndex, TAG_FAT_VOLUME); + return FALSE; + } + + // fill the index with sector numbers + for (i = 0; i < Volume->FatCacheSize; i++) + { + Volume->FatCacheIndex[i] = Volume->ActiveFatSectorStart + i; + } + return TRUE; } @@ -899,54 +938,76 @@ void FatParseShortFileName(PCHAR Buffer, PDIRENTRY DirEntry) //TRACE("FatParseShortFileName() ShortName = %s\n", Buffer); } +/** + * @brief Reads 1-4 sectors from FAT using the cache + */ +static +PUCHAR FatGetFatSector(PFAT_VOLUME_INFO Volume, UINT32 FatSectorNumber) +{ + UINT32 SectorNumAbsolute = Volume->ActiveFatSectorStart + FatSectorNumber; + UINT32 CacheIndex = FatSectorNumber % Volume->FatCacheSize; + + ASSERT(FatSectorNumber < Volume->SectorsPerFat); + + // cache miss + if (Volume->FatCacheIndex[CacheIndex] != SectorNumAbsolute) + { + UINT32 SectorsToRead = min(Volume->FatCacheSize - CacheIndex, min(Volume->SectorsPerFat - SectorNumAbsolute, 4)); + UINT8 i; + + if (!FatReadVolumeSectors(Volume, SectorNumAbsolute, SectorsToRead, &Volume->FatCache[CacheIndex * Volume->BytesPerSector])) + { + return NULL; + } + + for (i = 0; i < SectorsToRead; i++) + { + Volume->FatCacheIndex[CacheIndex + i] = SectorNumAbsolute + i; + } + + TRACE("FAT cache miss: read sector 0x%x from disk\n", SectorNumAbsolute); + } + else + { + TRACE("FAT cache hit: sector 0x%x present\n", SectorNumAbsolute); + } + + return &Volume->FatCache[CacheIndex * Volume->BytesPerSector]; +} + /* * FatGetFatEntry() * returns the Fat entry for a given cluster number */ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPointer) { - ULONG fat = 0; - UINT32 FatOffset; - UINT32 ThisFatSecNum; - UINT32 ThisFatEntOffset; - ULONG SectorCount; + UINT32 FatOffset, ThisFatSecNum, ThisFatEntOffset, fat; PUCHAR ReadBuffer; - BOOLEAN Success = TRUE; - //TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster); - - // We need a buffer for 2 sectors - ReadBuffer = FrLdrTempAlloc(2 * Volume->BytesPerSector, TAG_FAT_BUFFER); - if (!ReadBuffer) - { - return FALSE; - } + TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster); switch(Volume->FatType) { case FAT12: FatOffset = Cluster + (Cluster / 2); - ThisFatSecNum = Volume->ActiveFatSectorStart + (FatOffset / Volume->BytesPerSector); + ThisFatSecNum = FatOffset / Volume->BytesPerSector; ThisFatEntOffset = (FatOffset % Volume->BytesPerSector); TRACE("FatOffset: %d\n", FatOffset); TRACE("ThisFatSecNum: %d\n", ThisFatSecNum); TRACE("ThisFatEntOffset: %d\n", ThisFatEntOffset); - if (ThisFatEntOffset == (Volume->BytesPerSector - 1)) - { - SectorCount = 2; - } - else - { - SectorCount = 1; - } + // The cluster pointer can span within two sectors, but the FatGetFatSector function + // reads 4 sectors most times, except when we are at the edge of FAT cache + // and/or FAT region on the disk. For FAT12 the whole FAT would be cached so + // there will be no situation when the first sector is at the end of the cache + // and the next one is in the beginning - if (!FatReadVolumeSectors(Volume, ThisFatSecNum, SectorCount, ReadBuffer)) + ReadBuffer = FatGetFatSector(Volume, ThisFatSecNum); + if (!ReadBuffer) { - Success = FALSE; - break; + return FALSE; } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); @@ -962,13 +1023,13 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi case FATX16: FatOffset = (Cluster * 2); - ThisFatSecNum = Volume->ActiveFatSectorStart + (FatOffset / Volume->BytesPerSector); + ThisFatSecNum = FatOffset / Volume->BytesPerSector; ThisFatEntOffset = (FatOffset % Volume->BytesPerSector); - if (!FatReadVolumeSectors(Volume, ThisFatSecNum, 1, ReadBuffer)) + ReadBuffer = FatGetFatSector(Volume, ThisFatSecNum); + if (!ReadBuffer) { - Success = FALSE; - break; + return FALSE; } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); @@ -980,10 +1041,11 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi case FATX32: FatOffset = (Cluster * 4); - ThisFatSecNum = Volume->ActiveFatSectorStart + (FatOffset / Volume->BytesPerSector); + ThisFatSecNum = FatOffset / Volume->BytesPerSector; ThisFatEntOffset = (FatOffset % Volume->BytesPerSector); - if (!FatReadVolumeSectors(Volume, ThisFatSecNum, 1, ReadBuffer)) + ReadBuffer = FatGetFatSector(Volume, ThisFatSecNum); + if (!ReadBuffer) { Success = FALSE; break; @@ -997,17 +1059,14 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi default: ERR("Unknown FAT type %d\n", Volume->FatType); - Success = FALSE; - break; + return FALSE; } - //TRACE("FAT entry is 0x%x.\n", fat); - - FrLdrTempFree(ReadBuffer, TAG_FAT_BUFFER); + TRACE("FAT entry is 0x%x.\n", fat); *ClusterPointer = fat; - return Success; + return TRUE; } ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster)
5 years, 2 months
1
0
0
0
[reactos] 01/01: [SHELL] IPersistIDList/IShellLink use P(C)IDLIST_ABSOLUTE. CORE-16385
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=be1f95527ac288872c45a…
commit be1f95527ac288872c45a8b076399590c7db494a Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Sep 22 16:48:04 2019 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Sep 29 12:09:39 2019 +0200 [SHELL] IPersistIDList/IShellLink use P(C)IDLIST_ABSOLUTE. CORE-16385 --- dll/win32/shell32/CShellItem.cpp | 4 ++-- dll/win32/shell32/CShellItem.h | 4 ++-- dll/win32/shell32/CShellLink.cpp | 4 ++-- dll/win32/shell32/CShellLink.h | 8 ++++---- sdk/include/psdk/shobjidl.idl | 12 ++++++------ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dll/win32/shell32/CShellItem.cpp b/dll/win32/shell32/CShellItem.cpp index d403adcf023..f60da93a3f5 100644 --- a/dll/win32/shell32/CShellItem.cpp +++ b/dll/win32/shell32/CShellItem.cpp @@ -233,7 +233,7 @@ HRESULT WINAPI CShellItem::GetClassID(CLSID *pClassID) return S_OK; } -HRESULT WINAPI CShellItem::SetIDList(LPCITEMIDLIST pidlx) +HRESULT WINAPI CShellItem::SetIDList(PCIDLIST_ABSOLUTE pidlx) { LPITEMIDLIST new_pidl; @@ -250,7 +250,7 @@ HRESULT WINAPI CShellItem::SetIDList(LPCITEMIDLIST pidlx) return E_OUTOFMEMORY; } -HRESULT WINAPI CShellItem::GetIDList(LPITEMIDLIST *ppidl) +HRESULT WINAPI CShellItem::GetIDList(PIDLIST_ABSOLUTE *ppidl) { TRACE("(%p,%p)\n", this, ppidl); diff --git a/dll/win32/shell32/CShellItem.h b/dll/win32/shell32/CShellItem.h index 57c318523dd..555501d8cda 100644 --- a/dll/win32/shell32/CShellItem.h +++ b/dll/win32/shell32/CShellItem.h @@ -47,8 +47,8 @@ public: // IPersistIDList virtual HRESULT WINAPI GetClassID(CLSID *pClassID); - virtual HRESULT WINAPI SetIDList(LPCITEMIDLIST pidl); - virtual HRESULT WINAPI GetIDList(LPITEMIDLIST *ppidl); + virtual HRESULT WINAPI SetIDList(PCIDLIST_ABSOLUTE pidl); + virtual HRESULT WINAPI GetIDList(PIDLIST_ABSOLUTE *ppidl); DECLARE_NO_REGISTRY() DECLARE_NOT_AGGREGATABLE(CShellItem) diff --git a/dll/win32/shell32/CShellLink.cpp b/dll/win32/shell32/CShellLink.cpp index 695b83d8bb5..3d7051d9699 100644 --- a/dll/win32/shell32/CShellLink.cpp +++ b/dll/win32/shell32/CShellLink.cpp @@ -1097,7 +1097,7 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetPath(LPSTR pszFile, INT cchMaxPath, WIN return hr; } -HRESULT STDMETHODCALLTYPE CShellLink::GetIDList(LPITEMIDLIST *ppidl) +HRESULT STDMETHODCALLTYPE CShellLink::GetIDList(PIDLIST_ABSOLUTE *ppidl) { TRACE("(%p)->(ppidl=%p)\n", this, ppidl); @@ -1111,7 +1111,7 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIDList(LPITEMIDLIST *ppidl) return S_OK; } -HRESULT STDMETHODCALLTYPE CShellLink::SetIDList(LPCITEMIDLIST pidl) +HRESULT STDMETHODCALLTYPE CShellLink::SetIDList(PCIDLIST_ABSOLUTE pidl) { TRACE("(%p)->(pidl=%p)\n", this, pidl); return SetTargetFromPIDLOrPath(pidl, NULL); diff --git a/dll/win32/shell32/CShellLink.h b/dll/win32/shell32/CShellLink.h index 958eb9d6eff..dac5369fedf 100644 --- a/dll/win32/shell32/CShellLink.h +++ b/dll/win32/shell32/CShellLink.h @@ -129,8 +129,8 @@ public: // IShellLinkA virtual HRESULT STDMETHODCALLTYPE GetPath(LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags); - virtual HRESULT STDMETHODCALLTYPE GetIDList(LPITEMIDLIST *ppidl); - virtual HRESULT STDMETHODCALLTYPE SetIDList(LPCITEMIDLIST pidl); + virtual HRESULT STDMETHODCALLTYPE GetIDList(PIDLIST_ABSOLUTE *ppidl); + virtual HRESULT STDMETHODCALLTYPE SetIDList(PCIDLIST_ABSOLUTE pidl); virtual HRESULT STDMETHODCALLTYPE GetDescription(LPSTR pszName, INT cchMaxName); virtual HRESULT STDMETHODCALLTYPE SetDescription(LPCSTR pszName); virtual HRESULT STDMETHODCALLTYPE GetWorkingDirectory(LPSTR pszDir, INT cchMaxPath); @@ -149,8 +149,8 @@ public: // IShellLinkW virtual HRESULT STDMETHODCALLTYPE GetPath(LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags); - // virtual HRESULT STDMETHODCALLTYPE GetIDList(LPITEMIDLIST *ppidl); - // virtual HRESULT STDMETHODCALLTYPE SetIDList(LPCITEMIDLIST pidl); + // virtual HRESULT STDMETHODCALLTYPE GetIDList(PIDLIST_ABSOLUTE *ppidl); + // virtual HRESULT STDMETHODCALLTYPE SetIDList(PCIDLIST_ABSOLUTE pidl); virtual HRESULT STDMETHODCALLTYPE GetDescription(LPWSTR pszName, INT cchMaxName); virtual HRESULT STDMETHODCALLTYPE SetDescription(LPCWSTR pszName); virtual HRESULT STDMETHODCALLTYPE GetWorkingDirectory(LPWSTR pszDir, INT cchMaxPath); diff --git a/sdk/include/psdk/shobjidl.idl b/sdk/include/psdk/shobjidl.idl index 85c9be1c1e9..c540f232e00 100644 --- a/sdk/include/psdk/shobjidl.idl +++ b/sdk/include/psdk/shobjidl.idl @@ -83,8 +83,8 @@ interface IPersistFolder2 : IPersistFolder ] interface IPersistIDList : IPersist { - HRESULT SetIDList( [in] LPCITEMIDLIST pidl ); - HRESULT GetIDList( [out] LPITEMIDLIST *ppidl ); + HRESULT SetIDList( [in] PCIDLIST_ABSOLUTE pidl ); + HRESULT GetIDList( [out] PIDLIST_ABSOLUTE *ppidl ); } @@ -1139,9 +1139,9 @@ interface IShellLinkA : IUnknown [in, out, unique] WIN32_FIND_DATAA *pfd, [in] DWORD fFlags); - HRESULT GetIDList( [out] LPITEMIDLIST * ppidl ); + HRESULT GetIDList( [out] PIDLIST_ABSOLUTE * ppidl ); - HRESULT SetIDList( [in] LPCITEMIDLIST pidl ); + HRESULT SetIDList( [in] PCIDLIST_ABSOLUTE pidl ); HRESULT GetDescription( [out, size_is(cch)] LPSTR pszName, @@ -1206,9 +1206,9 @@ interface IShellLinkW : IUnknown [in, out] WIN32_FIND_DATAW *pfd, [in] DWORD fFlags); - HRESULT GetIDList( [out] LPITEMIDLIST * ppidl ); + HRESULT GetIDList( [out] PIDLIST_ABSOLUTE * ppidl ); - HRESULT SetIDList( [in] LPCITEMIDLIST pidl ); + HRESULT SetIDList( [in] PCIDLIST_ABSOLUTE pidl ); HRESULT GetDescription( [out, size_is(cch)] LPWSTR pszName,
5 years, 2 months
1
0
0
0
← Newer
1
2
3
4
...
12
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
Results per page:
10
25
50
100
200