Gentlefolk
I seem to have found a bug in filter manager in WSL Feb CTP. The problem is
that the name cache is not correct in the presence of transactions.
I have pasted below a test function (user mode) [outlook has messed up
indent]. I call this function with filename = “e:\testdir\testfile” and flag
as either TRUE or FALSE.
If I call with flag TRUE then a call to …
FltGetFileNameInformation(CallbackData, FLT_FILE_NAME_NORMALIZED |
FLT_FILE_NAME_QUERY_DEFAULT, &FileNameInformation);
… in post create for the final create file after the transaction has been
commit returns \testdir\testfile which is incorrect instead of
\testdir\testfile_new which is correct. If I call the test function with
flag FALSE then the correct name is returned from FltGetFileNameInformation.
The FltObjects->FileObject->FsContext in all the IRP_MJ_CREATE and
IRP_MJ_SET_INFORMATION FileRenameInformation due to test function are all
observed to have the same value.
I’d be grateful if MSFT could confirm.
Cheers
Lyndon
VOID DoChuckle(WCHAR * filename, BOOL flag)
{
HANDLE hTransaction;
HANDLE hFile;
WCHAR filename_new[MAX_PATH];
wsprintf(filename_new, L"%s_new", filename);
DeleteFile(filename);
DeleteFile(filename_new);
fwprintf(stdout, L"filename: %s\n", filename);
fwprintf(stdout, L"filename_new: %s\n", filename_new);
fwprintf(stdout, L"CreateTransaction\n");
hTransaction = CreateTransaction(NULL, NULL, 0, 0, 0, 0, NULL);
if (hTransaction == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"CreateTransaction fails %d\n", dwError);
exit(1);
}
fwprintf(stdout, L"CreateFile [CREATE]\n");
hFile = CreateFile(filename,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"CreateFile fails %d\n", dwError);
(void) CloseHandle(hTransaction);
exit(1);
}
(void) CloseHandle(hFile);
fwprintf(stdout, L"MoveFileTransacted\n");
if (!MoveFileTransacted(filename, filename_new, NULL, NULL,
MOVEFILE_REPLACE_EXISTING, hTransaction))
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"MoveFileTransacted fails %d\n", dwError);
(void) CloseHandle(hTransaction);
exit(1);
}
if (flag)
{
fwprintf(stdout, L"CreateFile [OPEN, READ]\n");
hFile = CreateFile(filename,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"CreateFile fails %d\n", dwError);
}
(void) CloseHandle(hFile);
}
fwprintf(stdout, L"CommitTransaction\n");
if (!CommitTransaction(hTransaction))
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"CommitTransaction fails %d\n", dwError);
(void) CloseHandle(hTransaction);
exit(1);
}
fwprintf(stdout, L"CreateFile [OPEN, READ] NEW\n");
hFile = CreateFile(filename_new,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
fwprintf(stderr, L"CreateFile fails %d\n", dwError);
}
(void) CloseHandle(hFile);
(void) CloseHandle(hTransaction);
}