diff --git a/DIRS b/DIRS index 5253ecb..61a11c5 100644 --- a/DIRS +++ b/DIRS @@ -1 +1 @@ -DIRS=Ext2Srv Ext3Fsd Ext2Mgr +DIRS=Ext2Srv Ext4Fsd diff --git a/Ext2Mgr/Ext2Mgr.sln b/Ext2Mgr/Ext2Mgr.sln deleted file mode 100644 index 7002a8b..0000000 --- a/Ext2Mgr/Ext2Mgr.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Mgr", "Ext2Mgr.vcproj", "{F0E304B5-AF20-49F7-8183-5994C6EA889D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.ActiveCfg = Debug|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.Build.0 = Debug|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.ActiveCfg = Release|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Ext2Mgr/Ext2Mgr.vcproj b/Ext2Mgr/Ext2Mgr.vcproj deleted file mode 100644 index 0f6fe37..0000000 --- a/Ext2Mgr/Ext2Mgr.vcproj +++ /dev/null @@ -1,914 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Ext2Mgr/Ext2Mgr.vcxproj b/Ext2Mgr/Ext2Mgr.vcxproj new file mode 100644 index 0000000..68911b3 --- /dev/null +++ b/Ext2Mgr/Ext2Mgr.vcxproj @@ -0,0 +1,225 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E} + Ext2Mgr + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + Dynamic + + + Application + false + v141 + true + MultiByte + Dynamic + + + Application + true + v141 + MultiByte + Dynamic + + + Application + false + v141 + true + MultiByte + Dynamic + + + + + + + + + + + + + + + + + + + + + Ext2Mgr + $(SolutionDir)Ext2Mgr\$(Configuration)\x86\ + $(Configuration)\x86\ + + + Ext2Mgr + $(SolutionDir)Ext2Mgr\$(Configuration)\x86\ + $(Configuration)\x86\ + + + Ext2Mgr + $(SolutionDir)Ext2Mgr\$(Configuration)\x64\ + $(Configuration)\x64\ + + + Ext2Mgr + $(SolutionDir)Ext2Mgr\$(Configuration)\x64\ + $(Configuration)\x64\ + + + + Level3 + Disabled + true + true + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions) + 4996;4703;%(DisableSpecificWarnings) + $(UM_IncludePath)\..\km;%(AdditionalIncludeDirectories) + + + Windows + ntdll.lib;setupapi.lib;%(AdditionalDependencies) + + + + + Level3 + Disabled + true + true + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions) + 4996;4703;%(DisableSpecificWarnings) + $(UM_IncludePath)\..\km;%(AdditionalIncludeDirectories) + + + Windows + ntdll.lib;setupapi.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + true + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions) + 4996;4703;%(DisableSpecificWarnings) + $(UM_IncludePath)\..\km;%(AdditionalIncludeDirectories) + + + true + true + Windows + ntdll.lib;setupapi.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + true + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions) + 4996;4703;%(DisableSpecificWarnings) + $(UM_IncludePath)\..\km;%(AdditionalIncludeDirectories) + + + true + true + Windows + ntdll.lib;setupapi.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ext2Mgr/Ext2Mgr.vcxproj.filters b/Ext2Mgr/Ext2Mgr.vcxproj.filters new file mode 100644 index 0000000..2fa5093 --- /dev/null +++ b/Ext2Mgr/Ext2Mgr.vcxproj.filters @@ -0,0 +1,167 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/Ext2Mgr/MAKEFILE b/Ext2Mgr/MAKEFILE deleted file mode 100644 index ef95367..0000000 --- a/Ext2Mgr/MAKEFILE +++ /dev/null @@ -1,11 +0,0 @@ -BUILD_ALLOW_COMPILER_WARNINGS=1 -BUILD_ALLOW_LINKER_WARNINGS=1 - -# -# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source -# file to this component. This file merely indirects to the real make file -# that is shared by all the driver components of the Windows NT DDK -# - -!INCLUDE $(NTMAKEENV)\makefile.def - diff --git a/Ext2Mgr/SOURCES b/Ext2Mgr/SOURCES deleted file mode 100644 index 9d4e451..0000000 --- a/Ext2Mgr/SOURCES +++ /dev/null @@ -1,32 +0,0 @@ -TARGETNAME=Ext2Mgr -TARGETPATH=obj -TARGETTYPE=PROGRAM - -USE_MFC=1 - -!IF $(_NT_TARGET_VERSION) > 0x500 -C_DEFINES=/DUSE_MFC6_WITH_ATL7=1,$(C_DEFINES) -!ENDIF -INCLUDES= .;..\Ext2Srv\;..\Ext3Fsd\include;..\Ext2Srv\Libraries; \ - $(DDK_INC_PATH);$(SDK_INC_PATH); $(MFC_INC_PATH); \ - $(MFC_INC_PATH)\..\atlmfc;$(INCLUDES) -TARGETLIBS= $(DDK_LIB_PATH)\ntdll.lib $(DDK_LIB_PATH)\setupapi.lib \ - $(DDK_LIB_PATH)\shell32.lib $(DDK_LIB_PATH)\Comctl32.lib - -PRECOMPILED_CXX=1 -PRECOMPILED_INCLUDE=stdafx.h - -SXS_MANIFEST=Ext2Mgr.exe.manifest -SXS_ASSEMBLY_NAME=Ext2Mgr -SXS_ASSEMBLY_VERSION=1.0 -SXS_ASSEMBLY_LANGUAGE_INDEPENDENT=1 -SXS_MANIFEST_IN_RESOURCES=1 - -SOURCES= DelDeadLetter.cpp DiskBox.cpp DlgView.cpp \ - Donate.cpp enumDisk.cpp Ext2Attribute.cpp \ - Ext2Mgr.cpp Ext2MgrDlg.cpp Ext2Pipe.cpp \ - HyperLink.cpp MountPoints.cpp PartBox.cpp \ - PartitionType.cpp PerfStatDlg.cpp Properties.cpp \ - SelectDrvLetter.cpp ServiceManage.cpp Splash.cpp \ - SysTray.cpp toolbar.cpp TreeList.cpp \ - Ext2Mgr.rc diff --git a/Ext2Mgr/astyle.bat b/Ext2Mgr/astyle.bat deleted file mode 100644 index d36082a..0000000 --- a/Ext2Mgr/astyle.bat +++ /dev/null @@ -1,2 +0,0 @@ -for /R %%a in (*.c;*.cpp;*.h;) do astyle.exe --indent=spaces=4 %%a -for /R %%a in (*.c;*.cpp;*.h;DIRS;sources;) do dos2unix %%a diff --git a/Ext2Mgr/enumDisk.h b/Ext2Mgr/enumDisk.h index e3e3139..ef1270d 100644 --- a/Ext2Mgr/enumDisk.h +++ b/Ext2Mgr/enumDisk.h @@ -334,7 +334,7 @@ typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, DWORD ClusterSize, PFMIFSCALLBACK Callback ); -#include "..\ext3fsd\include\common.h" +#include "..\ext4fsd\include\common.h" /* * structure definitions diff --git a/Ext2Srv/Ext2Srv.sln b/Ext2Srv/Ext2Srv.sln deleted file mode 100644 index 10d0cac..0000000 --- a/Ext2Srv/Ext2Srv.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Srv", "Ext2Srv.vcproj", "{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}" -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 1 - SccProjectUniqueName0 = Ext2Srv.vcproj - SccProjectName0 = Ext2Srv - SccLocalPath0 = . - SccProvider0 = MSSCCI:Perforce\u0020P4\u0020SCM - CanCheckoutShared = true - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.ActiveCfg = Debug|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.Build.0 = Debug|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.ActiveCfg = Release|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Ext2Srv/Ext2Srv.vcproj b/Ext2Srv/Ext2Srv.vcproj deleted file mode 100644 index 99f7b99..0000000 --- a/Ext2Srv/Ext2Srv.vcproj +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Ext2Srv/Ext2Srv.vcxproj b/Ext2Srv/Ext2Srv.vcxproj new file mode 100644 index 0000000..d5c4583 --- /dev/null +++ b/Ext2Srv/Ext2Srv.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20} + Ext2Srv + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + Ext2Srv + $(SolutionDir)Ext2Srv\$(Configuration)\x86\ + $(Configuration)\x86\ + + + Ext2Srv + $(SolutionDir)Ext2Srv\$(Configuration)\x86\ + $(Configuration)\x86\ + + + Ext2Srv + $(SolutionDir)Ext2Srv\$(Configuration)\x64\ + $(Configuration)\x64\ + + + Ext2Srv + $(SolutionDir)Ext2Srv\$(Configuration)\x64\ + $(Configuration)\x64\ + + + + Level3 + Disabled + true + true + ./;%(AdditionalIncludeDirectories) + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Wtsapi32.lib;%(AdditionalDependencies) + + + + + Level3 + Disabled + true + true + ./;%(AdditionalIncludeDirectories) + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Wtsapi32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + true + ./;%(AdditionalIncludeDirectories) + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + Wtsapi32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + true + ./;%(AdditionalIncludeDirectories) + /Zc:strictStrings- %(AdditionalOptions) + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + Wtsapi32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + diff --git a/Ext2Srv/Ext2Srv.vcxproj.filters b/Ext2Srv/Ext2Srv.vcxproj.filters new file mode 100644 index 0000000..9c32aad --- /dev/null +++ b/Ext2Srv/Ext2Srv.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/Ext2Srv/Release/X86/Ext2Srv.exe b/Ext2Srv/Release/X86/Ext2Srv.exe deleted file mode 100644 index ec001c8..0000000 Binary files a/Ext2Srv/Release/X86/Ext2Srv.exe and /dev/null differ diff --git a/Ext3Fsd.sln b/Ext3Fsd.sln deleted file mode 100644 index 08c2075..0000000 --- a/Ext3Fsd.sln +++ /dev/null @@ -1,45 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext3Fsd", "Ext3Fsd\ext3fsd.vcproj", "{2328F787-71B4-408B-8E10-B7A95BF9A110}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Mgr", "Ext2Mgr\Ext2Mgr.vcproj", "{F0E304B5-AF20-49F7-8183-5994C6EA889D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Srv", "Ext2Srv\Ext2Srv.vcproj", "{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}" -EndProject -Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 2 - SccProjectUniqueName0 = Ext3Fsd\\ext3fsd.vcproj - SccProjectName0 = Ext3Fsd - SccLocalPath0 = Ext3Fsd - SccProvider0 = MSSCCI:Perforce\u0020P4\u0020SCM - CanCheckoutShared = true - SccProjectUniqueName1 = Ext2Srv\\Ext2Srv.vcproj - SccProjectName1 = Ext2Srv - SccLocalPath1 = Ext2Srv - SccProvider1 = MSSCCI:Perforce\u0020P4\u0020SCM - CanCheckoutShared = true - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2328F787-71B4-408B-8E10-B7A95BF9A110}.Debug|Win32.ActiveCfg = Debug|Win32 - {2328F787-71B4-408B-8E10-B7A95BF9A110}.Debug|Win32.Build.0 = Debug|Win32 - {2328F787-71B4-408B-8E10-B7A95BF9A110}.Release|Win32.ActiveCfg = Release|Win32 - {2328F787-71B4-408B-8E10-B7A95BF9A110}.Release|Win32.Build.0 = Release|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.ActiveCfg = Debug|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.Build.0 = Debug|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.ActiveCfg = Release|Win32 - {F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.Build.0 = Release|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.ActiveCfg = Debug|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.Build.0 = Debug|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.ActiveCfg = Release|Win32 - {A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Ext4Fsd.sln b/Ext4Fsd.sln new file mode 100644 index 0000000..6e5e485 --- /dev/null +++ b/Ext4Fsd.sln @@ -0,0 +1,82 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.421 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Mgr", "Ext2Mgr\Ext2Mgr.vcxproj", "{E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}" + ProjectSection(ProjectDependencies) = postProject + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20} = {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Srv", "Ext2Srv\Ext2Srv.vcxproj", "{6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext4Fsd", "Ext4Fsd\Ext4Fsd.vcxproj", "{E98007B5-02C6-4C8F-BB89-E0D530991559}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|ARM.ActiveCfg = Debug|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|ARM64.ActiveCfg = Debug|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|x64.ActiveCfg = Debug|x64 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|x64.Build.0 = Debug|x64 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|x86.ActiveCfg = Debug|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Debug|x86.Build.0 = Debug|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|ARM.ActiveCfg = Release|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|ARM64.ActiveCfg = Release|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|x64.ActiveCfg = Release|x64 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|x64.Build.0 = Release|x64 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|x86.ActiveCfg = Release|Win32 + {E1AF85D7-0179-4CF0-B0D1-21AE72B6DC2E}.Release|x86.Build.0 = Release|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|ARM.ActiveCfg = Debug|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|x64.ActiveCfg = Debug|x64 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|x64.Build.0 = Debug|x64 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|x86.ActiveCfg = Debug|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Debug|x86.Build.0 = Debug|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|ARM.ActiveCfg = Release|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|ARM64.ActiveCfg = Release|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|x64.ActiveCfg = Release|x64 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|x64.Build.0 = Release|x64 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|x86.ActiveCfg = Release|Win32 + {6A5A0B13-7E05-4CA9-9A2B-FADF76DBAC20}.Release|x86.Build.0 = Release|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM.ActiveCfg = Debug|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM.Build.0 = Debug|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM.Deploy.0 = Debug|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM64.Build.0 = Debug|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x64.ActiveCfg = Debug|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x64.Build.0 = Debug|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x64.Deploy.0 = Debug|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x86.ActiveCfg = Debug|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x86.Build.0 = Debug|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Debug|x86.Deploy.0 = Debug|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM.ActiveCfg = Release|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM.Build.0 = Release|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM.Deploy.0 = Release|ARM + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM64.ActiveCfg = Release|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM64.Build.0 = Release|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|ARM64.Deploy.0 = Release|ARM64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x64.ActiveCfg = Release|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x64.Build.0 = Release|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x64.Deploy.0 = Release|x64 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x86.ActiveCfg = Release|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x86.Build.0 = Release|Win32 + {E98007B5-02C6-4C8F-BB89-E0D530991559}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8457A620-F40D-45A4-8FE0-1174D4E299ED} + EndGlobalSection +EndGlobal diff --git a/Ext4Fsd/Ext4Fsd.vcxproj b/Ext4Fsd/Ext4Fsd.vcxproj new file mode 100644 index 0000000..8dd722f --- /dev/null +++ b/Ext4Fsd/Ext4Fsd.vcxproj @@ -0,0 +1,285 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + {E98007B5-02C6-4C8F-BB89-E0D530991559} + {dd38f7fc-d7bd-488b-9242-7d8754cde80d} + v4.5 + 12.0 + Debug + Win32 + Ext4Fsd + $(LatestTargetPlatformVersion) + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + 1 + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + 1 + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + 1 + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + 1 + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + WDM + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + WDM + + + + + + + + + + + DbgengKernelDebugger + $(SolutionDir)Ext4Fsd\$(ConfigurationName)\x86\ + $(ConfigurationName)\x86\ + Ext4Fsd + + + DbgengKernelDebugger + $(SolutionDir)Ext4Fsd\$(ConfigurationName)\x86\ + $(ConfigurationName)\x86\ + Ext4Fsd + + + DbgengKernelDebugger + $(SolutionDir)Ext4Fsd\$(ConfigurationName)\x64\ + $(ConfigurationName)\x64\ + Ext4Fsd + + + DbgengKernelDebugger + $(SolutionDir)Ext4Fsd\$(ConfigurationName)\x64\ + $(ConfigurationName)\x64\ + Ext4Fsd + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + + .\include;.\include\linux;.\include\asm;%(AdditionalIncludeDirectories) + Level3 + __KERNEL__;%(PreprocessorDefinitions) + 4995;%(DisableSpecificWarnings) + + + %(AdditionalDependencies) + + + + + .\include;.\include\linux;.\include\asm;%(AdditionalIncludeDirectories) + Level3 + __KERNEL__;%(PreprocessorDefinitions) + 4995;%(DisableSpecificWarnings) + + + %(AdditionalDependencies) + + + + + .\include;.\include\linux;.\include\asm;%(AdditionalIncludeDirectories) + Level3 + __KERNEL__;%(PreprocessorDefinitions) + 4995;%(DisableSpecificWarnings) + + + + + .\include;.\include\linux;.\include\asm;%(AdditionalIncludeDirectories) + Level3 + __KERNEL__;%(PreprocessorDefinitions) + 4995;%(DisableSpecificWarnings) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ext4Fsd/Ext4Fsd.vcxproj.filters b/Ext4Fsd/Ext4Fsd.vcxproj.filters new file mode 100644 index 0000000..25e1fc5 --- /dev/null +++ b/Ext4Fsd/Ext4Fsd.vcxproj.filters @@ -0,0 +1,288 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + {13adb2ad-f681-4c9e-a21e-0fd46bbef319} + + + {9ab142d9-f11c-4d93-b92a-0df6595d2e24} + + + {3e51e838-e180-44c1-ae2d-53cf5297396b} + + + {94a9d102-6815-4f19-9b62-763fe5d482ca} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\ext3 + + + Source Files\ext3 + + + Source Files\ext3 + + + Source Files\ext3 + + + Source Files\ext4 + + + Source Files\ext4 + + + Source Files\ext4 + + + Source Files\ext4 + + + Source Files\ext4 + + + Source Files\jbd + + + Source Files\jbd + + + Source Files\jbd + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + Source Files\nls + + + + + Resource Files + + + + + Header Files + + + \ No newline at end of file diff --git a/Ext4Fsd/ddkbuild.bat b/Ext4Fsd/ddkbuild.bat deleted file mode 100644 index 50f1d9d..0000000 --- a/Ext4Fsd/ddkbuild.bat +++ /dev/null @@ -1,1268 +0,0 @@ -@echo off -@set VERSION=V7.4 -@set OSR_DEBUG=off - -set W7BASE=C:\WINDDK\7600.16385.1 - -@if "%OS%"=="Windows_NT" goto :Prerequisites -@echo This script requires Windows NT 4.0 or later to run properly! -goto :EOF -:Prerequisites -:: Check whether FINDSTR is available. It's used to show warnings etc. -findstr /? > NUL 2>&1 || echo "FINDSTR is a prerequisite but wasn't found!" && goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: $Id: ddkbuild.cmd 43 2009-11-12 03:46:08Z oliver $ -:: -:: This software is supplied for instructional purposes only. -:: -:: OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty -:: for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY -:: OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, -:: THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR -:: PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS -:: WITH YOU. OSR's entire liability and your exclusive remedy shall not -:: exceed the price paid for this material. In no event shall OSR or its -:: suppliers be liable for any damages whatsoever (including, without -:: limitation, damages for loss of business profit, business interruption, -:: loss of business information, or any other pecuniary loss) arising out -:: of the use or inability to use this software, even if OSR has been -:: advised of the possibility of such damages. Because some states/ -:: jurisdictions do not allow the exclusion or limitation of liability for -:: consequential or incidental damages, the above limitation may not apply -:: to you. -:: -:: OSR Open Systems Resources, Inc. -:: 105 Route 101A Suite 19 -:: Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503 -:: report bugs to -:: alternatively report them via -:: -:: -:: MODULE: -:: -:: ddkbuild.cmd -:: -:: ABSTRACT: -:: -:: This script allows drivers to be built with Visual Studio 2002 through -:: Visual Studio 2008 and possibly future versions. It will also work fine -:: from the command line. -:: If you are interested in a project wizard that makes use of this script, -:: try DDKWizard from . -:: -:: AUTHOR(S): -:: -:: - OSR Open Systems Resources, Inc. -:: - Oliver Schneider (ddkwizard.assarbad.net) -:: -:: REQUIREMENTS: -:: -:: Environment variables that must be set. -:: %NT4BASE% - Set this up for "-NT4" builds (legacy, support not tested) -:: %W2KBASE% - Set this up for "-W2K*" builds (legacy, support not tested) -:: %WXPBASE% - Set this up for "-WXP*" builds -:: %WNETBASE% - Set this up for "-WNET*" builds -:: %WLHBASE% - Set this up for "-WLH*" builds -:: %W7BASE% - Set this up for "-W7*" builds -:: %WDF_ROOT% - Must be set if attempting to do a WDF Build. -:: -:: Examples: -:: NT4BASE : could be "D:\NT4DDK" -:: W2KBASE : could be "D:\Nt50DDK" -:: WXPBASE : could be "D:\WINDDK\2600" -:: WNETBASE: could be "D:\WINDDK\3790.1830" or "C:\WINDDK\3790" -:: W7BASE : could be "C:\WINDDK\7600.16385.0" -:: -:: COMMAND FORMAT: -:: -:: Run the script without any parameters to get the whole help content! -:: Note: "-WDF" has been tested with the 01.00.5054 version of the framework -:: -:: RETURN CODES AND THEIR MEANING: -:: -:: 001 == Unknown type of build. Please recheck parameters. -:: 002 == WDF_ROOT is not defined, are you using 00.01.5054 or later? -:: 003 == To build using type you need to set the -:: environment variable to point to the DDK base -:: directory! -:: 004 == NT4BASE, W2KBASE, WXPBASE, WNETBASE and/or W7BASE environment -:: variable(s) not set. Environment variable(s) must be set by user -:: according to DDK version(s) installed. -:: 005 == must be 'checked', 'free', 'chk' or 'fre' -:: (case-insensitive). -:: 006 == No DIR or SOURCES file found in the given target directory. -:: 007 == Target directory must have a SOURCES+MAKEFILE or DIRS file. -:: 008 == The parameter must be a valid directory. -:: 009 == The SETENV script failed. -:: -:: Note: If %OSR_ERRCODE% and %ERRORLEVEL% are equal, the return code stems -:: from one of the tools being called during the build process. -:: -:: BROWSE FILES: -:: -:: This procedure supports the building of BROWSE files to be used by -:: Visual Studio 6 and by Visual Studio.NET However, the BSCfiles created -:: by bscmake for the two are not compatible. When this command procedure -:: runs, it selects the first bscmake.exe found in the path. So, make sure -:: that the correct bscmake.exe is in the path ... -:: -:: Note that if using Visual Studio.NET the .BSC must be added to the project -:: in order for the project to be browsed. -:: Another alternative is the VS addon named "Visual Assist X" which will -:: parse the header files - no more need for browse files. -:: -:: COMPILERS: -:: -:: If you are building NT4 you should really be using the VC6 compiler. -:: Later versions of the DDK now contain the compiler and the linker. This -:: procedure should use the correct compiler. -:: -:: GENERAL COMMENTS: -:: -:: This procedure has been cleaned up to be modular and easy to understand. -:: -:: As of the Server 2003 SP1 DDK DDKBUILD now clears the NO_BROWSE_FILE and -:: NO_BINPLACE environment variables so that users can use these features. -:: -:: Starting with the Vista WDK, the output in the respective tool window -:: in VS is in Unicode by default. This garbles the output from DDKBUILD -:: and we therefore clear the environment variable VS_UNICODE_OUTPUT. -:: -:: To modify the default behavior of this script with the newest WDKs, -:: set the variable SETTING_OACR in the ddkbldenv.cmd hook script to turn -:: OACR back on (NB: no OACR tools exist for Itanium in the WDK). -:: -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / MAIN function of the script -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:MAIN -:: Building "stack frame" -setlocal ENABLEEXTENSIONS & pushd . -:: Check whether the REG utility is available -reg /? > NUL 2>&1 && set OSR_REGAVAILABLE=1 - -:: This is set by client-side keyword substitution -set SVN_REVISION=$Revision: 43 $ -:: Extract the revision number from the revision keyword -set SVN_REVISION=%SVN_REVISION:~0,-2% -set SVN_REVISION=%SVN_REVISION:~11% -:: This is set by client-side keyword substitution -set SVN_REVDATE=$Date: 2009-11-12 03:46:08 +0000 (Thu, 12 Nov 2009) $ -:: Extract the date from the Date keyword -set SVN_REVDATE=%SVN_REVDATE:~7,10% -set VERSION=%VERSION%/r%SVN_REVISION% - -:: Init some special variables -set OSR_VERSTR=OSR DDKBUILD.CMD %VERSION% (%SVN_REVDATE%) - OSR, Open Systems Resources, Inc. -set OSR_PREBUILD_SCRIPT=ddkprebld.cmd -set OSR_POSTBUILD_SCRIPT=ddkpostbld.cmd -set OSR_SETENV_SCRIPT=ddkbldenv.cmd -set OSR_ECHO=@echo DDKBLD: -set OSR_RANDEXT=%RANDOM%%RANDOM% - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Set error messages -:: Possible codes: 1 -set ERR_UnknownBuildType=Unknown type of build. Please recheck parameters. -:: Possible codes: 2 -set ERR_NoWdfRoot=WDF_ROOT is not defined, are you using 00.01.5054 or later? -:: Possible codes: 3 -set ERR_BaseDirNotSet=To build using type %%OSR_TARGET%% you need to set the %%%%%%BASEDIRVAR%%%%%% environment variable to point to the %%BASEDIROS%% DDK base directory! -:: Possible codes: 4 -set ERR_NoBASEDIR=NT4BASE, W2KBASE, WXPBASE, WNETBASE and/or W7BASE environment variable(s) not set. Environment variable(s) must be set by user according to DDK version(s) installed. -:: Possible codes: 5 -set ERR_BadMode=^ must be 'checked', 'free', 'chk' or 'fre' (case-insensitive). -:: Possible codes: 6 -set ERR_NoTarget=Target directory must have a SOURCES+MAKEFILE or DIRS file. -:: Possible codes: 7, 8 -set ERR_NoDir=The ^ parameter must be a valid directory. -:: Possible codes: 9 -set ERR_SetEnvFailed=The SETENV script failed. - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Clear the error code variable -set OSR_ERRCODE=0 -set PREFAST_BUILD=0 - -:: Turn on tracing, use %OSR_TRACE% instead of ECHO -if /i "%OSR_DEBUG%" == "on" (set OSR_TRACE=%OSR_ECHO% [TRACE]) else (set OSR_TRACE=rem) -:: Turn on echoing of current line if %OSR_DEBUG% is set to "on" -@echo %OSR_DEBUG% - -:: Output version string -@echo %OSR_VERSTR% -%OSR_TRACE% ^(Current module: ^"%~f0^"^) -@echo. - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Set the target platform variable -set OSR_TARGET=%~1 -:: Remove any dashes in the variable -if not "%OSR_TARGET%" == "" set OSR_TARGET=%OSR_TARGET:-=% -:: Show help if the target parameter is empty after removal of the dashes -if "%OSR_TARGET%" == "" goto :USAGE - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: In the build directory check for this script and call it if it exists. -:: This allows to override any global system variable setting, if desired. -if not "%3" == "" call :GetCustomEnvironment "%~f3" -if not "%OSR_ERRCODE%" == "0" goto :USAGE -:: Additional error handling for better usability -:: These subroutines will also attempt to locate the requested DDK!!! -set OSR_ERRCODE=3 -%OSR_TRACE% Checking whether the environment variable for the build type was set -:: Calling as a subroutine has 2 advantages: -:: 1. the script does not quit if the label was not found -:: 2. we return to the line after the call and can check variables there -call :%OSR_TARGET%Check > NUL 2>&1 -:: If the BASEDIROS/BASEDIRVAR variable is not defined, it means the subroutine did not exist! -if not DEFINED BASEDIROS call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIROS)" & goto :USAGE -if not DEFINED BASEDIRVAR call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIRVAR)" & goto :USAGE -if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_BaseDirNotSet%" & goto :USAGE - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -set BASEDIR=%%%BASEDIRVAR%%% -call :ResolveVar BASEDIR -call :MakeShort BASEDIR "%BASEDIR%" -:: Check for existing %BASEDIR% -if "%BASEDIR%" == "" call :ShowErrorMsg 4 "%ERR_NoBASEDIR%" & goto :USAGE -set PATH=%BASEDIR%\bin;%PATH% -%OSR_TRACE% Now jump to the initialization of the commandline -:: Calling as a subroutine has 2 advantages: -:: 1. the script does not quit if the label was not found -:: 2. we return to the line after the call and can check variables there -call :%OSR_TARGET%Build - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -%OSR_TRACE% We returned from the variable initialization -if not DEFINED OSR_CMDLINE call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (OSR_CMDLINE)" & goto :USAGE - -%OSR_TRACE% Hurrah, all the variables have been initialized, continuing -:: Proceed with common build steps -goto :CommonBuild - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Check whether the parameter makes sense and try to -:: correct it if possible -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: These labels are for compatibility with the respective -:: modes supported by another flavor of DDKBUILD. -:WIN7Check -:WIN764Check -:WIN7A64Check -:WIN7WLHCheck -:WIN7WLH64Check -:WIN7WLHA64Check -:WIN7NETCheck -:WIN7NET64Check -:WIN7NETA64Check -:WIN7XPCheck -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:W7Check -:W7I64Check -:W7X64Check -:W7LHCheck -:W7LHI64Check -:W7LHX64Check -:W7NETCheck -:W7NETI64Check -:W7NETX64Check -:W7XPCheck -set BASEDIROS=Windows 7/Windows 2008 Server R2 -set BASEDIRVAR=W7BASE -:: The default for OACR is off ("no_oacr" appended) -if not DEFINED SETTING_OACR set SETTING_OACR=no_oacr -:: The default for "separate_object_root" is to not pass it to setenv.bat -if not DEFINED SETTING_SEP_OBJ_ROOT set SETTING_SEPARATE_OBJ_ROOT= -:: Other flavor of DDKBUILD -if not DEFINED W7BASE if DEFINED WIN7BASE set BASEDIRVAR=WIN7BASE -:: Compatibility between BUILD and VS ... prevent pipes from being used -%OSR_ECHO% Clearing %%VS_UNICODE_OUTPUT%% ... -set VS_UNICODE_OUTPUT= -:: Return to caller if the BASEDIR is already defined (either customized or global) -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :DetectBaseDirTemp "7600.16385.0" -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn -goto :CommonCheckErrorNotSupportedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: These labels are for compatibility with the respective -:: modes supported by another flavor of DDKBUILD. -:WLH64Check -:WLHA64Check -:WLHXP64Check -:WLHNET64Check -:WLHNETA64Check -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:WLHCheck -:WLHX64Check -:WLHI64Check -:WLHNETX64Check -:WLHNETI64Check -:WLHXPCheck -:WLH2KCheck -:WLHNETCheck -set BASEDIROS=Windows Vista/Windows 2008 Server -set BASEDIRVAR=WLHBASE -:: Compatibility between BUILD and VS ... prevent pipes from being used -%OSR_ECHO% Clearing %%VS_UNICODE_OUTPUT%% ... -set VS_UNICODE_OUTPUT= -:: Return to caller if the BASEDIR is already defined (either customized or global) -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :DetectBaseDirTemp "6001.18002 6001.18001 6001.18000 6000" -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn -goto :CommonCheckErrorNotSupportedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: These labels are for compatibility with the respective -:: modes supported by another flavor of DDKBUILD. -:WNETW2KCheck -:WNETA64Check -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:WNET2KCheck -:WNETXPCheck -:WNETXP64Check -:WNET64Check -:WNETI64Check -:WNETAMD64Check -:WNETX64Check -:WNETCheck -set BASEDIROS=Windows 2003 Server -set BASEDIRVAR=WNETBASE -:: Return to caller if the BASEDIR is already defined (either customized or global) -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :DetectBaseDirTemp "3790.1830 3790.1218 3790" -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn -goto :CommonCheckErrorNotDetectedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: These labels are for compatibility with the respective -:: modes supported by another flavor of DDKBUILD. -:XPCheck -:XP64Check -:XPW2KCheck -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:WXP64Check -:WXPI64Check -:WXPCheck -:WXP2KCheck -set BASEDIROS=Windows XP -set BASEDIRVAR=WXPBASE -:: Other flavor of DDKBUILD -if not DEFINED WXPBASE if DEFINED XPBASE set BASEDIRVAR=XPBASE -:: Return to caller if the BASEDIR is already defined (either customized or global) -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :DetectBaseDirTemp "2600.1106 2600" -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn -goto :CommonCheckErrorNotDetectedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:W2K64Check -:W2KI64Check -:W2KCheck -set BASEDIROS=Windows 2000 -set BASEDIRVAR=W2KBASE -:: Return to caller -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :CommonCheckMsg2 -goto :CommonCheckErrorNotSupportedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:NT4Check -set BASEDIROS=Windows NT4 -set BASEDIRVAR=NT4BASE -:: Return to caller -if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn -call :CommonCheckMsg2 -goto :CommonCheckErrorNotSupportedWithReturn - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:CommonCheckMsg1 -echo. -%OSR_ECHO% WARNING: %%%BASEDIRVAR%%% NOT SET! -%OSR_ECHO% Attempting to auto-detect the installation folder and set %%%BASEDIRVAR%%%. -%OSR_ECHO% (If this fails *you* will have to set it!) -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:CommonCheckMsg2 -echo. -%OSR_ECHO% WARNING: -%OSR_ECHO% Auto-detection of the folder settings is not supported for the requested DDK. -%OSR_ECHO% Please set %%%BASEDIRVAR%%% yourself! -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:CommonCheckSetVarWithReturn -%OSR_ECHO% Found! -echo. -set %BASEDIRVAR%=%BASEDIRTEMP% -set BASEDIRTEMP= -:: Tell the caller it was successful -:CommonCheckNoErrorWithReturn -set OSR_ERRCODE=0 -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:CommonCheckErrorNotDetectedWithReturn -echo. -%OSR_ECHO% None of the usual default paths works. Set %%%BASEDIRVAR%%% manually! -:CommonCheckErrorNotSupportedWithReturn -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Initialize variables specific to the respective platform -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Valid parameters for setenv in different DDKs/WDKs: -:: -:: 2600 - "setenv [fre|chk] [64] [hal]" -:: 2600.1106 - "setenv [fre|chk] [64] [hal] [WXP|W2K]" -:: 3790 - "setenv [fre|chk] [64|AMD64] [hal] [WXP|WNET|W2K]" -:: 3790.1830 - "setenv [fre|chk] [64|AMD64] [hal] [WXP|WNET|W2K] [no_prefast] [bscmake]" -:: 6000 - "setenv [fre|chk] [64|AMD64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" -:: 6001.18000 - "setenv [fre|chk] [64|x64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" -:: 6001.18001 - "setenv [fre|chk] [64|x64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" -:: 6001.18002 - "setenv [fre|chk] [64|x64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" -:: 7600.16385 - "setenv [fre|chk] [64|x64] [WIN7|WLH|WXP|WNET] [bscmake] [no_oacr] [separate_object_root]" - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: NT 4.0 build using NT4 DDK -:NT4Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% "%%MSDEVDIR%%" -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W2K build for 32bit using WXP DDK -:XPW2KBuild -:WXP2KBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\w2k\set2k.bat" %%BASEDIR%% %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W2K build for 64bit (Itanium) using W2K DDK -:W2K64Build -:W2KI64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv64.bat" %%BASEDIR%% %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W2K build for 32bit using W2K DDK -:W2KBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 64bit (Itanium) using WXP DDK -:XP64Build -:WXP64Build -:WXPI64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 32bit using WXP DDK -:XPBuild -:WXPBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W2K build for 32bit using WNET DDK -:WNETW2KBuild -:WNET2KBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% W2K %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 32bit using WNET DDK -:WNETXPBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WXP -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 64bit using WNET DDK -:WNETXP64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WXP -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (Itanium) using WNET DDK -:WNET64Build -:WNETI64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WNET -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (x64) using WNET DDK -:WNETA64Build -:WNETAMD64Build -:WNETX64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% AMD64 WNET -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 32bit using WNET DDK -:WNETBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 32bit using WLH WDK -:WLHBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WLH -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 64bit (x64) using WLH WDK -:WLHA64Build -:WLHX64Build -call :DetectVistaWDK -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% %OSR_AMD64FLAG% WLH -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 64bit (Itanium) using WLH WDK -:WLH64Build -:WLHI64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WLH -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (x64) using WLH WDK -:WLHNETA64Build -:WLHNETX64Build -call :DetectVistaWDK -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% %OSR_AMD64FLAG% WNET -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (Itanium) using WLH WDK -:WLHNET64Build -:WLHNETI64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WNET -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 32bit using WLH WDK -:WLHXPBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WXP -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 64bit (Itanium) using WLH WDK -:WLHXP64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WXP -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W2K build for 32bit using WLH WDK -:WLH2KBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% W2K -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 32bit using WLH WDK -:WLHNETBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WNET -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W7 build for 32bit using W7/2008 WDK -:W7Build -:WIN7Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x86 WIN7 %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W7 build for 64bit (x64) using W7/2008 WDK -:W7X64Build -:WIN7A64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x64 WIN7 %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: W7 build for 64bit (Itanium) using W7/2008 WDK -:W7I64Build -:WIN764Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% ia64 WIN7 no_oacr %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 32bit using W7/2008 WDK -:W7LHBuild -:WIN7WLHBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x86 WLH %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 64bit (x64) using W7/2008 WDK -:W7LHX64Build -:WIN7WLHA64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x64 WLH %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WLH build for 64bit (Itanium) using W7/2008 WDK -:W7LHI64Build -:WIN7WLH64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% ia64 WLH no_oacr %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 32bit using W7/2008 WDK -:W7NETBuild -:WIN7NETBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x86 WNET %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (x64) using W7/2008 WDK -:W7NETX64Build -:WIN7NETA64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x64 WNET %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WNET build for 64bit (Itanium) using W7/2008 WDK -:W7NETI64Build -:WIN7NET64Build -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% ia64 WNET no_oacr %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: WXP build for 32bit using W7/2008 WDK -:W7XPBuild -:WIN7XPBuild -set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% x86 WXP %SETTING_OACR% %SETTING_SEPARATE_OBJ_ROOT% -goto :EOF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: All builds go here for the rest of the procedure. Now, -:: we are getting ready to call build. The big problem -:: here is to figure our the name of the buildxxx files -:: being generated for the different platforms. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:CommonBuild -:: Remove first command line arg -shift -call :SetMode %1 -if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_BadMode%" & goto :USAGE -set OSR_BUILDNAME=%OSR_TARGET% (%BuildMode%) using the %BASEDIROS% DDK and %%%BASEDIRVAR%%% - -call :CheckTargets %2 -if "%OSR_ERRCODE%" == "6" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoTarget%" & goto :USAGE -if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoDir%" & goto :USAGE - -:: Resolve any variables in the command line string -call :ResolveVar OSR_CMDLINE - -pushd . -set ERRORLEVEL=0 -:: This external script prepares the build environment (e.g. setenv.bat) -call %OSR_CMDLINE% -:: Will only work with newer SETENV.BAT versions, but will be helpful in this case. -if not "%ERRORLEVEL%" == "0" call :ShowErrorMsg 9 "%ERR_SetEnvFailed%" & goto :USAGE -popd - -:: ---------------------------------------------------------------------------- -:: Setting global variables for the scope of this CMD session -set NO_BROWSER_FILE= -set NO_BINPLACE= -set buildDirectory=%~fs2 -call :MakeShort buildDirectory "%buildDirectory%" -set buildDirectory_raw=%2 -set buildDirectory_fname=%~n2 -%OSR_TRACE% buildDirectory == %buildDirectory% -%OSR_TRACE% buildDirectory_raw == %buildDirectory_raw% -%OSR_TRACE% buildDirectory_fname == %buildDirectory_fname% - -set mpFlag=-M -if "%BUILD_ALT_DIR%" == "" goto :NT4 - -:: W2K sets this! -set OSR_EXT=%BUILD_ALT_DIR% -set mpFlag=-MI - -:NT4 -if "%NUMBER_OF_PROCESSORS%" == "" set mpFlag= -if "%NUMBER_OF_PROCESSORS%" == "1" set mpFlag= - -:: Set additional variables at this point or do whatever you please -@if exist "%buildDirectory%\%OSR_PREBUILD_SCRIPT%" @( - %OSR_ECHO% ^>^> Performing pre-build steps [%OSR_PREBUILD_SCRIPT%] ... - pushd "%buildDirectory%" - call "%OSR_PREBUILD_SCRIPT%" > "%TEMP%\%OSR_PREBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" - for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_PREBUILD_SCRIPT%_%OSR_RANDEXT%.tmp"') do @( - %OSR_ECHO% %%x - ) - if exist "%TEMP%\%OSR_PREBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" del /f /q "%TEMP%\%OSR_PREBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" - popd - %OSR_ECHO% ^<^< Finished pre-build steps [%OSR_PREBUILD_SCRIPT%] ... -) -:: Save the current directory (before changing into the build directory!) -:: AFTERPREBUILD -pushd . - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Determine the settings of flags, WDF and PREFAST in -:: other words what was set for %3 and beyond.... -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -%OSR_ECHO% %OSR_BUILDNAME% -set OSR_ARGS= + argument(s): -if not "%3" == "" set OSR_ARGS=%OSR_ARGS% %3 -if not "%4" == "" set OSR_ARGS=%OSR_ARGS% %4 -if not "%5" == "" set OSR_ARGS=%OSR_ARGS% %5 -if /i "%OSR_ARGS%" == " + argument(s):" set OSR_ARGS= -%OSR_ECHO% Directory: %buildDirectory%%OSR_ARGS% -%OSR_ECHO% %BASEDIRVAR%: %BASEDIR% - -cd /D %~s2 -set bFlags=-Ze -set bscFlags= - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:ContinueParsing -if "%3" == "" goto :DONE -if "%3" == "/a" goto :RebuildallFound -if /i "%3" == "-WDF" goto :WDFFound -if /i "%3" == "-PREFAST" goto :PrefastFound -if /i "%3" == "-CUV" goto :CallUsageVerifier -set bscFlags=/n -set bFlags=%bFlags% %3 -:: Remove next arg -shift -goto :ContinueParsing - -:WDFFound -shift -:: Note, that the setwdf.bat is called from setenv.bat in the WDK, -:: therefore we skip it. -if /i "%BASEDIRVAR%" == "WLHBASE" goto :WDFOkay -if /i "%BASEDIRVAR%" == "W7BASE" goto :WDFOkay -if /i "%BASEDIRVAR%" == "WIN7BASE" goto :WDFOkay -if "%WDF_ROOT%" == "" call :ShowErrorMsg 2 "%ERR_NoWdfRoot%" & goto :USAGE -pushd . -if exist "%WDF_ROOT%\set_wdf_env.cmd" call "%WDF_ROOT%\set_wdf_env.cmd" -popd -:WDFOkay -goto :ContinueParsing - -:PrefastFound -shift -set PREFAST_BUILD=1 -goto :ContinueParsing - -:CallUsageVerifier -shift -set VERIFIER_DDK_EXTENSIONS=1 -set PREFAST_BUILD=1 -goto :ContinueParsing - -:RebuildallFound -shift -set bscFlags=/n -set bFlags=%bFlags:-Ze=-cfeZ% -set bFlags=%bFlags: -cZ=% -goto :ContinueParsing -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:DONE -for %%x in (build%OSR_EXT%.err build%OSR_EXT%.wrn build%OSR_EXT%.log prefast%OSR_EXT%.log) do @( - if exist "%%x" del /f /q "%%x" -) - -if not "%PREFAST_BUILD%" == "0" goto :RunPrefastBuild -%OSR_ECHO% Run build %mpFlag% %bFlags% for %BuildMode% version in %buildDirectory_raw% -pushd . -build %mpFlag% %bFlags% -popd -goto :BuildComplete - -:RunPrefastBuild -%OSR_ECHO% Run prefast build %mpFlag% %bFlags% for %BuildMode% version in %buildDirectory_raw% -setlocal ENABLEEXTENSIONS & pushd . -set PREFASTLOG=PREfast_defects_%OSR_EXT%.xml -prefast /log=%PREFASTLOG% /reset build %mpFlag% %bFlags% > NUL 2>&1 -if "%errorlevel%" GTR "0" set OSR_ERRCODE=%errorlevel% -prefast /log=%PREFASTLOG% list > prefast%OSR_EXT%.log -%OSR_ECHO% The PREfast logfile is ^"%prefastlog%^"! -popd & endlocal - -:BuildComplete -if not "%errorlevel%" == "0" set OSR_ERRCODE=%errorlevel% - -@echo %OSR_DEBUG% -:: Assume that the onscreen errors are complete! -setlocal -set WARNING_FILE_COUNT=0 -if exist "build%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CDMRU][0-9][0-9]* warning[^.][BRP][KCWG][0-9][0-9]* warning[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]* error[^.][CDMRU][0-9][0-9]* error[^.][BRP][KCWG][0-9][0-9]* error[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]*" "build%OSR_EXT%.log"') do @( - set /a WARNING_FILE_COUNT=%WARNING_FILE_COUNT%+1 -) -if not "%WARNING_FILE_COUNT%" == "0" ( - %OSR_ECHO% ================ Build warnings ======================= - if exist "build%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CDMRU][0-9][0-9]* warning[^.][BRP][KCWG][0-9][0-9]* warning[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]* error[^.][CDMRU][0-9][0-9]* error[^.][BRP][KCWG][0-9][0-9]* error[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]*" "build%OSR_EXT%.log"') do @( - @echo %%x - ) -) -set WARNING_FILE_COUNT_PRE=0 -if exist "prefast%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CDMRU][0-9][0-9]* warning[^.][BRP][KCWG][0-9][0-9]* warning[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]*" "prefast%OSR_EXT%.log"') do @( - set /a WARNING_FILE_COUNT_PRE=%WARNING_FILE_COUNT_PRE%+1 -) -:: Reset if this is no PREfast build -if "%PREFAST_BUILD%" == "0" set WARNING_FILE_COUNT_PRE=0 -if not "%WARNING_FILE_COUNT_PRE%" == "0" ( - %OSR_ECHO% =============== PREfast warnings ====================== - if exist "prefast%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CDMRU][0-9][0-9]* warning[^.][BRP][KCWG][0-9][0-9]* warning[^.][ACLPS][DNRTVX][JKLTX][0-9][0-9]*" "prefast%OSR_EXT%.log"') do @( - @echo %%x - ) -) -set /a WARNING_FILE_COUNT=%WARNING_FILE_COUNT%+%WARNING_FILE_COUNT_PRE% -if not "%WARNING_FILE_COUNT%" == "0" ( - %OSR_ECHO% ======================================================= -) -endlocal -@echo. -%OSR_ECHO% Build complete -%OSR_ECHO% Building browse information files -if exist "buildbrowse.cmd" call "buildbrowse.cmd" & goto :postBuildSteps -set sbrlist=sbrList.txt -if not exist sbrList%CPU%.txt goto :sbrDefault -set sbrlist=sbrList%CPU%.txt - -:sbrDefault -if not exist %sbrlist% goto :postBuildSteps -:: Prepend blank space -if not "%bscFlags%" == "" set bscFlags= %bscFlags% -:: bscmake%bscFlags% prevents a double blank space ... -bscmake%bscFlags% @%sbrlist% - -:: Perform whatever post-build steps -:postBuildSteps -:: Restore the current directory (after changing into the build directory!) -:: Search upwards for "AFTERPREBUILD" to find the corresponding PUSHD -popd -@if exist "%buildDirectory%\%OSR_POSTBUILD_SCRIPT%" @( - %OSR_ECHO% ^>^> Performing post-build steps [%OSR_POSTBUILD_SCRIPT%] ... - pushd "%buildDirectory%" - call "%OSR_POSTBUILD_SCRIPT%" > "%TEMP%\%OSR_POSTBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" - for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_POSTBUILD_SCRIPT%_%OSR_RANDEXT%.tmp"') do @( - %OSR_ECHO% %%x - ) - if exist "%TEMP%\%OSR_POSTBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" del /f /q "%TEMP%\%OSR_POSTBUILD_SCRIPT%_%OSR_RANDEXT%.tmp" - popd - %OSR_ECHO% ^<^< Finished post-build steps [%OSR_POSTBUILD_SCRIPT%] ... -) -goto :END -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ MAIN function of the script -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / GetCustomEnvironment -:: First parameter is the "directory" that supposedly contains the SOURCES -:: or DIRS file (and the build scripts) -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:GetCustomEnvironment -pushd . -call :CheckTargets "%~f1" -@if not "%OSR_ERRCODE%" == "0" @( - echo. - %OSR_ECHO% The target directory seemed to not contain a DIRS or SOURCES file - %OSR_ECHO% when trying to set a custom environment! Quitting. ^(ERROR #%OSR_ERRCODE%^) - set buildDirectory=%~f1 - if "%OSR_ERRCODE%" == "6" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoTarget%" & goto :GetCustomEnvironment_ret - call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoDir%" & goto :GetCustomEnvironment_ret - goto :GetCustomEnvironment_ret -) -:: If the user provided a script to customize the environment, execute it. -@if exist "%~f1\%OSR_SETENV_SCRIPT%" @( - %OSR_ECHO% ^>^> Setting custom environment variables [%OSR_SETENV_SCRIPT%] ... - pushd "%~f1" - call "%OSR_SETENV_SCRIPT%" > "%TEMP%\%OSR_SETENV_SCRIPT%_%OSR_RANDEXT%.tmp" - for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_SETENV_SCRIPT%_%OSR_RANDEXT%.tmp"') do @( - %OSR_ECHO% %%x - ) - if exist "%TEMP%\%OSR_SETENV_SCRIPT%_%OSR_RANDEXT%.tmp" del /f /q "%TEMP%\%OSR_SETENV_SCRIPT%_%OSR_RANDEXT%.tmp" - popd - %OSR_ECHO% ^<^< Finished setting custom environment variables [%OSR_SETENV_SCRIPT%] ... -) -:GetCustomEnvironment_ret -popd -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ GetCustomEnvironment -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / SetMode -:: Subroutine to validate the mode of the build passed in. It must be free, -:: FREE, fre, FRE or checked, CHECKED, chk, CHK. Anything else is an error. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:SetMode -set BuildMode= -if /i "%OSR_TARGET%" == "WLH2K" goto :SetModeWLH2K -for %%f in (free fre) do if /i "%%f" == "%1" set BuildMode=free -for %%f in (checked chk) do if /i "%%f" == "%1" set BuildMode=checked -goto :SetModeCommonEnd -:SetModeWLH2K -for %%f in (free fre) do if /i "%%f" == "%1" set BuildMode=f -for %%f in (checked chk) do if /i "%%f" == "%1" set BuildMode=c -:SetModeCommonEnd -%OSR_TRACE% Mode set to ^"%BuildMode%^" -if "%BuildMode%" == "" set OSR_ERRCODE=5 -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ SetMode -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / CheckTargets subroutine -:: Subroutine to validate that the target directory exists and that there is -:: either a DIRS or SOURCES and MakeFile in it. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:CheckTargets -:: Building "stack frame" -setlocal & pushd . & set OSR_ERRCODE=0 -set lTarget=%~1 -if not "%lTarget%" == "" goto :CheckTargets1 -set OSR_ERRCODE=7 -goto :CheckTargets_ret -:CheckTargets1 -if exist "%lTarget%" goto :CheckTargets2 -set OSR_ERRCODE=8 -goto :CheckTargets_ret -:CheckTargets2 -if not exist "%lTarget%\DIRS" goto :CheckTargets3 -set OSR_ERRCODE=0 -goto :CheckTargets_ret -:CheckTargets3 -if exist "%lTarget%\SOURCES" goto :CheckTargets4 -set OSR_ERRCODE=6 -goto :CheckTargets_ret -:CheckTargets4 -if exist "%lTarget%\MAKEFILE" goto :CheckTargets5 -set OSR_ERRCODE=6 -goto :CheckTargets_ret -:CheckTargets5 -set OSR_ERRCODE=0 -:CheckTargets_ret -:: Cleaning "stack frame" and returning error code into global scope -popd & endlocal & set OSR_ERRCODE=%OSR_ERRCODE% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ CheckTargets subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / ResolveVar subroutine -:: There is only one parameter, the name of the variable to be resolved! -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:ResolveVar -:: Get the name of the variable we are working with -setlocal ENABLEEXTENSIONS & set VAR_NAME=%1 -set VAR_TEMPRET2=%%%VAR_NAME%%% -:ResolveVarLoop -set VAR_TEMPRET1=%VAR_TEMPRET2% -set VAR_TEMPRET2=%VAR_TEMPRET1% -for /f "tokens=*" %%i in ('echo %VAR_TEMPRET1%') do ( - set VAR_TEMPRET2=%%i -) -if not "%VAR_TEMPRET1%" == "%VAR_TEMPRET2%" goto :ResolveVarLoop -:: Re-export the variable out of the local scope -endlocal & set %VAR_NAME%=%VAR_TEMPRET1% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ ResolveVar subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / MakeShort subroutine -:: Two parameters. First parameter is the variable name, second is the path -:: to convert into a short filename. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:MakeShort -setlocal ENABLEEXTENSIONS -:: Get the name of the variable we are working with and the path to convert -set VAR_NAME=%~1 -set PATH_SHORT=%~dpns2 -set PATH_EXTSHORT=%~xs2 -if not "" == "%PATH_EXTSHORT%" set PATH_EXTSHORT=%PATH_EXTSHORT:~0,4% -set PATH_SHORT=%PATH_SHORT%%PATH_EXTSHORT% -endlocal & set %VAR_NAME%=%PATH_SHORT% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ MakeShort subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / ErrorWithUsage subroutine -:: This one will take the passed in parameters and build a nice error -:: message which is returned to the user along with the usage hints. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:ShowErrorMsg -@set OSR_ERRCODE=%~1 -@set OSR_ERRMSG=%~2 -@set OSR_ERRMSG=%OSR_ERRMSG:'="% -@set OSR_ERRMSG=ERROR #%OSR_ERRCODE%: %OSR_ERRMSG% -@echo. -%OSR_ECHO% %OSR_ERRMSG% -if DEFINED buildDirectory %OSR_ECHO% -^> Target directory: %buildDirectory% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ ErrorWithUsage subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / SetVar subroutine -:: Param1 == name of the variable, Param2 == value to be set for the variable -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:SetVar -:: Get the name of the variable we are working with -setlocal ENABLEEXTENSIONS & set VAR_NAME=%1 -endlocal & set %VAR_NAME%=%~2 -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ SetVar subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / DetectVistaWDK subroutine -:: No parameters expected -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:DetectVistaWDK -setlocal ENABLEEXTENSIONS -:: Newer flag (starting with W2K8) is default -set OSR_AMD64FLAG=x64 -:: The Vista WDK accepted *only* "AMD64", the newer W2K8 WDK accepts only "x64" -:: We detect the older one by checking the setenv.bat for a certain string -findstr /C:"Windows Server Longhorn" "%BASEDIR%\bin\setenv.bat" > NUL 2>&1 && set OSR_AMD64FLAG=AMD64 -endlocal & set OSR_AMD64FLAG=%OSR_AMD64FLAG% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ DetectVistaWDK subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / DetectBaseDirTemp subroutine -:: The first parameter is the list of directory names to check, separated by -:: blank spaces. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:DetectBaseDirTemp -:: Get the name of the variable we are working with -if "%~1" == "" goto :EOF -setlocal ENABLEEXTENSIONS -call :CommonCheckMsg1 -:: Try to find an installed DDK/WDK from the registry keys -if DEFINED OSR_REGAVAILABLE if not "%OSR_REGAVAILABLE%" == "0" ( - for %%i in (%~1) do @( - call :RegTryBaseDirTemp "%%i" - ) -) -:: Try all the "default" locations -if not DEFINED BASEDIRTEMP ( - for %%i in (%~1) do @( - for %%a in (WINDDK DDK) do @( - call :BruteTryBaseDirTemp "%SystemDrive%\%%a\%%i" - call :BruteTryBaseDirTemp "%ProgramFiles%\%%a\%%i" - ) - ) -) -endlocal & set BASEDIRTEMP=%BASEDIRTEMP% -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ DetectBaseDirTemp subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / RegTryBaseDirTemp subroutine -:: Attempt to find the install key in the registry. -:: This functions tests old-style DDKs and new-style WDKs. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:RegTryBaseDirTemp -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF -setlocal ENABLEEXTENSIONS -call :RegTryBaseDirTempSingle "%~1" "LFNDirectory" BASEDIRTEMP -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF -call :RegTryBaseDirTempSingle "%~1\Setup" "BUILD" BASEDIRTEMP -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF -if not DEFINED BASEDIRTEMP (endlocal & goto :EOF) -:RegTryBaseDirTemp_EOF -%OSR_ECHO% Found directory (%BASEDIRTEMP%) from install key -endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ RegTryBaseDirTemp subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / RegTryBaseDirTempSingle subroutine -:: Attempt to find the install key in the registry. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:RegTryBaseDirTempSingle -setlocal ENABLEEXTENSIONS -set REGSUBKEY=%~1 -set REGVALUE=%~2 -set VARIABLETOSET=%~3 -set REGMAINKEY=HKLM\SOFTWARE\Microsoft\WINDDK -:: Test whether we can read the value below this key -reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_WOW64 -for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @( - call :SetVar _SETVARIABLE "%%j" -) -endlocal & set %VARIABLETOSET%=%_SETVARIABLE% -:RegTryBaseDirTempSingle_WOW64 -set REGMAINKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\WINDDK -:: Test whether we can read the value below this key -reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_EOF -for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @( - call :SetVar _SETVARIABLE "%%j" -) -endlocal & set %VARIABLETOSET%=%_SETVARIABLE% -:RegTryBaseDirTempSingle_EOF -endlocal -goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ RegTryBaseDirTempSingle subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: / BruteTryBaseDirTemp subroutine -:: Brute-force test the given directory. -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:BruteTryBaseDirTemp -if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF -setlocal ENABLEEXTENSIONS -:: We will not overwrite BASETEMPDIR if it has been set and is valid -:: Just try -set BASEDIRTEMP=%~1 -%OSR_ECHO% Trying %BASEDIRTEMP% ... -if not exist "%BASEDIRTEMP%" (endlocal & goto :EOF) -endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: \ BruteTryBaseDirTemp subroutine -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Usage output -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:USAGE -@echo. -@echo USAGE: -@echo ====== -@echo %~n0 ^ ^ ^ [flags] [-WDF] [-PREFAST] [-CUV] -@echo. -@echo Values for ^: -@echo --------------------------------------------------------------------------- -@echo Target OS version and architecture ^| Miscellaneous -@echo -------------------------------------^|------------------------------------- -@echo ^ ^| Windows ^| CPU ^| Base directory ^| ^ alias(es) -@echo -------------^|-------------^|---------^|----------------^|-------------------- -@echo -NT4 ^| NT 4.0 ^| x86 ^| %%NT4BASE%% ^| -@echo -W2K ^| 2000 ^| x86 ^| %%W2KBASE%% ^| -@echo -W2K64 ^| 2000 ^| Itanium ^| %%W2KBASE%% ^| -W2KI64 -@echo -WXP ^| XP ^| x86 ^| %%WXPBASE%% ^| -XP -@echo -WXP64 ^| XP ^| Itanium ^| %%WXPBASE%% ^| -WXPI64, -XP64 -@echo -WXP2K ^| 2000 ^| x86 ^| %%WXPBASE%% ^| -XPW2K -@echo -WNET ^| 2003 ^| x86 ^| %%WNETBASE%% ^| -@echo -WNET64 ^| 2003 ^| Itanium ^| %%WNETBASE%% ^| -WNETI64 -@echo -WNETXP ^| XP ^| x86 ^| %%WNETBASE%% ^| -@echo -WNETXP64 ^| XP ^| Itanium ^| %%WNETBASE%% ^| -@echo -WNETAMD64 ^| 2003/XP x64 ^| x64 ^| %%WNETBASE%% ^| -WNETX64, -WNETA64 -@echo -WNET2K ^| 2000 SP3 ^| x86 ^| %%WNETBASE%% ^| -WNETW2K -@echo -WLH ^| Vista/2008 ^| x86 ^| %%WLHBASE%% ^| -@echo -WLH2K ^| 2000 SP4 ^| x86 ^| %%WLHBASE%% ^| -@echo -WLHXP ^| XP ^| x86 ^| %%WLHBASE%% ^| -@echo -WLHXP64 ^| XP ^| Itanium ^| %%WLHBASE%% ^| -@echo -WLHNET ^| 2003 ^| x86 ^| %%WLHBASE%% ^| -@echo -WLHNETI64 ^| 2003 ^| Itanium ^| %%WLHBASE%% ^| -WLHNET64 -@echo -WLHNETX64 ^| 2003/XP x64 ^| x64 ^| %%WLHBASE%% ^| -WLHNETA64 -@echo -WLHI64 ^| Vista/2008 ^| Itanium ^| %%WLHBASE%% ^| -WLH64 -@echo -WLHX64 ^| Vista/2008 ^| x64 ^| %%WLHBASE%% ^| -WLHA64 -@echo -W7 ^| 7/2008 R2 ^| x86 ^| %%W7BASE%% ^| -WIN7 -@echo -W7I64 ^| 7/2008 R2 ^| Itanium ^| %%W7BASE%% ^| -WIN764 -@echo -W7X64 ^| 7/2008 R2 ^| x64 ^| %%W7BASE%% ^| -WIN7A64 -@echo -W7LH ^| Vista/2008 ^| x86 ^| %%W7BASE%% ^| -WIN7WLH -@echo -W7LHI64 ^| Vista/2008 ^| Itanium ^| %%W7BASE%% ^| -WIN7WLH64 -@echo -W7LHX64 ^| Vista/2008 ^| x64 ^| %%W7BASE%% ^| -WIN7WLHA64 -@echo -W7NET ^| 2003 ^| x86 ^| %%W7BASE%% ^| -WIN7NET -@echo -W7NETI64 ^| 2003 ^| Itanium ^| %%W7BASE%% ^| -WIN7NET64 -@echo -W7NETX64 ^| 2003/XP x64 ^| x64 ^| %%W7BASE%% ^| -WIN7NETA64 -@echo -W7XP ^| XP ^| x86 ^| %%W7BASE%% ^| -WIN7XP -@echo --------------------------------------------------------------------------- -@echo Support for NT4 and W2K DDKs is deprecated and not checked anymore -@echo in new versions. It may or may not work properly. -@echo --------------------------------------------------------------------------- -@echo. -@echo Values for ^: -@echo checked, chk indicates a checked build -@echo free, fre indicates a free build -@echo. -@echo Remaining parameters (all optional): -@echo ^ path to build directory, try . (current directory) -@echo [flags] any flags you think should be passed to build (try /a -@echo for clean) -@echo -WDF performs a WDF build -@echo -PREFAST performs a PREFAST build -@echo -CUV uses the Call Usage Verifier, implies a PREFAST build -@echo. -@echo Special files: -@echo The build target directory (where the DIRS or SOURCES file resides) can -@echo contain the following files: -@echo - %OSR_PREBUILD_SCRIPT% -@echo Allows to include a step before the BUILD tool from the DDK is called -@echo but after the environment for the respective DDK has been set! -@echo - %OSR_POSTBUILD_SCRIPT% -@echo Allows to include a step after the BUILD tool from the DDK is called, -@echo so the environment is still available to the script. -@echo - %OSR_SETENV_SCRIPT% -@echo Allows to set (or override) _any_ environment variables that may exist -@echo in the global environment. Thus you can set the base directory for the -@echo DDK from inside this script, making your project more self-contained. -@echo. -@echo DDKBUILD will only handle those files which exist, so you may choose to -@echo use none, one or multiple of these script files. -@echo (All scripts execute inside their current directory. Consider this!) -@echo. -@echo Examples: -@echo ^"%~n0 -NT4 checked .^" (for NT4 BUILD) -@echo ^"%~n0 -WXP64 chk .^" -@echo ^"%~n0 -WXP chk c:\projects\myproject^" -@echo ^"%~n0 -WNET64 chk .^" (IA64 build) -@echo ^"%~n0 -WNETAMD64 chk .^" (AMD64/EM64T build) -@echo ^"%~n0 -WNETXP chk . -cZ -WDF^" -@echo ^"%~n0 -WNETXP chk . -cZ -PREFAST^" -@echo. -@echo In order for this procedure to work correctly for each platform, it -@echo requires an environment variable to be set up for certain platforms. -@echo There is an auto-detection mechanism in this script, which will work best -@echo if the DDK/WDK was installed using the normal installer (i.e. not just -@echo copied). The auto-detection is based on the DDK/WDK for which you request -@echo a build. Whenever you set the variable explicitly, this will take -@echo precedence over the auto-detected path! -@echo The environment variables are as follows: -@echo. -@echo %%NT4BASE%% - Set this up for ^"-NT4^" builds -@echo %%W2KBASE%% - Set this up for ^"-W2K^" and ^"-W2K64^" builds -@echo %%WXPBASE%% - Set this up for ^"-WXP^", ^"-WXP64^", ^"-WXP2K^" builds -@echo %%WNETBASE%% - Set this up for ^"-WNET*^" builds -@echo %%WLHBASE%% - Set this up for ^"-WLH*^" builds -@echo %%W7BASE%% - Set this up for ^"-W7*^" builds -@echo. -@echo %%WDF_ROOT%% must be set if attempting to do a WDF Build previous to the -@echo Vista WDK (in later DDKs there is no need to set WDF_ROOT). -@echo. -@echo Path to this script: -@echo %~f0 -@echo. -@echo %OSR_VERSTR% -@echo -^> report any problems to ^ or ^ -@echo. - -:END -popd & endlocal & exit /b %OSR_ERRCODE% diff --git a/Ext4Fsd/debug.c b/Ext4Fsd/debug.c index f15b415..54eed8b 100644 --- a/Ext4Fsd/debug.c +++ b/Ext4Fsd/debug.c @@ -2587,7 +2587,7 @@ Ext2NtStatusToString ( IN NTSTATUS Status ) VOID Ext2TraceMcb(PCHAR fn, USHORT lc, USHORT add, PEXT2_MCB Mcb) { - int i; + size_t i; CHAR _space[33]; _snprintf(&_space[0], 32, "%s:%d:", fn, lc); diff --git a/Ext4Fsd/ext3fsd.vcproj b/Ext4Fsd/ext3fsd.vcproj deleted file mode 100644 index d5208d4..0000000 --- a/Ext4Fsd/ext3fsd.vcproj +++ /dev/null @@ -1,693 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Ext4Fsd/include/ext2fs.h b/Ext4Fsd/include/ext2fs.h index e28cd78..5ddaf55 100644 --- a/Ext4Fsd/include/ext2fs.h +++ b/Ext4Fsd/include/ext2fs.h @@ -41,7 +41,7 @@ /* STRUCTS & CONSTS******************************************************/ -#define EXT2FSD_VERSION "0.69" +#define EXT2FSD_VERSION "0.70" /* WDK DEFINITIONS ******************************************************/ @@ -2527,6 +2527,9 @@ Ext2TruncateIndirect( // linux.c: linux lib implemenation // +int strncmp(const char* str1, const char* str2, size_t count); +char* strncpy(char* dest, const char* src, size_t count); + int ext2_init_linux(); diff --git a/Ext4Fsd/include/linux/errno.h b/Ext4Fsd/include/linux/errno.h index 243f1f9..cd813dc 100644 --- a/Ext4Fsd/include/linux/errno.h +++ b/Ext4Fsd/include/linux/errno.h @@ -141,4 +141,6 @@ #define EBADTYPE 527 /* Type not supported by server */ #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ +#define ENAMETOOLONG 1024; + #endif diff --git a/Ext4Fsd/include/linux/ext3_fs.h b/Ext4Fsd/include/linux/ext3_fs.h index db79afb..157c5be 100644 --- a/Ext4Fsd/include/linux/ext3_fs.h +++ b/Ext4Fsd/include/linux/ext3_fs.h @@ -1019,6 +1019,8 @@ struct mmp_struct { #define XATTR_NO_CTIME 0x80 #endif +int _strnicmp(const char* str1, const char* str2, size_t count); + /* * NOTE! unlike strncmp, ext3_match returns 1 for success, 0 for failure. * diff --git a/Ext4Fsd/include/linux/jbd.h b/Ext4Fsd/include/linux/jbd.h index 5901589..15c0a4d 100644 --- a/Ext4Fsd/include/linux/jbd.h +++ b/Ext4Fsd/include/linux/jbd.h @@ -923,7 +923,6 @@ static inline handle_t *journal_current_handle(void) { return NULL; /* return current->journal_info; */ -#pragma message("WARNINGS: journal_current_handle NOT implemented") } /* The journaling code user interface: diff --git a/Ext4Fsd/linux.c b/Ext4Fsd/linux.c index acc0f58..e11dbe5 100644 --- a/Ext4Fsd/linux.c +++ b/Ext4Fsd/linux.c @@ -1,1005 +1,1060 @@ -/* - * COPYRIGHT: See COPYRIGHT.TXT - * PROJECT: Ext2 File System Driver for WinNT/2K/XP - * FILE: linux.c - * PROGRAMMER: Matt Wu - * HOMEPAGE: http://www.ext2fsd.com - * UPDATE HISTORY: - */ - -/* INCLUDES *****************************************************************/ - -#include -#include -#include - -/* GLOBALS ***************************************************************/ - -extern PEXT2_GLOBAL Ext2Global; - -/* DEFINITIONS *************************************************************/ - -#ifdef ALLOC_PRAGMA -#pragma alloc_text(PAGE, kzalloc) -#endif - -struct task_struct current_task = { - /* pid */ 0, - /* tid */ 1, - /* comm */ "current\0", - /* journal_info */ NULL -}; -struct task_struct *current = ¤t_task; - -void *kzalloc(int size, int flags) -{ - void *buffer = kmalloc(size, flags); - if (buffer) { - memset(buffer, 0, size); - } - return buffer; -} - -// -// slab routines -// - -kmem_cache_t * -kmem_cache_create( - const char * name, - size_t size, - size_t offset, - unsigned long flags, - kmem_cache_cb_t ctor -) -{ - kmem_cache_t *kc = NULL; - - kc = kmalloc(sizeof(kmem_cache_t), GFP_KERNEL); - if (kc == NULL) { - goto errorout; - } - - memset(kc, 0, sizeof(kmem_cache_t)); - ExInitializeNPagedLookasideList( - &kc->la, - NULL, - NULL, - 0, - size, - 'JBKC', - 0); - - kc->size = size; - strncpy(kc->name, name, 31); - kc->constructor = ctor; - -errorout: - - return kc; -} - -int kmem_cache_destroy(kmem_cache_t * kc) -{ - ASSERT(kc != NULL); - - ExDeleteNPagedLookasideList(&(kc->la)); - kfree(kc); - - return 0; -} - -void* kmem_cache_alloc(kmem_cache_t *kc, int flags) -{ - PVOID ptr = NULL; - ptr = ExAllocateFromNPagedLookasideList(&(kc->la)); - if (ptr) { - atomic_inc(&kc->count); - atomic_inc(&kc->acount); - } - return ptr; -} - -void kmem_cache_free(kmem_cache_t *kc, void *p) -{ - if (p) { - atomic_dec(&kc->count); - ExFreeToNPagedLookasideList(&(kc->la), p); - } -} - -// -// wait queue routines -// - -void init_waitqueue_head(wait_queue_head_t *q) -{ - spin_lock_init(&q->lock); - INIT_LIST_HEAD(&q->task_list); -} - -struct __wait_queue * -wait_queue_create() -{ - struct __wait_queue * wait = NULL; - wait = kmalloc(sizeof(struct __wait_queue), GFP_KERNEL); - if (!wait) { - return NULL; - } - - memset(wait, 0, sizeof(struct __wait_queue)); - wait->flags = WQ_FLAG_AUTO_REMOVAL; - wait->private = (void *)KeGetCurrentThread(); - INIT_LIST_HEAD(&wait->task_list); - KeInitializeEvent(&(wait->event), - SynchronizationEvent, - FALSE); - - return wait; -} - -void -wait_queue_destroy(struct __wait_queue * wait) -{ - kfree(wait); -} - -static inline void __add_wait_queue(wait_queue_head_t *head, struct __wait_queue *new) -{ - list_add(&new->task_list, &head->task_list); -} - -/* - * Used for wake-one threads: - */ -static inline void __add_wait_queue_tail(wait_queue_head_t *head, - struct __wait_queue *new) -{ - list_add_tail(&new->task_list, &head->task_list); -} - -static inline void __remove_wait_queue(wait_queue_head_t *head, - struct __wait_queue *old) -{ - list_del(&old->task_list); -} - -void add_wait_queue(wait_queue_head_t *q, wait_queue_t *waiti) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - wait->flags &= ~WQ_FLAG_EXCLUSIVE; - spin_lock_irqsave(&q->lock, flags); - __add_wait_queue(q, wait); - spin_unlock_irqrestore(&q->lock, flags); -} - -void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *waiti) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - wait->flags |= WQ_FLAG_EXCLUSIVE; - spin_lock_irqsave(&q->lock, flags); - __add_wait_queue_tail(q, wait); - spin_unlock_irqrestore(&q->lock, flags); -} - -void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *waiti) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - spin_lock_irqsave(&q->lock, flags); - __remove_wait_queue(q, wait); - spin_unlock_irqrestore(&q->lock, flags); -} - -/* - * Note: we use "set_current_state()" _after_ the wait-queue add, - * because we need a memory barrier there on SMP, so that any - * wake-function that tests for the wait-queue being active - * will be guaranteed to see waitqueue addition _or_ subsequent - * tests in this thread will see the wakeup having taken place. - * - * The spin_unlock() itself is semi-permeable and only protects - * one way (it only protects stuff inside the critical region and - * stops them from bleeding out - it would still allow subsequent - * loads to move into the critical region). - */ -void -prepare_to_wait(wait_queue_head_t *q, wait_queue_t *waiti, int state) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - wait->flags &= ~WQ_FLAG_EXCLUSIVE; - spin_lock_irqsave(&q->lock, flags); - if (list_empty(&wait->task_list)) - __add_wait_queue(q, wait); - /* - * don't alter the task state if this is just going to - * queue an async wait queue callback - */ - if (is_sync_wait(wait)) - set_current_state(state); - spin_unlock_irqrestore(&q->lock, flags); -} - -void -prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *waiti, int state) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - wait->flags |= WQ_FLAG_EXCLUSIVE; - spin_lock_irqsave(&q->lock, flags); - if (list_empty(&wait->task_list)) - __add_wait_queue_tail(q, wait); - /* - * don't alter the task state if this is just going to - * queue an async wait queue callback - */ - if (is_sync_wait(wait)) - set_current_state(state); - spin_unlock_irqrestore(&q->lock, flags); -} -EXPORT_SYMBOL(prepare_to_wait_exclusive); - -void finish_wait(wait_queue_head_t *q, wait_queue_t *waiti) -{ - unsigned long flags; - struct __wait_queue *wait = *waiti; - - __set_current_state(TASK_RUNNING); - /* - * We can check for list emptiness outside the lock - * IFF: - * - we use the "careful" check that verifies both - * the next and prev pointers, so that there cannot - * be any half-pending updates in progress on other - * CPU's that we haven't seen yet (and that might - * still change the stack area. - * and - * - all other users take the lock (ie we can only - * have _one_ other CPU that looks at or modifies - * the list). - */ - if (!list_empty_careful(&wait->task_list)) { - spin_lock_irqsave(&q->lock, flags); - list_del_init(&wait->task_list); - spin_unlock_irqrestore(&q->lock, flags); - } - - /* free wait */ - wait_queue_destroy(wait); -} - -int wake_up(wait_queue_head_t *queue) -{ - return 0; /* KeSetEvent(&wait->event, 0, FALSE); */ -} - - -// -// kernel timer routines -// - -// -// buffer head routines -// - -struct _EXT2_BUFFER_HEAD { - kmem_cache_t * bh_cache; - atomic_t bh_count; - atomic_t bh_acount; -} g_jbh = {NULL, ATOMIC_INIT(0)}; - -int -ext2_init_bh() -{ - g_jbh.bh_count.counter = 0; - g_jbh.bh_acount.counter = 0; - g_jbh.bh_cache = kmem_cache_create( - "ext2_bh", /* bh */ - sizeof(struct buffer_head), - 0, /* offset */ - SLAB_TEMPORARY, /* flags */ - NULL); /* ctor */ - if (g_jbh.bh_cache == NULL) { - printk(KERN_EMERG "JBD: failed to create handle cache\n"); - return -ENOMEM; - } - return 0; -} - -void -ext2_destroy_bh() -{ - if (g_jbh.bh_cache) { - kmem_cache_destroy(g_jbh.bh_cache); - g_jbh.bh_cache = NULL; - } -} - -struct buffer_head * -new_buffer_head() -{ - struct buffer_head * bh = NULL; - bh = kmem_cache_alloc(g_jbh.bh_cache, GFP_NOFS); - if (bh) { - atomic_inc(&g_jbh.bh_count); - atomic_inc(&g_jbh.bh_acount); - - memset(bh, 0, sizeof(struct buffer_head)); - InitializeListHead(&bh->b_link); - KeQuerySystemTime(&bh->b_ts_creat); - DEBUG(DL_BH, ("bh=%p allocated.\n", bh)); - INC_MEM_COUNT(PS_BUFF_HEAD, bh, sizeof(struct buffer_head)); - } - - return bh; -} - -void -free_buffer_head(struct buffer_head * bh) -{ - if (bh) { - if (bh->b_mdl) { - - DEBUG(DL_BH, ("bh=%p mdl=%p (Flags:%xh VA:%p) released.\n", bh, bh->b_mdl, - bh->b_mdl->MdlFlags, bh->b_mdl->MappedSystemVa)); - if (IsFlagOn(bh->b_mdl->MdlFlags, MDL_MAPPED_TO_SYSTEM_VA)) { - MmUnmapLockedPages(bh->b_mdl->MappedSystemVa, bh->b_mdl); - } - Ext2DestroyMdl(bh->b_mdl); - } - if (bh->b_bcb) { - CcUnpinDataForThread(bh->b_bcb, (ERESOURCE_THREAD)bh | 0x3); - } - - DEBUG(DL_BH, ("bh=%p freed.\n", bh)); - DEC_MEM_COUNT(PS_BUFF_HEAD, bh, sizeof(struct buffer_head)); - kmem_cache_free(g_jbh.bh_cache, bh); - atomic_dec(&g_jbh.bh_count); - } -} - -// -// Red-black tree insert routine. -// - -static struct buffer_head *__buffer_head_search(struct rb_root *root, - sector_t blocknr) -{ - struct rb_node *new = root->rb_node; - - /* Figure out where to put new node */ - while (new) { - struct buffer_head *bh = - container_of(new, struct buffer_head, b_rb_node); - s64 result = blocknr - bh->b_blocknr; - - if (result < 0) - new = new->rb_left; - else if (result > 0) - new = new->rb_right; - else - return bh; - - } - - return NULL; -} - -static int buffer_head_blocknr_cmp(struct rb_node *a, struct rb_node *b) -{ - struct buffer_head *a_bh, *b_bh; - s64 result; - a_bh = container_of(a, struct buffer_head, b_rb_node); - b_bh = container_of(b, struct buffer_head, b_rb_node); - result = a_bh->b_blocknr - b_bh->b_blocknr; - - if (result < 0) - return -1; - if (result > 0) - return 1; - return 0; -} - -static struct buffer_head *buffer_head_search(struct block_device *bdev, - sector_t blocknr) -{ - struct rb_root *root; - root = &bdev->bd_bh_root; - return __buffer_head_search(root, blocknr); -} - -static void buffer_head_insert(struct block_device *bdev, struct buffer_head *bh) -{ - rb_insert(&bdev->bd_bh_root, &bh->b_rb_node, buffer_head_blocknr_cmp); -} - -void buffer_head_remove(struct block_device *bdev, struct buffer_head *bh) -{ - rb_erase(&bh->b_rb_node, &bdev->bd_bh_root); -} - -struct buffer_head * -get_block_bh_mdl( - struct block_device * bdev, - sector_t block, - unsigned long size, - int zero -) -{ - PEXT2_VCB Vcb = bdev->bd_priv; - LARGE_INTEGER offset; - PVOID bcb = NULL; - PVOID ptr = NULL; - - struct list_head *entry; - - /* allocate buffer_head and initialize it */ - struct buffer_head *bh = NULL, *tbh = NULL; - - /* check the block is valid or not */ - if (block >= TOTAL_BLOCKS) { - DbgBreak(); - goto errorout; - } - - /* search the bdev bh list */ - ExAcquireSharedStarveExclusive(&bdev->bd_bh_lock, TRUE); - tbh = buffer_head_search(bdev, block); - if (tbh) { - bh = tbh; - get_bh(bh); - ExReleaseResourceLite(&bdev->bd_bh_lock); - goto errorout; - } - ExReleaseResourceLite(&bdev->bd_bh_lock); - - bh = new_buffer_head(); - if (!bh) { - goto errorout; - } - bh->b_bdev = bdev; - bh->b_blocknr = block; - bh->b_size = size; - bh->b_data = NULL; - -again: - - offset.QuadPart = (s64) bh->b_blocknr; - offset.QuadPart <<= BLOCK_BITS; - - if (zero) { - /* PIN_EXCLUSIVE disabled, likely to deadlock with volume operations */ - if (!CcPreparePinWrite(Vcb->Volume, - &offset, - bh->b_size, - FALSE, - PIN_WAIT /* | PIN_EXCLUSIVE */, - &bcb, - &ptr)) { - Ext2Sleep(100); - goto again; - } - } else { - if (!CcPinRead( Vcb->Volume, - &offset, - bh->b_size, - PIN_WAIT, - &bcb, - &ptr)) { - Ext2Sleep(100); - goto again; - } - set_buffer_uptodate(bh); - } - - bh->b_mdl = Ext2CreateMdl(ptr, bh->b_size, IoModifyAccess); - if (bh->b_mdl) { - /* muse map the PTE to NonCached zone. journal recovery will - access the PTE under spinlock: DISPATCH_LEVEL IRQL */ - bh->b_data = MmMapLockedPagesSpecifyCache( - bh->b_mdl, KernelMode, MmNonCached, - NULL,FALSE, HighPagePriority); - /* bh->b_data = MmMapLockedPages(bh->b_mdl, KernelMode); */ - } - if (!bh->b_mdl || !bh->b_data) { - free_buffer_head(bh); - bh = NULL; - goto errorout; - } - - get_bh(bh); - - DEBUG(DL_BH, ("getblk: Vcb=%p bhcount=%u block=%u bh=%p mdl=%p (Flags:%xh VA:%p)\n", - Vcb, atomic_read(&g_jbh.bh_count), block, bh, bh->b_mdl, bh->b_mdl->MdlFlags, bh->b_data)); - - ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); - /* do search again here */ - tbh = buffer_head_search(bdev, block); - if (tbh) { - free_buffer_head(bh); - bh = tbh; - get_bh(bh); - RemoveEntryList(&bh->b_link); - InitializeListHead(&bh->b_link); - ExReleaseResourceLite(&bdev->bd_bh_lock); - goto errorout; - } else { - buffer_head_insert(bdev, bh); - } - ExReleaseResourceLite(&bdev->bd_bh_lock); - - /* we get it */ -errorout: - - if (bcb) - CcUnpinData(bcb); - - return bh; -} - -int submit_bh_mdl(int rw, struct buffer_head *bh) -{ - struct block_device *bdev = bh->b_bdev; - PEXT2_VCB Vcb = bdev->bd_priv; - PBCB Bcb; - PVOID Buffer; - LARGE_INTEGER Offset; - - ASSERT(Vcb->Identifier.Type == EXT2VCB); - ASSERT(bh->b_data); - - if (rw == WRITE) { - - if (IsVcbReadOnly(Vcb)) { - goto errorout; - } - - SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED); - Offset.QuadPart = ((LONGLONG)bh->b_blocknr) << BLOCK_BITS; - - /* PIN_EXCLUSIVE disabled, likely to deadlock with volume operations */ - if (CcPreparePinWrite( - Vcb->Volume, - &Offset, - BLOCK_SIZE, - FALSE, - PIN_WAIT /* | PIN_EXCLUSIVE */, - &Bcb, - &Buffer )) { -#if 0 - if (memcmp(Buffer, bh->b_data, BLOCK_SIZE) != 0) { - DbgBreak(); - } - memmove(Buffer, bh->b_data, BLOCK_SIZE); -#endif - CcSetDirtyPinnedData(Bcb, NULL); - Ext2AddBlockExtent( Vcb, NULL, - (ULONG)bh->b_blocknr, - (ULONG)bh->b_blocknr, - (bh->b_size >> BLOCK_BITS)); - CcUnpinData(Bcb); - } else { - - Ext2AddBlockExtent( Vcb, NULL, - (ULONG)bh->b_blocknr, - (ULONG)bh->b_blocknr, - (bh->b_size >> BLOCK_BITS)); - } - - } else { - } - -errorout: - - unlock_buffer(bh); - put_bh(bh); - return 0; -} - -struct buffer_head * -get_block_bh_pin( - struct block_device * bdev, - sector_t block, - unsigned long size, - int zero -) -{ - PEXT2_VCB Vcb = bdev->bd_priv; - LARGE_INTEGER offset; - - struct list_head *entry; - - /* allocate buffer_head and initialize it */ - struct buffer_head *bh = NULL, *tbh = NULL; - - /* check the block is valid or not */ - if (block >= TOTAL_BLOCKS) { - DbgBreak(); - goto errorout; - } - - /* search the bdev bh list */ - ExAcquireSharedStarveExclusive(&bdev->bd_bh_lock, TRUE); - tbh = buffer_head_search(bdev, block); - if (tbh) { - bh = tbh; - get_bh(bh); - ExReleaseResourceLite(&bdev->bd_bh_lock); - goto errorout; - } - ExReleaseResourceLite(&bdev->bd_bh_lock); - - bh = new_buffer_head(); - if (!bh) { - goto errorout; - } - bh->b_bdev = bdev; - bh->b_blocknr = block; - bh->b_size = size; - bh->b_data = NULL; - -again: - - offset.QuadPart = (s64) bh->b_blocknr; - offset.QuadPart <<= BLOCK_BITS; - - if (zero) { - if (!CcPreparePinWrite(Vcb->Volume, - &offset, - bh->b_size, - FALSE, - PIN_WAIT, - &bh->b_bcb, - &bh->b_data)) { - Ext2Sleep(100); - goto again; - } - } else { - if (!CcPinRead( Vcb->Volume, - &offset, - bh->b_size, - PIN_WAIT, - &bh->b_bcb, - &bh->b_data)) { - Ext2Sleep(100); - goto again; - } - set_buffer_uptodate(bh); - } - - if (bh->b_bcb) - CcSetBcbOwnerPointer(bh->b_bcb, (PVOID)((ERESOURCE_THREAD)bh | 0x3)); - - if (!bh->b_data) { - free_buffer_head(bh); - bh = NULL; - goto errorout; - } - get_bh(bh); - - DEBUG(DL_BH, ("getblk: Vcb=%p bhcount=%u block=%u bh=%p ptr=%p.\n", - Vcb, atomic_read(&g_jbh.bh_count), block, bh, bh->b_data)); - - ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); - /* do search again here */ - tbh = buffer_head_search(bdev, block); - if (tbh) { - get_bh(tbh); - free_buffer_head(bh); - bh = tbh; - RemoveEntryList(&bh->b_link); - InitializeListHead(&bh->b_link); - ExReleaseResourceLite(&bdev->bd_bh_lock); - goto errorout; - } else { - buffer_head_insert(bdev, bh); - } - ExReleaseResourceLite(&bdev->bd_bh_lock); - - /* we get it */ -errorout: - - return bh; -} - -int submit_bh_pin(int rw, struct buffer_head *bh) -{ - struct block_device *bdev = bh->b_bdev; - PEXT2_VCB Vcb = bdev->bd_priv; - PVOID Buffer; - LARGE_INTEGER Offset; - - ASSERT(Vcb->Identifier.Type == EXT2VCB); - ASSERT(bh->b_data && bh->b_bcb); - - if (rw == WRITE) { - - if (IsVcbReadOnly(Vcb)) { - goto errorout; - } - - SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED); - Offset.QuadPart = ((LONGLONG)bh->b_blocknr) << BLOCK_BITS; - - CcSetDirtyPinnedData(bh->b_bcb, NULL); - Ext2AddBlockExtent( Vcb, NULL, - (ULONG)bh->b_blocknr, - (ULONG)bh->b_blocknr, - (bh->b_size >> BLOCK_BITS)); - } else { - } - -errorout: - - unlock_buffer(bh); - put_bh(bh); - return 0; -} - -#if 0 - -struct buffer_head * -get_block_bh( - struct block_device * bdev, - sector_t block, - unsigned long size, - int zero -) -{ - return get_block_bh_mdl(bdev, block, size, zero); -} - -int submit_bh(int rw, struct buffer_head *bh) -{ - return submit_bh_mdl(rw, bh); -} - -#else - -struct buffer_head * -get_block_bh( - struct block_device * bdev, - sector_t block, - unsigned long size, - int zero -) -{ - return get_block_bh_pin(bdev, block, size, zero); -} - -int submit_bh(int rw, struct buffer_head *bh) -{ - return submit_bh_pin(rw, bh); -} -#endif - -struct buffer_head * -__getblk( - struct block_device * bdev, - sector_t block, - unsigned long size -) -{ - return get_block_bh(bdev, block, size, 0); -} - -void __brelse(struct buffer_head *bh) -{ - struct block_device *bdev = bh->b_bdev; - PEXT2_VCB Vcb = (PEXT2_VCB)bdev->bd_priv; - - ASSERT(Vcb->Identifier.Type == EXT2VCB); - - /* write data in case it's dirty */ - while (buffer_dirty(bh)) { - ll_rw_block(WRITE, 1, &bh); - } - - ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); - if (atomic_dec_and_test(&bh->b_count)) { - ASSERT(0 == atomic_read(&bh->b_count)); - } else { - ExReleaseResourceLite(&bdev->bd_bh_lock); - return; - } - KeQuerySystemTime(&bh->b_ts_drop); - RemoveEntryList(&bh->b_link); - InsertTailList(&Vcb->bd.bd_bh_free, &bh->b_link); - KeClearEvent(&Vcb->bd.bd_bh_notify); - ExReleaseResourceLite(&bdev->bd_bh_lock); - KeSetEvent(&Ext2Global->bhReaper.Wait, 0, FALSE); - - DEBUG(DL_BH, ("brelse: cnt=%u size=%u blk=%10.10xh bh=%p ptr=%p\n", - atomic_read(&g_jbh.bh_count) - 1, bh->b_size, - bh->b_blocknr, bh, bh->b_data )); -} - - -void __bforget(struct buffer_head *bh) -{ - clear_buffer_dirty(bh); - __brelse(bh); -} - -void __lock_buffer(struct buffer_head *bh) -{ -} - -void unlock_buffer(struct buffer_head *bh) -{ - clear_buffer_locked(bh); -} - -void __wait_on_buffer(struct buffer_head *bh) -{ -} - -void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]) -{ - int i; - - for (i = 0; i < nr; i++) { - - struct buffer_head *bh = bhs[i]; - - if (rw == SWRITE) - lock_buffer(bh); - else if (test_set_buffer_locked(bh)) - continue; - - if (rw == WRITE || rw == SWRITE) { - if (test_clear_buffer_dirty(bh)) { - get_bh(bh); - submit_bh(WRITE, bh); - continue; - } - } else { - if (!buffer_uptodate(bh)) { - get_bh(bh); - submit_bh(rw, bh); - continue; - } - } - unlock_buffer(bh); - } -} - -int bh_submit_read(struct buffer_head *bh) -{ - ll_rw_block(READ, 1, &bh); - return 0; -} - -int sync_dirty_buffer(struct buffer_head *bh) -{ - int ret = 0; - - ASSERT(atomic_read(&bh->b_count) <= 1); - lock_buffer(bh); - if (test_clear_buffer_dirty(bh)) { - get_bh(bh); - ret = submit_bh(WRITE, bh); - wait_on_buffer(bh); - } else { - unlock_buffer(bh); - } - return ret; -} - -void mark_buffer_dirty(struct buffer_head *bh) -{ - set_buffer_dirty(bh); -} - -int sync_blockdev(struct block_device *bdev) -{ - PEXT2_VCB Vcb = (PEXT2_VCB) bdev->bd_priv; - Ext2FlushVolume(NULL, Vcb, FALSE); - return 0; -} - -/* - * Perform a pagecache lookup for the matching buffer. If it's there, refre - * it in the LRU and mark it as accessed. If it is not present then return - * NULL - */ -struct buffer_head * -__find_get_block(struct block_device *bdev, sector_t block, unsigned long size) -{ - return __getblk(bdev, block, size); -} - - -// -// inode block mapping -// - -ULONGLONG bmap(struct inode *i, ULONGLONG b) -{ - ULONGLONG lcn = 0; - struct super_block *s = i->i_sb; - - PEXT2_MCB Mcb = (PEXT2_MCB)i->i_priv; - PEXT2_VCB Vcb = (PEXT2_VCB)s->s_priv; - PEXT2_EXTENT extent = NULL; - ULONGLONG offset = (ULONGLONG)b; - NTSTATUS status; - - if (!Mcb || !Vcb) { - goto errorout; - } - - offset <<= BLOCK_BITS; - status = Ext2BuildExtents( - NULL, - Vcb, - Mcb, - offset, - BLOCK_SIZE, - FALSE, - &extent - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - - if (extent == NULL) { - goto errorout; - } - - lcn = (unsigned long)(extent->Lba >> BLOCK_BITS); - -errorout: - - if (extent) { - Ext2FreeExtent(extent); - } - - return lcn; -} - -void iget(struct inode *inode) -{ - atomic_inc(&inode->i_count); -} - -void iput(struct inode *inode) -{ - if (atomic_dec_and_test(&inode->i_count)) { - kfree(inode); - } -} - -// -// initialzer and destructor -// - -int -ext2_init_linux() -{ - int rc = 0; - - rc = ext2_init_bh(); - if (rc != 0) { - goto errorout; - } - -errorout: - - return rc; -} - -void -ext2_destroy_linux() -{ - ext2_destroy_bh(); -} +/* + * COPYRIGHT: See COPYRIGHT.TXT + * PROJECT: Ext2 File System Driver for WinNT/2K/XP + * FILE: linux.c + * PROGRAMMER: Matt Wu + * HOMEPAGE: http://www.ext2fsd.com + * UPDATE HISTORY: + */ + +/* INCLUDES *****************************************************************/ + +#include +#include +#include + +/* GLOBALS ***************************************************************/ + +extern PEXT2_GLOBAL Ext2Global; + +/* DEFINITIONS *************************************************************/ + +#ifdef ALLOC_PRAGMA +#pragma alloc_text(PAGE, kzalloc) +#endif + +struct task_struct current_task = { + /* pid */ 0, + /* tid */ 1, + /* comm */ "current\0", + /* journal_info */ NULL +}; +struct task_struct *current = ¤t_task; + +void *kzalloc(int size, int flags) +{ + void *buffer = kmalloc(size, flags); + if (buffer) { + memset(buffer, 0, size); + } + return buffer; +} + +// +// slab routines +// + +kmem_cache_t * +kmem_cache_create( + const char * name, + size_t size, + size_t offset, + unsigned long flags, + kmem_cache_cb_t ctor +) +{ + kmem_cache_t *kc = NULL; + + kc = kmalloc(sizeof(kmem_cache_t), GFP_KERNEL); + if (kc == NULL) { + goto errorout; + } + + memset(kc, 0, sizeof(kmem_cache_t)); + ExInitializeNPagedLookasideList( + &kc->la, + NULL, + NULL, + 0, + size, + 'JBKC', + 0); + + kc->size = size; + strncpy(kc->name, name, 31); + kc->constructor = ctor; + +errorout: + + return kc; +} + +int kmem_cache_destroy(kmem_cache_t * kc) +{ + ASSERT(kc != NULL); + + ExDeleteNPagedLookasideList(&(kc->la)); + kfree(kc); + + return 0; +} + +void* kmem_cache_alloc(kmem_cache_t *kc, int flags) +{ + PVOID ptr = NULL; + ptr = ExAllocateFromNPagedLookasideList(&(kc->la)); + if (ptr) { + atomic_inc(&kc->count); + atomic_inc(&kc->acount); + } + return ptr; +} + +void kmem_cache_free(kmem_cache_t *kc, void *p) +{ + if (p) { + atomic_dec(&kc->count); + ExFreeToNPagedLookasideList(&(kc->la), p); + } +} + +// +// wait queue routines +// + +void init_waitqueue_head(wait_queue_head_t *q) +{ + spin_lock_init(&q->lock); + INIT_LIST_HEAD(&q->task_list); +} + +struct __wait_queue * +wait_queue_create() +{ + struct __wait_queue * wait = NULL; + wait = kmalloc(sizeof(struct __wait_queue), GFP_KERNEL); + if (!wait) { + return NULL; + } + + memset(wait, 0, sizeof(struct __wait_queue)); + wait->flags = WQ_FLAG_AUTO_REMOVAL; + wait->private = (void *)KeGetCurrentThread(); + INIT_LIST_HEAD(&wait->task_list); + KeInitializeEvent(&(wait->event), + SynchronizationEvent, + FALSE); + + return wait; +} + +void +wait_queue_destroy(struct __wait_queue * wait) +{ + kfree(wait); +} + +static inline void __add_wait_queue(wait_queue_head_t *head, struct __wait_queue *new) +{ + list_add(&new->task_list, &head->task_list); +} + +/* + * Used for wake-one threads: + */ +static inline void __add_wait_queue_tail(wait_queue_head_t *head, + struct __wait_queue *new) +{ + list_add_tail(&new->task_list, &head->task_list); +} + +static inline void __remove_wait_queue(wait_queue_head_t *head, + struct __wait_queue *old) +{ + list_del(&old->task_list); +} + +void add_wait_queue(wait_queue_head_t *q, wait_queue_t *waiti) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + wait->flags &= ~WQ_FLAG_EXCLUSIVE; + spin_lock_irqsave(&q->lock, flags); + __add_wait_queue(q, wait); + spin_unlock_irqrestore(&q->lock, flags); +} + +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *waiti) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + wait->flags |= WQ_FLAG_EXCLUSIVE; + spin_lock_irqsave(&q->lock, flags); + __add_wait_queue_tail(q, wait); + spin_unlock_irqrestore(&q->lock, flags); +} + +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *waiti) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + spin_lock_irqsave(&q->lock, flags); + __remove_wait_queue(q, wait); + spin_unlock_irqrestore(&q->lock, flags); +} + +/* + * Note: we use "set_current_state()" _after_ the wait-queue add, + * because we need a memory barrier there on SMP, so that any + * wake-function that tests for the wait-queue being active + * will be guaranteed to see waitqueue addition _or_ subsequent + * tests in this thread will see the wakeup having taken place. + * + * The spin_unlock() itself is semi-permeable and only protects + * one way (it only protects stuff inside the critical region and + * stops them from bleeding out - it would still allow subsequent + * loads to move into the critical region). + */ +void +prepare_to_wait(wait_queue_head_t *q, wait_queue_t *waiti, int state) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + wait->flags &= ~WQ_FLAG_EXCLUSIVE; + spin_lock_irqsave(&q->lock, flags); + if (list_empty(&wait->task_list)) + __add_wait_queue(q, wait); + /* + * don't alter the task state if this is just going to + * queue an async wait queue callback + */ + if (is_sync_wait(wait)) + set_current_state(state); + spin_unlock_irqrestore(&q->lock, flags); +} + +void +prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *waiti, int state) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + wait->flags |= WQ_FLAG_EXCLUSIVE; + spin_lock_irqsave(&q->lock, flags); + if (list_empty(&wait->task_list)) + __add_wait_queue_tail(q, wait); + /* + * don't alter the task state if this is just going to + * queue an async wait queue callback + */ + if (is_sync_wait(wait)) + set_current_state(state); + spin_unlock_irqrestore(&q->lock, flags); +} +EXPORT_SYMBOL(prepare_to_wait_exclusive); + +void finish_wait(wait_queue_head_t *q, wait_queue_t *waiti) +{ + unsigned long flags; + struct __wait_queue *wait = *waiti; + + __set_current_state(TASK_RUNNING); + /* + * We can check for list emptiness outside the lock + * IFF: + * - we use the "careful" check that verifies both + * the next and prev pointers, so that there cannot + * be any half-pending updates in progress on other + * CPU's that we haven't seen yet (and that might + * still change the stack area. + * and + * - all other users take the lock (ie we can only + * have _one_ other CPU that looks at or modifies + * the list). + */ + if (!list_empty_careful(&wait->task_list)) { + spin_lock_irqsave(&q->lock, flags); + list_del_init(&wait->task_list); + spin_unlock_irqrestore(&q->lock, flags); + } + + /* free wait */ + wait_queue_destroy(wait); +} + +int wake_up(wait_queue_head_t *queue) +{ + return 0; /* KeSetEvent(&wait->event, 0, FALSE); */ +} + + +// +// kernel timer routines +// + +// +// buffer head routines +// + +struct _EXT2_BUFFER_HEAD { + kmem_cache_t * bh_cache; + atomic_t bh_count; + atomic_t bh_acount; +} g_jbh = {NULL, ATOMIC_INIT(0)}; + +int +ext2_init_bh() +{ + g_jbh.bh_count.counter = 0; + g_jbh.bh_acount.counter = 0; + g_jbh.bh_cache = kmem_cache_create( + "ext2_bh", /* bh */ + sizeof(struct buffer_head), + 0, /* offset */ + SLAB_TEMPORARY, /* flags */ + NULL); /* ctor */ + if (g_jbh.bh_cache == NULL) { + printk(KERN_EMERG "JBD: failed to create handle cache\n"); + return -ENOMEM; + } + return 0; +} + +void +ext2_destroy_bh() +{ + if (g_jbh.bh_cache) { + kmem_cache_destroy(g_jbh.bh_cache); + g_jbh.bh_cache = NULL; + } +} + +struct buffer_head * +new_buffer_head() +{ + struct buffer_head * bh = NULL; + bh = kmem_cache_alloc(g_jbh.bh_cache, GFP_NOFS); + if (bh) { + atomic_inc(&g_jbh.bh_count); + atomic_inc(&g_jbh.bh_acount); + + memset(bh, 0, sizeof(struct buffer_head)); + InitializeListHead(&bh->b_link); + KeQuerySystemTime(&bh->b_ts_creat); + DEBUG(DL_BH, ("bh=%p allocated.\n", bh)); + INC_MEM_COUNT(PS_BUFF_HEAD, bh, sizeof(struct buffer_head)); + } + + return bh; +} + +void +free_buffer_head(struct buffer_head * bh) +{ + if (bh) { + if (bh->b_mdl) { + + DEBUG(DL_BH, ("bh=%p mdl=%p (Flags:%xh VA:%p) released.\n", bh, bh->b_mdl, + bh->b_mdl->MdlFlags, bh->b_mdl->MappedSystemVa)); + if (IsFlagOn(bh->b_mdl->MdlFlags, MDL_MAPPED_TO_SYSTEM_VA)) { + MmUnmapLockedPages(bh->b_mdl->MappedSystemVa, bh->b_mdl); + } + Ext2DestroyMdl(bh->b_mdl); + } + if (bh->b_bcb) { + CcUnpinDataForThread(bh->b_bcb, (ERESOURCE_THREAD)bh | 0x3); + } + + DEBUG(DL_BH, ("bh=%p freed.\n", bh)); + DEC_MEM_COUNT(PS_BUFF_HEAD, bh, sizeof(struct buffer_head)); + kmem_cache_free(g_jbh.bh_cache, bh); + atomic_dec(&g_jbh.bh_count); + } +} + +// +// Red-black tree insert routine. +// + +static struct buffer_head *__buffer_head_search(struct rb_root *root, + sector_t blocknr) +{ + struct rb_node *new = root->rb_node; + + /* Figure out where to put new node */ + while (new) { + struct buffer_head *bh = + container_of(new, struct buffer_head, b_rb_node); + s64 result = blocknr - bh->b_blocknr; + + if (result < 0) + new = new->rb_left; + else if (result > 0) + new = new->rb_right; + else + return bh; + + } + + return NULL; +} + +static int buffer_head_blocknr_cmp(struct rb_node *a, struct rb_node *b) +{ + struct buffer_head *a_bh, *b_bh; + s64 result; + a_bh = container_of(a, struct buffer_head, b_rb_node); + b_bh = container_of(b, struct buffer_head, b_rb_node); + result = a_bh->b_blocknr - b_bh->b_blocknr; + + if (result < 0) + return -1; + if (result > 0) + return 1; + return 0; +} + +static struct buffer_head *buffer_head_search(struct block_device *bdev, + sector_t blocknr) +{ + struct rb_root *root; + root = &bdev->bd_bh_root; + return __buffer_head_search(root, blocknr); +} + +static void buffer_head_insert(struct block_device *bdev, struct buffer_head *bh) +{ + rb_insert(&bdev->bd_bh_root, &bh->b_rb_node, buffer_head_blocknr_cmp); +} + +void buffer_head_remove(struct block_device *bdev, struct buffer_head *bh) +{ + rb_erase(&bh->b_rb_node, &bdev->bd_bh_root); +} + +struct buffer_head * +get_block_bh_mdl( + struct block_device * bdev, + sector_t block, + unsigned long size, + int zero +) +{ + PEXT2_VCB Vcb = bdev->bd_priv; + LARGE_INTEGER offset; + PVOID bcb = NULL; + PVOID ptr = NULL; + + struct list_head *entry; + + /* allocate buffer_head and initialize it */ + struct buffer_head *bh = NULL, *tbh = NULL; + + /* check the block is valid or not */ + if (block >= TOTAL_BLOCKS) { + DbgBreak(); + goto errorout; + } + + /* search the bdev bh list */ + ExAcquireSharedStarveExclusive(&bdev->bd_bh_lock, TRUE); + tbh = buffer_head_search(bdev, block); + if (tbh) { + bh = tbh; + get_bh(bh); + ExReleaseResourceLite(&bdev->bd_bh_lock); + goto errorout; + } + ExReleaseResourceLite(&bdev->bd_bh_lock); + + bh = new_buffer_head(); + if (!bh) { + goto errorout; + } + bh->b_bdev = bdev; + bh->b_blocknr = block; + bh->b_size = size; + bh->b_data = NULL; + +again: + + offset.QuadPart = (s64) bh->b_blocknr; + offset.QuadPart <<= BLOCK_BITS; + + if (zero) { + /* PIN_EXCLUSIVE disabled, likely to deadlock with volume operations */ + if (!CcPreparePinWrite(Vcb->Volume, + &offset, + bh->b_size, + FALSE, + PIN_WAIT /* | PIN_EXCLUSIVE */, + &bcb, + &ptr)) { + Ext2Sleep(100); + goto again; + } + } else { + if (!CcPinRead( Vcb->Volume, + &offset, + bh->b_size, + PIN_WAIT, + &bcb, + &ptr)) { + Ext2Sleep(100); + goto again; + } + set_buffer_uptodate(bh); + } + + bh->b_mdl = Ext2CreateMdl(ptr, bh->b_size, IoModifyAccess); + if (bh->b_mdl) { + /* muse map the PTE to NonCached zone. journal recovery will + access the PTE under spinlock: DISPATCH_LEVEL IRQL */ + bh->b_data = MmMapLockedPagesSpecifyCache( + bh->b_mdl, KernelMode, MmNonCached, + NULL,FALSE, HighPagePriority); + /* bh->b_data = MmMapLockedPages(bh->b_mdl, KernelMode); */ + } + if (!bh->b_mdl || !bh->b_data) { + free_buffer_head(bh); + bh = NULL; + goto errorout; + } + + get_bh(bh); + + DEBUG(DL_BH, ("getblk: Vcb=%p bhcount=%u block=%u bh=%p mdl=%p (Flags:%xh VA:%p)\n", + Vcb, atomic_read(&g_jbh.bh_count), block, bh, bh->b_mdl, bh->b_mdl->MdlFlags, bh->b_data)); + + ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); + /* do search again here */ + tbh = buffer_head_search(bdev, block); + if (tbh) { + free_buffer_head(bh); + bh = tbh; + get_bh(bh); + RemoveEntryList(&bh->b_link); + InitializeListHead(&bh->b_link); + ExReleaseResourceLite(&bdev->bd_bh_lock); + goto errorout; + } else { + buffer_head_insert(bdev, bh); + } + ExReleaseResourceLite(&bdev->bd_bh_lock); + + /* we get it */ +errorout: + + if (bcb) + CcUnpinData(bcb); + + return bh; +} + +int submit_bh_mdl(int rw, struct buffer_head *bh) +{ + struct block_device *bdev = bh->b_bdev; + PEXT2_VCB Vcb = bdev->bd_priv; + PBCB Bcb; + PVOID Buffer; + LARGE_INTEGER Offset; + + ASSERT(Vcb->Identifier.Type == EXT2VCB); + ASSERT(bh->b_data); + + if (rw == WRITE) { + + if (IsVcbReadOnly(Vcb)) { + goto errorout; + } + + SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED); + Offset.QuadPart = ((LONGLONG)bh->b_blocknr) << BLOCK_BITS; + + /* PIN_EXCLUSIVE disabled, likely to deadlock with volume operations */ + if (CcPreparePinWrite( + Vcb->Volume, + &Offset, + BLOCK_SIZE, + FALSE, + PIN_WAIT /* | PIN_EXCLUSIVE */, + &Bcb, + &Buffer )) { +#if 0 + if (memcmp(Buffer, bh->b_data, BLOCK_SIZE) != 0) { + DbgBreak(); + } + memmove(Buffer, bh->b_data, BLOCK_SIZE); +#endif + CcSetDirtyPinnedData(Bcb, NULL); + Ext2AddBlockExtent( Vcb, NULL, + (ULONG)bh->b_blocknr, + (ULONG)bh->b_blocknr, + (bh->b_size >> BLOCK_BITS)); + CcUnpinData(Bcb); + } else { + + Ext2AddBlockExtent( Vcb, NULL, + (ULONG)bh->b_blocknr, + (ULONG)bh->b_blocknr, + (bh->b_size >> BLOCK_BITS)); + } + + } else { + } + +errorout: + + unlock_buffer(bh); + put_bh(bh); + return 0; +} + +struct buffer_head * +get_block_bh_pin( + struct block_device * bdev, + sector_t block, + unsigned long size, + int zero +) +{ + PEXT2_VCB Vcb = bdev->bd_priv; + LARGE_INTEGER offset; + + struct list_head *entry; + + /* allocate buffer_head and initialize it */ + struct buffer_head *bh = NULL, *tbh = NULL; + + /* check the block is valid or not */ + if (block >= TOTAL_BLOCKS) { + DbgBreak(); + goto errorout; + } + + /* search the bdev bh list */ + ExAcquireSharedStarveExclusive(&bdev->bd_bh_lock, TRUE); + tbh = buffer_head_search(bdev, block); + if (tbh) { + bh = tbh; + get_bh(bh); + ExReleaseResourceLite(&bdev->bd_bh_lock); + goto errorout; + } + ExReleaseResourceLite(&bdev->bd_bh_lock); + + bh = new_buffer_head(); + if (!bh) { + goto errorout; + } + bh->b_bdev = bdev; + bh->b_blocknr = block; + bh->b_size = size; + bh->b_data = NULL; + +again: + + offset.QuadPart = (s64) bh->b_blocknr; + offset.QuadPart <<= BLOCK_BITS; + + if (zero) { + if (!CcPreparePinWrite(Vcb->Volume, + &offset, + bh->b_size, + FALSE, + PIN_WAIT, + &bh->b_bcb, + &bh->b_data)) { + Ext2Sleep(100); + goto again; + } + } else { + if (!CcPinRead( Vcb->Volume, + &offset, + bh->b_size, + PIN_WAIT, + &bh->b_bcb, + &bh->b_data)) { + Ext2Sleep(100); + goto again; + } + set_buffer_uptodate(bh); + } + + if (bh->b_bcb) + CcSetBcbOwnerPointer(bh->b_bcb, (PVOID)((ERESOURCE_THREAD)bh | 0x3)); + + if (!bh->b_data) { + free_buffer_head(bh); + bh = NULL; + goto errorout; + } + get_bh(bh); + + DEBUG(DL_BH, ("getblk: Vcb=%p bhcount=%u block=%u bh=%p ptr=%p.\n", + Vcb, atomic_read(&g_jbh.bh_count), block, bh, bh->b_data)); + + ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); + /* do search again here */ + tbh = buffer_head_search(bdev, block); + if (tbh) { + get_bh(tbh); + free_buffer_head(bh); + bh = tbh; + RemoveEntryList(&bh->b_link); + InitializeListHead(&bh->b_link); + ExReleaseResourceLite(&bdev->bd_bh_lock); + goto errorout; + } else { + buffer_head_insert(bdev, bh); + } + ExReleaseResourceLite(&bdev->bd_bh_lock); + + /* we get it */ +errorout: + + return bh; +} + +int submit_bh_pin(int rw, struct buffer_head *bh) +{ + struct block_device *bdev = bh->b_bdev; + PEXT2_VCB Vcb = bdev->bd_priv; + PVOID Buffer; + LARGE_INTEGER Offset; + + ASSERT(Vcb->Identifier.Type == EXT2VCB); + ASSERT(bh->b_data && bh->b_bcb); + + if (rw == WRITE) { + + if (IsVcbReadOnly(Vcb)) { + goto errorout; + } + + SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED); + Offset.QuadPart = ((LONGLONG)bh->b_blocknr) << BLOCK_BITS; + + CcSetDirtyPinnedData(bh->b_bcb, NULL); + Ext2AddBlockExtent( Vcb, NULL, + (ULONG)bh->b_blocknr, + (ULONG)bh->b_blocknr, + (bh->b_size >> BLOCK_BITS)); + } else { + } + +errorout: + + unlock_buffer(bh); + put_bh(bh); + return 0; +} + +#if 0 + +struct buffer_head * +get_block_bh( + struct block_device * bdev, + sector_t block, + unsigned long size, + int zero +) +{ + return get_block_bh_mdl(bdev, block, size, zero); +} + +int submit_bh(int rw, struct buffer_head *bh) +{ + return submit_bh_mdl(rw, bh); +} + +#else + +struct buffer_head * +get_block_bh( + struct block_device * bdev, + sector_t block, + unsigned long size, + int zero +) +{ + return get_block_bh_pin(bdev, block, size, zero); +} + +int submit_bh(int rw, struct buffer_head *bh) +{ + return submit_bh_pin(rw, bh); +} +#endif + +struct buffer_head * +__getblk( + struct block_device * bdev, + sector_t block, + unsigned long size +) +{ + return get_block_bh(bdev, block, size, 0); +} + +void __brelse(struct buffer_head *bh) +{ + struct block_device *bdev = bh->b_bdev; + PEXT2_VCB Vcb = (PEXT2_VCB)bdev->bd_priv; + + ASSERT(Vcb->Identifier.Type == EXT2VCB); + + /* write data in case it's dirty */ + while (buffer_dirty(bh)) { + ll_rw_block(WRITE, 1, &bh); + } + + ExAcquireResourceExclusiveLite(&bdev->bd_bh_lock, TRUE); + if (atomic_dec_and_test(&bh->b_count)) { + ASSERT(0 == atomic_read(&bh->b_count)); + } else { + ExReleaseResourceLite(&bdev->bd_bh_lock); + return; + } + KeQuerySystemTime(&bh->b_ts_drop); + RemoveEntryList(&bh->b_link); + InsertTailList(&Vcb->bd.bd_bh_free, &bh->b_link); + KeClearEvent(&Vcb->bd.bd_bh_notify); + ExReleaseResourceLite(&bdev->bd_bh_lock); + KeSetEvent(&Ext2Global->bhReaper.Wait, 0, FALSE); + + DEBUG(DL_BH, ("brelse: cnt=%u size=%u blk=%10.10xh bh=%p ptr=%p\n", + atomic_read(&g_jbh.bh_count) - 1, bh->b_size, + bh->b_blocknr, bh, bh->b_data )); +} + + +void __bforget(struct buffer_head *bh) +{ + clear_buffer_dirty(bh); + __brelse(bh); +} + +void __lock_buffer(struct buffer_head *bh) +{ +} + +void unlock_buffer(struct buffer_head *bh) +{ + clear_buffer_locked(bh); +} + +void __wait_on_buffer(struct buffer_head *bh) +{ +} + +void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]) +{ + int i; + + for (i = 0; i < nr; i++) { + + struct buffer_head *bh = bhs[i]; + + if (rw == SWRITE) + lock_buffer(bh); + else if (test_set_buffer_locked(bh)) + continue; + + if (rw == WRITE || rw == SWRITE) { + if (test_clear_buffer_dirty(bh)) { + get_bh(bh); + submit_bh(WRITE, bh); + continue; + } + } else { + if (!buffer_uptodate(bh)) { + get_bh(bh); + submit_bh(rw, bh); + continue; + } + } + unlock_buffer(bh); + } +} + +int bh_submit_read(struct buffer_head *bh) +{ + ll_rw_block(READ, 1, &bh); + return 0; +} + +int sync_dirty_buffer(struct buffer_head *bh) +{ + int ret = 0; + + ASSERT(atomic_read(&bh->b_count) <= 1); + lock_buffer(bh); + if (test_clear_buffer_dirty(bh)) { + get_bh(bh); + ret = submit_bh(WRITE, bh); + wait_on_buffer(bh); + } else { + unlock_buffer(bh); + } + return ret; +} + +void mark_buffer_dirty(struct buffer_head *bh) +{ + set_buffer_dirty(bh); +} + +int sync_blockdev(struct block_device *bdev) +{ + PEXT2_VCB Vcb = (PEXT2_VCB) bdev->bd_priv; + Ext2FlushVolume(NULL, Vcb, FALSE); + return 0; +} + +/* + * Perform a pagecache lookup for the matching buffer. If it's there, refre + * it in the LRU and mark it as accessed. If it is not present then return + * NULL + */ +struct buffer_head * +__find_get_block(struct block_device *bdev, sector_t block, unsigned long size) +{ + return __getblk(bdev, block, size); +} + + +// +// inode block mapping +// + +ULONGLONG bmap(struct inode *i, ULONGLONG b) +{ + ULONGLONG lcn = 0; + struct super_block *s = i->i_sb; + + PEXT2_MCB Mcb = (PEXT2_MCB)i->i_priv; + PEXT2_VCB Vcb = (PEXT2_VCB)s->s_priv; + PEXT2_EXTENT extent = NULL; + ULONGLONG offset = (ULONGLONG)b; + NTSTATUS status; + + if (!Mcb || !Vcb) { + goto errorout; + } + + offset <<= BLOCK_BITS; + status = Ext2BuildExtents( + NULL, + Vcb, + Mcb, + offset, + BLOCK_SIZE, + FALSE, + &extent + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + + if (extent == NULL) { + goto errorout; + } + + lcn = (unsigned long)(extent->Lba >> BLOCK_BITS); + +errorout: + + if (extent) { + Ext2FreeExtent(extent); + } + + return lcn; +} + +void iget(struct inode *inode) +{ + atomic_inc(&inode->i_count); +} + +void iput(struct inode *inode) +{ + if (atomic_dec_and_test(&inode->i_count)) { + kfree(inode); + } +} + +// +// string functions from linux/lib/string.c +// + +int _strnicmp(const char* str1, const char* str2, size_t count) +{ + unsigned int c1, c2; + + if (!count) + return 0; + + do { + c1 = *str1++; + c2 = *str2++; + if (!c1 || !c2) + break; + if (c1 == c2) + continue; + c1 = tolower(c1); + c2 = tolower(c2); + if (c1 != c2) + break; + } while (--count); + return (int)c1 - (int)c2; +} + +int strncmp(const char* str1, const char* str2, size_t count) +{ + unsigned char c1, c2; + + while (count) { + c1 = *str1++; + c2 = *str2++; + if (c1 != c2) + return c1 < c2 ? -1 : 1; + if (!c1) + break; + count--; + } + return 0; +} + +char* strncpy(char* dest, const char* src, size_t count) +{ + char *p = dest; + + while (count) { + if ((*p = *src) != 0) + src++; + p++; + count--; + } + return dest; +} + +// +// initialzer and destructor +// + +int +ext2_init_linux() +{ + int rc = 0; + + rc = ext2_init_bh(); + if (rc != 0) { + goto errorout; + } + +errorout: + + return rc; +} + +void +ext2_destroy_linux() +{ + ext2_destroy_bh(); +} diff --git a/Ext4Fsd/misc.c b/Ext4Fsd/misc.c index 91c3740..d78f5b8 100644 --- a/Ext4Fsd/misc.c +++ b/Ext4Fsd/misc.c @@ -436,8 +436,8 @@ NTSTATUS Ext2WinntError(int rc) case -EBUSY: return STATUS_DEVICE_BUSY; - case -ENOSYS: - return STATUS_NOT_IMPLEMENTED; +/* case -ENOSYS: + return STATUS_NOT_IMPLEMENTED;*/ case -ENOSPC: return STATUS_DISK_FULL; @@ -445,8 +445,8 @@ NTSTATUS Ext2WinntError(int rc) case -EOPNOTSUPP: return STATUS_NOT_SUPPORTED; - case -EDEADLK: - return STATUS_POSSIBLE_DEADLOCK; +/* case -EDEADLK: + return STATUS_POSSIBLE_DEADLOCK;*/ case -EEXIST: return STATUS_OBJECT_NAME_COLLISION; @@ -460,8 +460,8 @@ NTSTATUS Ext2WinntError(int rc) case -EISDIR: return STATUS_FILE_IS_A_DIRECTORY; - case -ENOTEMPTY: - return STATUS_DIRECTORY_NOT_EMPTY; +/* case -ENOTEMPTY: + return STATUS_DIRECTORY_NOT_EMPTY;*/ case -ENODEV: return STATUS_NO_SUCH_DEVICE;