Skip to content

Commit 83a607e

Browse files
committed
directory notifications excluded when populate by STREAM
1 parent 30cb069 commit 83a607e

File tree

5 files changed

+50
-13
lines changed

5 files changed

+50
-13
lines changed

source/P4VFS.Console/P4VFS.Notes.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
Microsoft P4VFS Release Notes
22

3+
Version [1.29.0.0]
4+
* Fixing virtual file hydration to be excluded from system directory notifications.
5+
This avoids unecessary FILE_NOTIFY_INFORMATION or DirectoryWatcher events indicating
6+
a virtual file has been modified, when it's only been hydrated as-expected on read.
7+
This technique is common across filter drivers. This is only supported for STREAM
8+
populate method (default). New unit test TestReadDirectoryChanges for verification.
9+
* Additional unit test varible P4VFS_TEST_SERVER_ROOT for overriding the root directory
10+
for the test servers. This better facilitates running all tests remotely on a local
11+
virtual machine with including kernel mode debugging. Includes support for
12+
RestartPerforceServer script to quick spin-up of existing server on override drive
13+
314
Version [1.28.4.0]
415
* Addition of optional service commandline argument to launch with debugger attached.
516
This is done as needed from admin command prompt "sc.exe start P4VFS.Service --break"

source/P4VFS.Core/Include/FileOperations.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ namespace Microsoft {
1010
namespace P4VFS {
1111
namespace FileOperations {
1212

13+
HRESULT
14+
RestrictFileTimeChange(
15+
HANDLE hFile
16+
);
17+
18+
HRESULT
19+
SetFileAttributesOnHandle(
20+
HANDLE hFile,
21+
DWORD dwFileAttributes
22+
);
23+
1324
bool
1425
SleepAndVerifyFileExists(
1526
const WCHAR* filePath,

source/P4VFS.Core/Source/FileOperations.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ RestrictFileTimeChange(
7171
return S_OK;
7272
}
7373

74+
HRESULT
75+
SetFileAttributesOnHandle(
76+
HANDLE hFile,
77+
DWORD dwFileAttributes
78+
)
79+
{
80+
FILE_BASIC_INFO basicInfo = {0};
81+
basicInfo.FileAttributes = dwFileAttributes;
82+
83+
if (!SetFileInformationByHandle(hFile, FileBasicInfo, &basicInfo, sizeof(basicInfo)))
84+
{
85+
return HRESULT_FROM_WIN32(GetLastError());
86+
}
87+
88+
return S_OK;
89+
}
90+
7491
bool
7592
SleepAndVerifyFileExists(
7693
const WCHAR* filePath,
@@ -1116,12 +1133,6 @@ PopulateFileByStream(
11161133
return hr;
11171134
}
11181135

1119-
if (SetFileAttributes(fileToPopulate.c_str(), dstFileAttributes & ~FILE_ATTRIBUTE_READONLY) == FALSE)
1120-
{
1121-
hr = HRESULT_FROM_WIN32(GetLastError());
1122-
return hr;
1123-
}
1124-
11251136
FileCore::FileStream* fileToPopulateFrom = srcFileStream;
11261137
if (fileToPopulateFrom == nullptr || fileToPopulateFrom->CanRead() == false)
11271138
{
@@ -1170,17 +1181,16 @@ PopulateFileByStream(
11701181
hr = RemoveSparseFileSizeOnHandle(dstFile.Handle());
11711182
if (FAILED(hr))
11721183
{
1173-
return hr;
1184+
return hr;
11741185
}
11751186

1176-
dstFile.Close();
1177-
1178-
if (!SetFileAttributes(fileToPopulate.c_str(), dstFileAttributes & ~(FILE_ATTRIBUTE_OFFLINE)))
1187+
hr = SetFileAttributesOnHandle(dstFile.Handle(), dstFileAttributes & ~(FILE_ATTRIBUTE_OFFLINE));
1188+
if (FAILED(hr))
11791189
{
1180-
hr = HRESULT_FROM_WIN32(GetLastError());
11811190
return hr;
11821191
}
11831192

1193+
dstFile.Close();
11841194
return S_OK;
11851195
}
11861196

source/P4VFS.Driver/Include/DriverVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define P4VFS_VER_MAJOR 1 // Increment this number almost never
66
#define P4VFS_VER_MINOR 28 // Increment this number whenever the driver changes
77
#define P4VFS_VER_BUILD 4 // Increment this number when a major user mode change has been made
8-
#define P4VFS_VER_REVISION 6 // Increment this number when we rebuild with any change
8+
#define P4VFS_VER_REVISION 7 // Increment this number when we rebuild with any change
99

1010
#define P4VFS_VER_STRINGIZE_EX(v) L#v
1111
#define P4VFS_VER_STRINGIZE(v) P4VFS_VER_STRINGIZE_EX(v)

source/P4VFS.UnitTest/Scripts/RestartPerforceServer.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ PUSHD "%SCRIPT_FOLDER%\..\..\.."
1414
SET REPO_FOLDER=%CD%
1515
POPD
1616

17-
SET SERVER_FOLDER=%REPO_FOLDER%\intermediate\1666
17+
IF NOT "%P4VFS_TEST_SERVER_ROOT%"=="" (
18+
SET SERVER_FOLDER=%P4VFS_TEST_SERVER_ROOT%\1666
19+
) ELSE (
20+
SET SERVER_FOLDER=%REPO_FOLDER%\intermediate\1666
21+
)
22+
1823
SET P4D_EXE=%SERVER_FOLDER%\p4d.exe
1924
SET P4_EXE=p4.exe
2025
FOR /F "tokens=*" %%A IN ('dir /s /b "%REPO_FOLDER%\external\P4API\p4.exe"') DO (

0 commit comments

Comments
 (0)