Import the NFS file system mini-redirector and the associated network provider.
Not all the pieces are in place to make it working.

CORE-8204

svn path=/trunk/; revision=75105
This commit is contained in:
Pierre Schweitzer 2017-06-18 20:49:46 +00:00
parent 1ee7db3ccc
commit 42e5eee699
17 changed files with 9366 additions and 0 deletions

View file

@ -5,6 +5,7 @@ add_subdirectory(cpl)
add_subdirectory(directx)
add_subdirectory(keyboard)
add_subdirectory(nls)
add_subdirectory(np)
add_subdirectory(ntdll)
add_subdirectory(opengl)
add_subdirectory(shellext)

View file

@ -0,0 +1 @@
add_subdirectory(nfs)

View file

@ -0,0 +1,17 @@
spec2def(nfs41_np.dll nfs41_np.spec ADD_IMPORTLIB)
list(APPEND SOURCE
dllmain.c
nfs41_np.c
nfs41_np.h
options.c
options.h)
include_directories(
${REACTOS_SOURCE_DIR}/drivers/filesystems/nfs)
add_library(nfs41_np SHARED ${SOURCE} nfsnp.rc ${CMAKE_CURRENT_BINARY_DIR}/nfs41_np.def)
set_module_type(nfs41_np win32dll UNICODE)
target_link_libraries(nfs41_np ${PSEH_LIB})
add_importlibs(nfs41_np msvcrt kernel32)
add_cd_file(TARGET nfs41_np DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,74 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
/*++
Copyright (c) 1989-1999 Microsoft Corporation
Module Name:
dllmain.c
Abstract:
This module implements the initialization routines for network
provider interface
Notes:
This module has been built and tested only in UNICODE environment
--*/
#include <windows.h>
#include <process.h>
// NOTE:
//
// Function:` DllMain
//
// Return: TRUE => Success
// FALSE => Failure
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL bStatus = TRUE;
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}
return(bStatus);
}

View file

@ -0,0 +1,910 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#include <windows.h>
#include <npapi.h>
#include <devioctl.h>
#include <strsafe.h>
#include "nfs41_driver.h"
#include "nfs41_np.h"
#include "options.h"
#ifdef DBG
#define DbgP(_x_) NFS41DbgPrint _x_
#else
#define DbgP(_x_)
#endif
#define TRACE_TAG L"[NFS41_NP]"
#define WNNC_DRIVER( major, minor ) ( major * 0x00010000 + minor )
ULONG _cdecl NFS41DbgPrint( __in LPTSTR Format, ... )
{
ULONG rc = 0;
TCHAR szbuffer[256];
va_list marker;
va_start( marker, Format );
{
//StringCchVPrintfW( szbuffer, 127, Format, marker );
StringCchVPrintfW( szbuffer, 256, Format, marker );
szbuffer[255] = (TCHAR)0;
OutputDebugString( TRACE_TAG );
OutputDebugString( szbuffer );
}
return rc;
}
int filter(unsigned int code)
{
DbgP((L"####Got exception %u\n", code));
return EXCEPTION_CONTINUE_SEARCH;
}
DWORD
OpenSharedMemory(
PHANDLE phMutex,
PHANDLE phMemory,
PVOID *pMemory)
/*++
Routine Description:
This routine opens the shared memory for exclusive manipulation
Arguments:
phMutex - the mutex handle
phMemory - the memory handle
pMemory - a ptr. to the shared memory which is set if successful
Return Value:
WN_SUCCESS -- if successful
--*/
{
DWORD dwStatus;
*phMutex = 0;
*phMemory = 0;
*pMemory = NULL;
*phMutex = CreateMutex(NULL, FALSE, TEXT(NFS41NP_MUTEX_NAME));
if (*phMutex == NULL)
{
dwStatus = GetLastError();
DbgP((TEXT("OpenSharedMemory: OpenMutex failed\n")));
goto OpenSharedMemoryAbort1;
}
WaitForSingleObject(*phMutex, INFINITE);
*phMemory = OpenFileMapping(FILE_MAP_WRITE,
FALSE,
TEXT(NFS41_USER_SHARED_MEMORY_NAME));
if (*phMemory == NULL)
{
dwStatus = GetLastError();
DbgP((TEXT("OpenSharedMemory: OpenFileMapping failed\n")));
goto OpenSharedMemoryAbort2;
}
*pMemory = MapViewOfFile(*phMemory, FILE_MAP_WRITE, 0, 0, 0);
if (*pMemory == NULL)
{
dwStatus = GetLastError();
DbgP((TEXT("OpenSharedMemory: MapViewOfFile failed\n")));
goto OpenSharedMemoryAbort3;
}
return ERROR_SUCCESS;
OpenSharedMemoryAbort3:
CloseHandle(*phMemory);
OpenSharedMemoryAbort2:
ReleaseMutex(*phMutex);
CloseHandle(*phMutex);
*phMutex = NULL;
OpenSharedMemoryAbort1:
DbgP((TEXT("OpenSharedMemory: return dwStatus: %d\n"), dwStatus));
return dwStatus;
}
VOID
CloseSharedMemory(
PHANDLE hMutex,
PHANDLE hMemory,
PVOID *pMemory)
/*++
Routine Description:
This routine relinquishes control of the shared memory after exclusive
manipulation
Arguments:
hMutex - the mutex handle
hMemory - the memory handle
pMemory - a ptr. to the shared memory which is set if successful
Return Value:
--*/
{
if (*pMemory)
{
UnmapViewOfFile(*pMemory);
*pMemory = NULL;
}
if (*hMemory)
{
CloseHandle(*hMemory);
*hMemory = 0;
}
if (*hMutex)
{
if (ReleaseMutex(*hMutex) == FALSE)
{
DbgP((TEXT("CloseSharedMemory: ReleaseMutex error: %d\n"), GetLastError()));
}
CloseHandle(*hMutex);
*hMutex = 0;
}
}
static DWORD StoreConnectionInfo(
IN LPCWSTR LocalName,
IN LPCWSTR ConnectionName,
IN USHORT ConnectionNameLength,
IN LPNETRESOURCE lpNetResource)
{
DWORD status;
HANDLE hMutex, hMemory;
PNFS41NP_SHARED_MEMORY pSharedMemory;
PNFS41NP_NETRESOURCE pNfs41NetResource;
INT Index;
BOOLEAN FreeEntryFound = FALSE;
#ifdef __REACTOS__
status = OpenSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
#else
status = OpenSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
#endif
if (status)
goto out;
DbgP((TEXT("StoreConnectionInfo: NextIndex %d, NumResources %d\n"),
pSharedMemory->NextAvailableIndex,
pSharedMemory->NumberOfResourcesInUse));
for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
{
if (!pSharedMemory->NetResources[Index].InUse)
{
FreeEntryFound = TRUE;
DbgP((TEXT("Reusing existing index %d\n"), Index));
break;
}
}
if (!FreeEntryFound)
{
if (pSharedMemory->NextAvailableIndex >= NFS41NP_MAX_DEVICES) {
status = WN_NO_MORE_DEVICES;
goto out_close;
}
Index = pSharedMemory->NextAvailableIndex++;
DbgP((TEXT("Using new index %d\n"), Index));
}
pSharedMemory->NumberOfResourcesInUse += 1;
pNfs41NetResource = &pSharedMemory->NetResources[Index];
pNfs41NetResource->InUse = TRUE;
pNfs41NetResource->dwScope = lpNetResource->dwScope;
pNfs41NetResource->dwType = lpNetResource->dwType;
pNfs41NetResource->dwDisplayType = lpNetResource->dwDisplayType;
pNfs41NetResource->dwUsage = RESOURCEUSAGE_CONNECTABLE;
pNfs41NetResource->LocalNameLength = (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
pNfs41NetResource->RemoteNameLength = (USHORT)(wcslen(lpNetResource->lpRemoteName) + 1) * sizeof(WCHAR);
pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
StringCchCopy(pNfs41NetResource->LocalName,
pNfs41NetResource->LocalNameLength,
LocalName);
StringCchCopy(pNfs41NetResource->RemoteName,
pNfs41NetResource->RemoteNameLength,
lpNetResource->lpRemoteName);
StringCchCopy(pNfs41NetResource->ConnectionName,
pNfs41NetResource->ConnectionNameLength,
ConnectionName);
// TODO: copy mount options -cbodley
out_close:
#ifdef __REACTOS__
CloseSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
#else
CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
#endif
out:
return status;
}
ULONG
SendTo_NFS41Driver(
IN ULONG IoctlCode,
IN PVOID InputDataBuf,
IN ULONG InputDataLen,
IN PVOID OutputDataBuf,
IN PULONG pOutputDataLen)
{
HANDLE DeviceHandle; // The mini rdr device handle
BOOL rc = FALSE;
ULONG Status;
Status = WN_SUCCESS;
DbgP((L"[aglo] calling CreateFile\n"));
DeviceHandle = CreateFile(
NFS41_USER_DEVICE_NAME,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
0,
(HANDLE) NULL );
DbgP((L"[aglo] after CreateFile Device Handle\n"));
if ( INVALID_HANDLE_VALUE != DeviceHandle )
{
_SEH2_TRY {
DbgP((L"[aglo] calling DeviceIoControl\n"));
rc = DeviceIoControl(
DeviceHandle,
IoctlCode,
InputDataBuf,
InputDataLen,
OutputDataBuf,
*pOutputDataLen,
pOutputDataLen,
NULL );
} _SEH2_EXCEPT(_SEH2_GetExceptionCode()) {
DbgP((L"#### In except\n"));
} _SEH2_END;
DbgP((L"[aglo] returned from DeviceIoControl %08lx\n", rc));
if ( !rc )
{
DbgP((L"[aglo] SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
Status = GetLastError( );
}
else
{
DbgP((L"[aglo] SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
}
CloseHandle(DeviceHandle);
}
else
{
Status = GetLastError( );
DbgP((L"[aglo] SendTo_NFS41Driver: error %08lx opening device \n", Status));
}
DbgP((L"[aglo] returned from SendTo_NFS41Driver %08lx\n", Status));
return Status;
}
DWORD APIENTRY
NPGetCaps(
DWORD nIndex )
{
DWORD rc = 0;
DbgP(( L"[aglo] GetNetCaps %d\n", nIndex ));
switch ( nIndex )
{
case WNNC_SPEC_VERSION:
rc = WNNC_SPEC_VERSION51;
break;
case WNNC_NET_TYPE:
rc = WNNC_NET_RDR2SAMPLE;
break;
case WNNC_DRIVER_VERSION:
rc = WNNC_DRIVER(1, 0);
break;
case WNNC_CONNECTION:
rc = WNNC_CON_GETCONNECTIONS |
WNNC_CON_CANCELCONNECTION |
WNNC_CON_ADDCONNECTION |
WNNC_CON_ADDCONNECTION3;
break;
case WNNC_ENUMERATION:
rc = WNNC_ENUM_LOCAL;
break;
case WNNC_START:
rc = 1;
break;
case WNNC_USER:
case WNNC_DIALOG:
case WNNC_ADMIN:
default:
rc = 0;
break;
}
return rc;
}
DWORD APIENTRY
NPLogonNotify(
__in PLUID lpLogonId,
__in PCWSTR lpAuthentInfoType,
__in PVOID lpAuthentInfo,
__in PCWSTR lpPreviousAuthentInfoType,
__in PVOID lpPreviousAuthentInfo,
__in PWSTR lpStationName,
__in PVOID StationHandle,
__out PWSTR *lpLogonScript)
{
*lpLogonScript = NULL;
DbgP(( L"[aglo] NPLogonNotify: returning WN_SUCCESS\n" ));
return WN_SUCCESS;
}
DWORD APIENTRY
NPPasswordChangeNotify (
__in LPCWSTR lpAuthentInfoType,
__in LPVOID lpAuthentInfo,
__in LPCWSTR lpPreviousAuthentInfoType,
__in LPVOID lpPreviousAuthentInfo,
__in LPWSTR lpStationName,
LPVOID StationHandle,
DWORD dwChangeInfo )
{
DbgP(( L"[aglo] NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
SetLastError( WN_NOT_SUPPORTED );
return WN_NOT_SUPPORTED;
}
#ifdef __REACTOS__
DWORD APIENTRY
NPAddConnection3(
__in HWND hwndOwner,
__in LPNETRESOURCE lpNetResource,
__in_opt LPWSTR lpPassword,
__in_opt LPWSTR lpUserName,
__in DWORD dwFlags);
#endif
DWORD APIENTRY
NPAddConnection(
__in LPNETRESOURCE lpNetResource,
__in_opt LPWSTR lpPassword,
__in_opt LPWSTR lpUserName )
{
return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
}
DWORD APIENTRY
NPAddConnection3(
__in HWND hwndOwner,
__in LPNETRESOURCE lpNetResource,
__in_opt LPWSTR lpPassword,
__in_opt LPWSTR lpUserName,
__in DWORD dwFlags)
{
DWORD Status;
WCHAR wszScratch[128];
WCHAR LocalName[3];
DWORD CopyBytes = 0;
CONNECTION_INFO Connection;
LPWSTR ConnectionName;
WCHAR ServerName[MAX_PATH];
PWCHAR p;
DWORD i;
DbgP(( L"[aglo] NPAddConnection3('%s', '%s')\n",
lpNetResource->lpLocalName, lpNetResource->lpRemoteName ));
DbgP(( L"[aglo] username = '%s', passwd = '%s'\n", lpUserName, lpPassword));
Status = InitializeConnectionInfo(&Connection,
(PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
&ConnectionName);
if (Status) {
DbgP(( L"InitializeConnectionInfo failed with %d\n", Status ));
goto out;
}
// \device\miniredirector\;<DriveLetter>:\Server\Share
// local name, must start with "X:"
if (lstrlen(lpNetResource->lpLocalName) < 2 ||
lpNetResource->lpLocalName[1] != L':') {
Status = WN_BAD_LOCALNAME;
goto out;
}
LocalName[0] = (WCHAR) toupper(lpNetResource->lpLocalName[0]);
LocalName[1] = L':';
LocalName[2] = L'\0';
StringCchCopyW( ConnectionName, MAX_PATH, NFS41_DEVICE_NAME );
StringCchCatW( ConnectionName, MAX_PATH, L"\\;" );
StringCchCatW( ConnectionName, MAX_PATH, LocalName );
// remote name, must start with "\\"
if (lpNetResource->lpRemoteName[0] == L'\0' ||
lpNetResource->lpRemoteName[0] != L'\\' ||
lpNetResource->lpRemoteName[1] != L'\\') {
Status = WN_BAD_NETNAME;
goto out;
}
/* note: remotename comes as \\server but we need to add \server thus +1 pointer */
p = lpNetResource->lpRemoteName + 1;
ServerName[0] = L'\\';
i = 1;
for(;;) {
/* convert servername ending unix slash to windows slash */
if (p[i] == L'/')
p[i] = L'\\';
/* deal with servername ending with any slash */
if (p[i] == L'\0')
p[i] = L'\\';
ServerName[i] = p[i];
if (p[i] == L'\\') break;
i++;
}
ServerName[i] = L'\0';
StringCchCatW( ConnectionName, MAX_PATH, ServerName);
/* insert the "nfs4" in between the server name and the path,
* just to make sure all calls to our driver come thru this */
StringCchCatW( ConnectionName, MAX_PATH, L"\\nfs4" );
#ifdef CONVERT_2_UNIX_SLASHES
/* convert all windows slashes to unix slashes */
{
PWCHAR q = p;
DWORD j = 0;
for(;;) {
if(q[j] == L'\0') break;
if (q[j] == L'\\') q[j] = L'/';
j++;
}
}
#else
/* convert all unix slashes to windows slashes */
{
PWCHAR q = p;
DWORD j = 0;
for(;;) {
if(q[j] == L'\0') break;
if (q[j] == L'/') q[j] = L'\\';
j++;
}
}
#endif
StringCchCatW( ConnectionName, MAX_PATH, &p[i]);
DbgP(( L"[aglo] Full Connect Name: %s\n", ConnectionName ));
DbgP(( L"[aglo] Full Connect Name Length: %d %d\n",
(wcslen(ConnectionName) + 1) * sizeof(WCHAR),
(lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
if ( QueryDosDevice( LocalName, wszScratch, 128 )
|| GetLastError() != ERROR_FILE_NOT_FOUND) {
Status = WN_ALREADY_CONNECTED;
goto out;
}
MarshalConnectionInfo(&Connection);
Status = SendTo_NFS41Driver( IOCTL_NFS41_ADDCONN,
Connection.Buffer, Connection.BufferSize,
NULL, &CopyBytes );
if (Status) {
DbgP(( L"[aglo] SendTo_NFS41Driver failed with %d\n", Status));
goto out;
}
DbgP(( L"[aglo] calling DefineDosDevice\n"));
if ( !DefineDosDevice( DDD_RAW_TARGET_PATH |
DDD_NO_BROADCAST_SYSTEM,
lpNetResource->lpLocalName,
ConnectionName ) ) {
Status = GetLastError();
DbgP(( L"[aglo] DefineDosDevice failed with %d\n", Status));
goto out_delconn;
}
// The connection was established and the local device mapping
// added. Include this in the list of mapped devices.
Status = StoreConnectionInfo(LocalName, ConnectionName,
Connection.Buffer->NameLength, lpNetResource);
if (Status) {
DbgP(( L"[aglo] StoreConnectionInfo failed with %d\n", Status));
goto out_undefine;
}
out:
FreeConnectionInfo(&Connection);
DbgP(( L"[aglo] NPAddConnection3: status %08X\n", Status));
return Status;
out_undefine:
DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_RAW_TARGET_PATH |
DDD_EXACT_MATCH_ON_REMOVE, LocalName, ConnectionName);
out_delconn:
SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
Connection.Buffer->NameLength, NULL, &CopyBytes);
goto out;
}
DWORD APIENTRY
NPCancelConnection(
__in LPWSTR lpName,
__in BOOL fForce )
{
DWORD Status = 0;
HANDLE hMutex, hMemory;
PNFS41NP_SHARED_MEMORY pSharedMemory;
DbgP((TEXT("NPCancelConnection\n")));
DbgP((TEXT("NPCancelConnection: ConnectionName: %S\n"), lpName));
Status = OpenSharedMemory( &hMutex,
&hMemory,
(PVOID)&pSharedMemory);
if (Status == WN_SUCCESS)
{
INT Index;
PNFS41NP_NETRESOURCE pNetResource;
Status = WN_NOT_CONNECTED;
DbgP((TEXT("NPCancelConnection: NextIndex %d, NumResources %d\n"),
pSharedMemory->NextAvailableIndex,
pSharedMemory->NumberOfResourcesInUse));
for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
{
pNetResource = &pSharedMemory->NetResources[Index];
if (pNetResource->InUse)
{
if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
pNetResource->LocalNameLength)
&& ( !wcscmp(lpName, pNetResource->LocalName) ))
{
ULONG CopyBytes;
DbgP((TEXT("NPCancelConnection: Connection Found:\n")));
CopyBytes = 0;
Status = SendTo_NFS41Driver( IOCTL_NFS41_DELCONN,
pNetResource->ConnectionName,
pNetResource->ConnectionNameLength,
NULL,
&CopyBytes );
if (Status != WN_SUCCESS)
{
DbgP((TEXT("NPCancelConnection: SendToMiniRdr returned Status %lx\n"),Status));
break;
}
if (DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
lpName,
pNetResource->ConnectionName) == FALSE)
{
DbgP((TEXT("RemoveDosDevice: DefineDosDevice error: %d\n"), GetLastError()));
Status = GetLastError();
}
else
{
pNetResource->InUse = FALSE;
pSharedMemory->NumberOfResourcesInUse--;
if (Index+1 == pSharedMemory->NextAvailableIndex)
pSharedMemory->NextAvailableIndex--;
}
break;
}
DbgP((TEXT("NPCancelConnection: Name %S EntryName %S\n"),
lpName,pNetResource->LocalName));
DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
pNetResource->LocalNameLength,pNetResource->LocalName));
}
}
CloseSharedMemory( &hMutex,
&hMemory,
(PVOID)&pSharedMemory);
}
return Status;
}
DWORD APIENTRY
NPGetConnection(
__in LPWSTR lpLocalName,
__out_bcount(*lpBufferSize) LPWSTR lpRemoteName,
__inout LPDWORD lpBufferSize )
{
DWORD Status = 0;
HANDLE hMutex, hMemory;
PNFS41NP_SHARED_MEMORY pSharedMemory;
Status = OpenSharedMemory( &hMutex,
&hMemory,
(PVOID)&pSharedMemory);
if (Status == WN_SUCCESS)
{
INT Index;
PNFS41NP_NETRESOURCE pNetResource;
Status = WN_NOT_CONNECTED;
for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
{
pNetResource = &pSharedMemory->NetResources[Index];
if (pNetResource->InUse)
{
if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
pNetResource->LocalNameLength)
&& ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
{
if (*lpBufferSize < pNetResource->RemoteNameLength)
{
*lpBufferSize = pNetResource->RemoteNameLength;
Status = WN_MORE_DATA;
}
else
{
*lpBufferSize = pNetResource->RemoteNameLength;
CopyMemory( lpRemoteName,
pNetResource->RemoteName,
pNetResource->RemoteNameLength);
Status = WN_SUCCESS;
}
break;
}
}
}
CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
}
return Status;
}
DWORD APIENTRY
NPOpenEnum(
DWORD dwScope,
DWORD dwType,
DWORD dwUsage,
LPNETRESOURCE lpNetResource,
LPHANDLE lphEnum )
{
DWORD Status;
DbgP((L"[aglo] NPOpenEnum\n"));
*lphEnum = NULL;
switch ( dwScope )
{
case RESOURCE_CONNECTED:
{
*lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( ULONG ) );
if (*lphEnum )
{
Status = WN_SUCCESS;
}
else
{
Status = WN_OUT_OF_MEMORY;
}
break;
}
break;
case RESOURCE_CONTEXT:
default:
Status = WN_NOT_SUPPORTED;
break;
}
DbgP((L"[aglo] NPOpenEnum returning Status %lx\n",Status));
return(Status);
}
DWORD APIENTRY
NPEnumResource(
HANDLE hEnum,
LPDWORD lpcCount,
LPVOID lpBuffer,
LPDWORD lpBufferSize)
{
DWORD Status = WN_SUCCESS;
ULONG EntriesCopied;
LPNETRESOURCE pNetResource;
ULONG SpaceNeeded = 0;
ULONG SpaceAvailable;
PWCHAR StringZone;
HANDLE hMutex, hMemory;
PNFS41NP_SHARED_MEMORY pSharedMemory;
PNFS41NP_NETRESOURCE pNfsNetResource;
INT Index = *(PULONG)hEnum;
DbgP((L"[aglo] NPEnumResource\n"));
DbgP((L"[aglo] NPEnumResource Count Requested %d\n", *lpcCount));
pNetResource = (LPNETRESOURCE) lpBuffer;
SpaceAvailable = *lpBufferSize;
EntriesCopied = 0;
StringZone = (PWCHAR) ((PBYTE)lpBuffer + *lpBufferSize);
Status = OpenSharedMemory( &hMutex,
&hMemory,
(PVOID)&pSharedMemory);
if ( Status == WN_SUCCESS)
{
Status = WN_NO_MORE_ENTRIES;
for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
Index < pSharedMemory->NextAvailableIndex; Index++)
{
pNfsNetResource = &pSharedMemory->NetResources[Index];
if (pNfsNetResource->InUse)
{
SpaceNeeded = sizeof( NETRESOURCE );
SpaceNeeded += pNfsNetResource->LocalNameLength;
SpaceNeeded += pNfsNetResource->RemoteNameLength;
SpaceNeeded += 5 * sizeof(WCHAR); // comment
SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U); // provider name
if ( SpaceNeeded > SpaceAvailable )
{
Status = WN_MORE_DATA;
DbgP((L"[aglo] NPEnumResource More Data Needed - %d\n", SpaceNeeded));
*lpBufferSize = SpaceNeeded;
break;
}
else
{
SpaceAvailable -= SpaceNeeded;
pNetResource->dwScope = pNfsNetResource->dwScope;
pNetResource->dwType = pNfsNetResource->dwType;
pNetResource->dwDisplayType = pNfsNetResource->dwDisplayType;
pNetResource->dwUsage = pNfsNetResource->dwUsage;
// setup string area at opposite end of buffer
SpaceNeeded -= sizeof( NETRESOURCE );
StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
// copy local name
StringCchCopy( StringZone,
pNfsNetResource->LocalNameLength,
pNfsNetResource->LocalName );
pNetResource->lpLocalName = StringZone;
StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
// copy remote name
StringCchCopy( StringZone,
pNfsNetResource->RemoteNameLength,
pNfsNetResource->RemoteName );
pNetResource->lpRemoteName = StringZone;
StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
// copy comment
pNetResource->lpComment = StringZone;
*StringZone++ = L'A';
*StringZone++ = L'_';
*StringZone++ = L'O';
*StringZone++ = L'K';
*StringZone++ = L'\0';
// copy provider name
pNetResource->lpProvider = StringZone;
StringCbCopyW( StringZone, sizeof(NFS41_PROVIDER_NAME_U), NFS41_PROVIDER_NAME_U );
StringZone += sizeof(NFS41_PROVIDER_NAME_U)/sizeof(WCHAR);
EntriesCopied++;
// set new bottom of string zone
StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
Status = WN_SUCCESS;
}
pNetResource++;
}
}
CloseSharedMemory( &hMutex, &hMemory, (PVOID*)&pSharedMemory);
}
*lpcCount = EntriesCopied;
*(PULONG) hEnum = Index;
DbgP((L"[aglo] NPEnumResource entries returned: %d\n", EntriesCopied));
return Status;
}
DWORD APIENTRY
NPCloseEnum(
HANDLE hEnum )
{
DbgP((L"[aglo] NPCloseEnum\n"));
HeapFree( GetProcessHeap( ), 0, (PVOID) hEnum );
return WN_SUCCESS;
}
DWORD APIENTRY
NPGetResourceParent(
LPNETRESOURCE lpNetResource,
LPVOID lpBuffer,
LPDWORD lpBufferSize )
{
DbgP(( L"[aglo] NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
return WN_NOT_SUPPORTED;
}
DWORD APIENTRY
NPGetResourceInformation(
__in LPNETRESOURCE lpNetResource,
__out_bcount(*lpBufferSize) LPVOID lpBuffer,
__inout LPDWORD lpBufferSize,
__deref_out LPWSTR *lplpSystem )
{
DbgP(( L"[aglo] NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
return WN_NOT_SUPPORTED;
}
DWORD APIENTRY
NPGetUniversalName(
LPCWSTR lpLocalPath,
DWORD dwInfoLevel,
LPVOID lpBuffer,
LPDWORD lpBufferSize )
{
DbgP(( L"[aglo] NPGetUniversalName: WN_NOT_SUPPORTED\n" ));
return WN_NOT_SUPPORTED;
}

View file

@ -0,0 +1,50 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#ifndef __NFS41_NP_H__
#define __NFS41_NP_H__
#define NFS41NP_MUTEX_NAME "NFS41NPMUTEX"
#define NFS41NP_MAX_DEVICES 26
typedef struct __NFS41NP_NETRESOURCE {
BOOL InUse;
USHORT LocalNameLength;
USHORT RemoteNameLength;
USHORT ConnectionNameLength;
DWORD dwScope;
DWORD dwType;
DWORD dwDisplayType;
DWORD dwUsage;
WCHAR LocalName[MAX_PATH];
WCHAR RemoteName[MAX_PATH];
WCHAR ConnectionName[MAX_PATH];
WCHAR Options[MAX_PATH];
} NFS41NP_NETRESOURCE, *PNFS41NP_NETRESOURCE;
typedef struct __NFS41NP_SHARED_MEMORY {
INT NextAvailableIndex;
INT NumberOfResourcesInUse;
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES];
} NFS41NP_SHARED_MEMORY, *PNFS41NP_SHARED_MEMORY;
#endif /* !__NFS41_NP_H__ */

View file

@ -0,0 +1,13 @@
@ stdcall NPGetCaps(long)
@ stdcall NPLogonNotify(ptr wstr ptr wstr ptr wstr ptr wstr)
@ stdcall NPPasswordChangeNotify(wstr ptr wstr ptr wstr ptr long)
@ stdcall NPAddConnection(ptr wstr wstr)
@ stdcall NPAddConnection3(long ptr wstr wstr long)
@ stdcall NPCancelConnection(wstr long)
@ stdcall NPGetConnection(wstr ptr ptr)
@ stdcall NPOpenEnum(long long long ptr ptr)
@ stdcall NPEnumResource(long ptr ptr ptr)
@ stdcall NPCloseEnum(long)
@ stdcall NPGetResourceParent(ptr ptr ptr)
@ stdcall NPGetResourceInformation(ptr ptr ptr ptr)
@ stdcall NPGetUniversalName(ptr long ptr ptr)

View file

@ -0,0 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "NFS Network Provider"
#define REACTOS_STR_INTERNAL_NAME "nfsnp"
#define REACTOS_STR_ORIGINAL_FILENAME "nfsnp.dll"
#include <reactos/version.rc>

View file

@ -0,0 +1,102 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#include <windows.h>
#include "options.h"
DWORD InitializeConnectionInfo(
IN OUT PCONNECTION_INFO Connection,
IN PMOUNT_OPTION_BUFFER Options,
OUT LPWSTR *ConnectionName)
{
DWORD result = WN_SUCCESS;
SIZE_T size;
/* verify that this is a mount options buffer */
if (Options &&
Options->Zero == 0 &&
Options->Secret == MOUNT_OPTION_BUFFER_SECRET)
{
Connection->Options = Options;
size = MAX_CONNECTION_BUFFER_SIZE(Options->Length);
}
else
{
Connection->Options = NULL;
size = MAX_CONNECTION_BUFFER_SIZE(0);
}
Connection->Buffer = LocalAlloc(LMEM_ZEROINIT, size);
if (Connection->Buffer)
*ConnectionName = (LPWSTR)Connection->Buffer->Buffer;
else
result = WN_OUT_OF_MEMORY;
return result;
}
#ifdef __REACTOS__
FORCEINLINE SIZE_T ConnectionBufferSize(
#else
static FORCEINLINE SIZE_T ConnectionBufferSize(
#endif
IN PCONNECTION_BUFFER Buffer)
{
return sizeof(USHORT) + sizeof(USHORT) + sizeof(ULONG) +
Buffer->NameLength + Buffer->EaPadding + Buffer->EaLength;
}
void MarshalConnectionInfo(
IN OUT PCONNECTION_INFO Connection)
{
PCONNECTION_BUFFER Buffer = Connection->Buffer;
LPWSTR ConnectionName = (LPWSTR)Buffer->Buffer;
Buffer->NameLength = (USHORT)(wcslen(ConnectionName) + 1) * sizeof(WCHAR);
/* copy the EaBuffer after the end of ConnectionName */
if (Connection->Options && Connection->Options->Length)
{
PBYTE ptr = Buffer->Buffer + Buffer->NameLength;
/* add padding so EaBuffer starts on a ULONG boundary */
Buffer->EaPadding = (USHORT)
(sizeof(ULONG) - (SIZE_T)ptr % sizeof(ULONG)) % sizeof(ULONG);
Buffer->EaLength = Connection->Options->Length;
ptr += Buffer->EaPadding;
RtlCopyMemory(ptr, Connection->Options->Buffer, Buffer->EaLength);
}
Connection->BufferSize = (ULONG)ConnectionBufferSize(Buffer);
}
void FreeConnectionInfo(
IN PCONNECTION_INFO Connection)
{
if (Connection->Buffer)
{
LocalFree(Connection->Buffer);
Connection->Buffer = NULL;
}
Connection->Options = NULL;
Connection->BufferSize = 0;
}

View file

@ -0,0 +1,82 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#ifndef __NFS41_NP_OPTIONS_H__
#define __NFS41_NP_OPTIONS_H__
#define MOUNT_OPTION_BUFFER_SECRET ('n4')
/* MOUNT_OPTION_BUFFER
* The mount options buffer received by NPAddConnection3
* via NETRESOURCE.lpComment. To avoid interpreting a normal
* comment string as mount options, a NULL and secret number
* are expected at the front. */
typedef struct _MOUNT_OPTION_BUFFER {
USHORT Zero; /* = 0 */
USHORT Secret; /* = 'n4' */
ULONG Length;
BYTE Buffer[1];
} MOUNT_OPTION_BUFFER, *PMOUNT_OPTION_BUFFER;
/* CONNECTION_BUFFER
* The connection information as sent to the driver via
* IOCTL_NFS41_ADDCONN. The buffer contains the connection name
* followed by any extended attributes for mount options. */
typedef struct _CONNECTION_BUFFER {
USHORT NameLength; /* length of connection filename */
USHORT EaPadding; /* 0-3 bytes of padding to put EaBuffer
* on a ULONG boundary */
ULONG EaLength; /* length of EaBuffer */
BYTE Buffer[1];
} CONNECTION_BUFFER, *PCONNECTION_BUFFER;
/* CONNECTION_INFO
* Used in NPAddConnection3 to encapsulate the formation of
* the connection buffer. */
typedef struct _CONNECTION_INFO {
PMOUNT_OPTION_BUFFER Options;
ULONG BufferSize;
PCONNECTION_BUFFER Buffer;
} CONNECTION_INFO, *PCONNECTION_INFO;
#define MAX_CONNECTION_BUFFER_SIZE(EaSize) ( \
sizeof(CONNECTION_BUFFER) + MAX_PATH + (EaSize) )
/* options.c */
DWORD InitializeConnectionInfo(
IN OUT PCONNECTION_INFO Connection,
IN PMOUNT_OPTION_BUFFER Options,
OUT LPWSTR *ConnectionName);
void FreeConnectionInfo(
IN OUT PCONNECTION_INFO Connection);
/* MarshallConnectionInfo
* Prepares the CONNECTION_BUFFER for transmission to the driver
* by copying the extended attributes into place and updating the
* lengths accordingly. */
void MarshalConnectionInfo(
IN OUT PCONNECTION_INFO Connection);
#endif /* !__NFS41_NP_OPTIONS_H__ */

View file

@ -8,6 +8,7 @@ add_subdirectory(ffs)
add_subdirectory(fs_rec)
add_subdirectory(msfs)
add_subdirectory(mup)
add_subdirectory(nfs)
add_subdirectory(npfs)
add_subdirectory(ntfs)
add_subdirectory(reiserfs)

View file

@ -0,0 +1,21 @@
list(APPEND SOURCE
nfs41_driver.c
nfs41_debug.c
nfs41_driver.h
nfs41_debug.h)
include_directories(
${REACTOS_SOURCE_DIR}/dll/np/nfs)
add_definitions(-DRDBSS_TRACKER)
add_library(nfs41_driver SHARED ${SOURCE} nfs.rc)
set_module_type(nfs41_driver kernelmodedriver)
target_link_libraries(nfs41_driver ntoskrnl_vista rdbsslib ${PSEH_LIB})
add_importlibs(nfs41_driver ntoskrnl hal)
if((NOT MSVC) AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
add_target_compile_flags(nfs41_driver "-Wno-switch")
endif()
add_cd_file(TARGET nfs41_driver DESTINATION reactos/system32/drivers FOR all)

View file

@ -0,0 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "NFS Driver"
#define REACTOS_STR_INTERNAL_NAME "nfs"
#define REACTOS_STR_ORIGINAL_FILENAME "nfs.sys"
#include <reactos/version.rc>

View file

@ -0,0 +1,749 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#define MINIRDR__NAME "Value is ignored, only fact of definition"
#include <rx.h>
#include "nfs41_driver.h"
#include "nfs41_debug.h"
#include <stdio.h>
#include <stdarg.h>
#include <ntstrsafe.h>
#include <winerror.h>
#if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7)
NTSTATUS NTAPI RtlUnicodeToUTF8N(CHAR *utf8_dest, ULONG utf8_bytes_max,
ULONG *utf8_bytes_written,
const WCHAR *uni_src, ULONG uni_bytes);
NTSTATUS NTAPI RtlUTF8ToUnicodeN(WCHAR *uni_dest, ULONG uni_bytes_max,
ULONG *uni_bytes_written,
const CHAR *utf8_src, ULONG utf8_bytes);
#endif /* defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7) */
//#define INCLUDE_TIMESTAMPS
ULONG __cdecl DbgP(IN PCCH fmt, ...)
{
CHAR msg[512];
va_list args;
NTSTATUS status;
va_start(args, fmt);
ASSERT(fmt != NULL);
status = RtlStringCbVPrintfA(msg, sizeof(msg), fmt, args);
if (NT_SUCCESS(status)) {
#ifdef INCLUDE_TIMESTAMPS
LARGE_INTEGER timestamp, local_time;
TIME_FIELDS time_fields;
KeQuerySystemTime(&timestamp);
ExSystemTimeToLocalTime(&timestamp,&local_time);
RtlTimeToTimeFields(&local_time, &time_fields);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld].[%02u:%02u:%02u.%u] %s", IoGetCurrentProcess(),
time_fields.Hour, time_fields.Minute, time_fields.Second,
time_fields.Milliseconds, msg);
#else
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%04x] %s", PsGetCurrentProcessId(), msg);
#endif
}
va_end(args);
return 0;
}
ULONG __cdecl print_error(IN PCCH fmt, ...)
{
CHAR msg[512];
va_list args;
NTSTATUS status;
va_start(args, fmt);
ASSERT(fmt != NULL);
status = RtlStringCbVPrintfA(msg, sizeof(msg), fmt, args);
if (NT_SUCCESS(status)) {
#ifdef INCLUDE_TIMESTAMPS
LARGE_INTEGER timestamp, local_time;
TIME_FIELDS time_fields;
KeQuerySystemTime(&timestamp);
ExSystemTimeToLocalTime(&timestamp,&local_time);
RtlTimeToTimeFields(&local_time, &time_fields);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld].[%02u:%02u:%02u.%u] %s", IoGetCurrentProcess(),
time_fields.Hour, time_fields.Minute, time_fields.Second,
time_fields.Milliseconds, msg);
#else
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%04x] %s", PsGetCurrentProcessId(), msg);
#endif
}
va_end(args);
return 0;
}
void print_hexbuf(int on, unsigned char *title, unsigned char *buf, int len)
{
int j, k;
LARGE_INTEGER timestamp, local_time;
TIME_FIELDS time_fields;
if (!on) return;
KeQuerySystemTime(&timestamp);
ExSystemTimeToLocalTime(&timestamp,&local_time);
RtlTimeToTimeFields(&local_time, &time_fields);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld].[%02u:%02u:%02u.%u] %s\n", IoGetCurrentProcess(),
time_fields.Hour, time_fields.Minute, time_fields.Second,
time_fields.Milliseconds, title);
for(j = 0, k = 0; j < len; j++, k++) {
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"%02x ", buf[j]);
if (((k+1) % 30 == 0 && k > 0))
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "\n");
}
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "\n");
}
void print_ioctl(int on, int op)
{
if(!on) return;
switch(op) {
case IRP_MJ_FILE_SYSTEM_CONTROL:
DbgP("IRP_MJ_FILE_SYSTEM_CONTROL\n");
break;
case IRP_MJ_DEVICE_CONTROL:
DbgP("IRP_MJ_DEVICE_CONTROL\n");
break;
case IRP_MJ_INTERNAL_DEVICE_CONTROL:
DbgP("IRP_MJ_INTERNAL_DEVICE_CONTROL\n");
break;
default:
DbgP("UNKNOWN MJ IRP %d\n", op);
};
}
void print_fs_ioctl(int on, int op)
{
if(!on) return;
switch(op) {
case IOCTL_NFS41_INVALCACHE:
DbgP("IOCTL_NFS41_INVALCACHE\n");
break;
case IOCTL_NFS41_READ:
DbgP("IOCTL_NFS41_UPCALL\n");
break;
case IOCTL_NFS41_WRITE:
DbgP("IOCTL_NFS41_DOWNCALL\n");
break;
case IOCTL_NFS41_ADDCONN:
DbgP("IOCTL_NFS41_ADDCONN\n");
break;
case IOCTL_NFS41_DELCONN:
DbgP("IOCTL_NFS41_DELCONN\n");
break;
case IOCTL_NFS41_GETSTATE:
DbgP("IOCTL_NFS41_GETSTATE\n");
break;
case IOCTL_NFS41_START:
DbgP("IOCTL_NFS41_START\n");
break;
case IOCTL_NFS41_STOP:
DbgP("IOCTL_NFS41_STOP\n");
break;
default:
DbgP("UNKNOWN FS IOCTL %d\n", op);
};
}
void print_driver_state(int state)
{
switch (state) {
case NFS41_START_DRIVER_STARTABLE:
DbgP("NFS41_START_DRIVER_STARTABLE\n");
break;
case NFS41_START_DRIVER_STOPPED:
DbgP("NFS41_START_DRIVER_STOPPED\n");
break;
case NFS41_START_DRIVER_START_IN_PROGRESS:
DbgP("NFS41_START_DRIVER_START_IN_PROGRESS\n");
break;
case NFS41_START_DRIVER_STARTED:
DbgP("NFS41_START_DRIVER_STARTED\n");
break;
default:
DbgP("UNKNOWN DRIVER STATE %d\n", state);
};
}
void print_basic_info(int on, PFILE_BASIC_INFORMATION info)
{
if (!on) return;
DbgP("BASIC_INFO: Create=%lx Access=%lx Write=%lx Change=%lx Attr=%x\n",
info->CreationTime.QuadPart, info->LastAccessTime.QuadPart,
info->LastWriteTime.QuadPart, info->ChangeTime.QuadPart,
info->FileAttributes);
}
void print_std_info(int on, PFILE_STANDARD_INFORMATION info)
{
if (!on) return;
DbgP("STD_INFO: Type=%s #Links=%d Alloc=%lx EOF=%lx Delete=%d\n",
info->Directory?"DIR":"FILE", info->NumberOfLinks,
info->AllocationSize.QuadPart, info->EndOfFile.QuadPart,
info->DeletePending);
}
void print_ea_info(int on, PFILE_FULL_EA_INFORMATION info)
{
if (!on) return;
DbgP("FULL_EA_INFO: NextOffset=%d Flags=%x EaNameLength=%d "
"ExValueLength=%x EaName=%s\n", info->NextEntryOffset, info->Flags,
info->EaNameLength, info->EaValueLength, info->EaName);
if (info->EaValueLength)
print_hexbuf(0, (unsigned char *)"eavalue",
(unsigned char *)info->EaName + info->EaNameLength + 1,
info->EaValueLength);
}
void print_get_ea(int on, PFILE_GET_EA_INFORMATION info)
{
if (!on || !info) return;
DbgP("GET_EA_INFO: NextOffset=%d EaNameLength=%d EaName=%s\n",
info->NextEntryOffset, info->EaNameLength, info->EaName);
}
VOID print_srv_call(int on, IN PMRX_SRV_CALL p)
{
if (!on) return;
DbgP("PMRX_SRV_CALL %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("pSrvCallName %wZ\n", p->pSrvCallName);
//DbgP("pPrincipalName %wZ\n", p->pPrincipalName);
//DbgP("PDomainName %wZ\n", p->pDomainName);
//DbgP("Flags %08lx\n", p->Flags);
//DbgP("MaximumNumberOfCloseDelayedFiles %ld\n", p->MaximumNumberOfCloseDelayedFiles);
//DbgP("Status %ld\n", p->Status);
DbgP("*****************\n");
#endif
}
VOID print_net_root(int on, IN PMRX_NET_ROOT p)
{
if (!on) return;
DbgP("PMRX_NET_ROOT %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpSrvCall %p\n", p->pSrvCall);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("\tNumberOfFcbs %ld\n", p->NumberOfFcbs);
DbgP("\tNumberofSrvOpens %ld\n", p->NumberOfSrvOpens);
//DbgP("MRxNetRootState %ld\n", p->MRxNetRootState);
//DbgP("Type %ld\n", p->Type);
//DbgP("DeviceType %ld\n", p->DeviceType);
//DbgP("pNetRootName %wZ\n", p->pNetRootName);
//DbgP("InnerNamePrefix %wZ\n", &p->InnerNamePrefix);
DbgP("*****************\n");
#endif
}
VOID print_v_net_root(int on, IN PMRX_V_NET_ROOT p)
{
if (!on) return;
DbgP("PMRX_V_NET_ROOT %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpNetRoot %p\n", p->pNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("\tNumberofOpens %ld\n", p->NumberOfOpens);
DbgP("\tNumberofFobxs %ld\n", p->NumberOfFobxs);
//DbgP("LogonId\n");
//DbgP("pUserDomainName %wZ\n", p->pUserDomainName);
//DbgP("pUserName %wZ\n", p->pUserName);
//DbgP("pPassword %wZ\n", p->pPassword);
//DbgP("SessionId %ld\n", p->SessionId);
//DbgP("ConstructionStatus %08lx\n", p->ConstructionStatus);
//DbgP("IsExplicitConnection %d\n", p->IsExplicitConnection);
DbgP("*****************\n");
#endif
}
void print_file_object(int on, PFILE_OBJECT file)
{
if (!on) return;
DbgP("FsContext %p FsContext2 %p\n", file->FsContext, file->FsContext2);
DbgP("DeletePending %d ReadAccess %d WriteAccess %d DeleteAccess %d\n",
file->DeletePending, file->WriteAccess, file->DeleteAccess);
DbgP("SharedRead %d SharedWrite %d SharedDelete %d Flags %x\n",
file->SharedRead, file->SharedWrite, file->SharedDelete, file->Flags);
}
void print_fo_all(int on, PRX_CONTEXT c)
{
if (!on) return;
if (c->pFcb && c->pRelevantSrvOpen)
DbgP("OpenCount %d FCB %p SRV %p FOBX %p VNET %p NET %p\n",
c->pFcb->OpenCount, c->pFcb, c->pRelevantSrvOpen, c->pFobx,
c->pRelevantSrvOpen->pVNetRoot, c->pFcb->pNetRoot);
}
VOID print_fcb(int on, IN PMRX_FCB p)
{
if (!on) return;
DbgP("PMRX_FCB %p OpenCount %d\n", p, p->OpenCount);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpNetRoot %p\n", p->pNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("FcbState %ld\n", p->FcbState);
//DbgP("UncleanCount %ld\n", p->UncleanCount);
//DbgP("UncachedUncleanCount %ld\n", p->UncachedUncleanCount);
DbgP("\tOpenCount %ld\n", p->OpenCount);
//DbgP("OutstandingLockOperationsCount %ld\n", p->OutstandingLockOperationsCount);
//DbgP("ActualAllocationLength %ull\n", p->ActualAllocationLength);
//DbgP("Attributes %ld\n", p->Attributes);
//DbgP("IsFileWritten %d\n", p->IsFileWritten);
//DbgP("fShouldBeOrphaned %d\n", p->fShouldBeOrphaned);
//DbgP("fMiniInited %ld\n", p->fMiniInited);
//DbgP("CachedNetRootType %c\n", p->CachedNetRootType);
//DbgP("SrvOpenList\n");
//DbgP("SrvOpenListVersion %ld\n", p->SrvOpenListVersion);
DbgP("*****************\n");
#endif
}
VOID print_srv_open(int on, IN PMRX_SRV_OPEN p)
{
if (!on) return;
DbgP("PMRX_SRV_OPEN %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpFcb %p\n", p->pFcb);
DbgP("\tpVNetRoot %p\n", p->pVNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
//DbgP("pAlreadyPrefixedName %wZ\n", p->pAlreadyPrefixedName);
//DbgP("UncleanFobxCount %ld\n", p->UncleanFobxCount);
DbgP("\tOpenCount %ld\n", p->OpenCount);
//DbgP("Key %p\n", p->Key);
//DbgP("DesiredAccess\n");
//DbgP("ShareAccess %ld\n", p->ShareAccess);
//DbgP("CreateOptions %ld\n", p->CreateOptions);
//DbgP("BufferingFlags %ld\n", p->BufferingFlags);
//DbgP("ulFileSizeVersion %ld\n", p->ulFileSizeVersion);
//DbgP("SrvOpenQLinks\n");
DbgP("*****************\n");
#endif
}
VOID print_fobx(int on, IN PMRX_FOBX p)
{
if (!on) return;
DbgP("PMRX_FOBX %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpSrvOpen %p\n", p->pSrvOpen);
DbgP("\tAssociatedFileObject %p\n", p->AssociatedFileObject);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("*****************\n");
#endif
}
VOID print_irp_flags(int on, PIRP irp)
{
if (!on) return;
if (irp->Flags)
DbgP("IRP FLAGS: 0x%x %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",
irp->Flags,
(irp->Flags & IRP_NOCACHE)?"NOCACHE":"",
(irp->Flags & IRP_PAGING_IO)?"PAGING_IO":"",
(irp->Flags & IRP_MOUNT_COMPLETION)?"MOUNT":"",
(irp->Flags & IRP_SYNCHRONOUS_API)?"SYNC":"",
(irp->Flags & IRP_ASSOCIATED_IRP)?"ASSOC_IPR":"",
(irp->Flags & IRP_BUFFERED_IO)?"BUFFERED":"",
(irp->Flags & IRP_DEALLOCATE_BUFFER)?"DEALLOC_BUF":"",
(irp->Flags & IRP_INPUT_OPERATION)?"INPUT_OP":"",
(irp->Flags & IRP_SYNCHRONOUS_PAGING_IO)?"SYNC_PAGIN_IO":"",
(irp->Flags & IRP_CREATE_OPERATION)?"CREATE_OP":"",
(irp->Flags & IRP_READ_OPERATION)?"READ_OP":"",
(irp->Flags & IRP_WRITE_OPERATION)?"WRITE_OP":"",
(irp->Flags & IRP_CLOSE_OPERATION)?"CLOSE_OP":"",
(irp->Flags & IRP_DEFER_IO_COMPLETION)?"DEFER_IO":"");
}
void print_irps_flags(int on, PIO_STACK_LOCATION irps)
{
if (!on) return;
if (irps->Flags)
DbgP("IRPSP FLAGS 0x%x %s %s %s %s\n", irps->Flags,
(irps->Flags & SL_CASE_SENSITIVE)?"CASE_SENSITIVE":"",
(irps->Flags & SL_OPEN_PAGING_FILE)?"PAGING_FILE":"",
(irps->Flags & SL_FORCE_ACCESS_CHECK)?"ACCESS_CHECK":"",
(irps->Flags & SL_OPEN_TARGET_DIRECTORY)?"TARGET_DIR":"");
}
void print_nt_create_params(int on, NT_CREATE_PARAMETERS params)
{
if (!on) return;
if (params.FileAttributes)
DbgP("File attributes %x: %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",
params.FileAttributes,
(params.FileAttributes & FILE_ATTRIBUTE_TEMPORARY)?"TEMPFILE ":"",
(params.FileAttributes & FILE_ATTRIBUTE_READONLY)?"READONLY ":"",
(params.FileAttributes & FILE_ATTRIBUTE_HIDDEN)?"HIDDEN ":"",
(params.FileAttributes & FILE_ATTRIBUTE_SYSTEM)?"SYSTEM ":"",
(params.FileAttributes & FILE_ATTRIBUTE_ARCHIVE)?"ARCHIVE ":"",
(params.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)?"DIR ":"",
(params.FileAttributes & FILE_ATTRIBUTE_DEVICE)?"DEVICE ":"",
(params.FileAttributes & FILE_ATTRIBUTE_NORMAL)?"NORMAL ":"",
(params.FileAttributes & FILE_ATTRIBUTE_SPARSE_FILE)?"SPARSE_FILE ":"",
(params.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)?"REPARSE_POINT ":"",
(params.FileAttributes & FILE_ATTRIBUTE_COMPRESSED)?"COMPRESSED ":"",
(params.FileAttributes & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)?"NOT INDEXED ":"",
(params.FileAttributes & FILE_ATTRIBUTE_ENCRYPTED)?"ENCRYPTED ":"",
(params.FileAttributes & FILE_ATTRIBUTE_VIRTUAL)?"VIRTUAL":"");
if (params.Disposition == FILE_SUPERSEDE)
DbgP("Create Dispositions: FILE_SUPERSEDE\n");
if (params.Disposition == FILE_CREATE)
DbgP("Create Dispositions: FILE_CREATE\n");
if (params.Disposition == FILE_OPEN)
DbgP("Create Dispositions: FILE_OPEN\n");
if (params.Disposition == FILE_OPEN_IF)
DbgP("Create Dispositions: FILE_OPEN_IF\n");
if (params.Disposition == FILE_OVERWRITE)
DbgP("Create Dispositions: FILE_OVERWRITE\n");
if (params.Disposition == FILE_OVERWRITE_IF)
DbgP("Create Dispositions: FILE_OVERWRITE_IF\n");
DbgP("Create Attributes: 0x%x %s %s %s %s %s %s %s %s %s %s %s %s %s %s "
"%s %s\n", params.CreateOptions,
(params.CreateOptions & FILE_DIRECTORY_FILE)?"DIRFILE":"",
(params.CreateOptions & FILE_NON_DIRECTORY_FILE)?"FILE":"",
(params.CreateOptions & FILE_DELETE_ON_CLOSE)?"DELETE_ON_CLOSE":"",
(params.CreateOptions & FILE_WRITE_THROUGH)?"WRITE_THROUGH":"",
(params.CreateOptions & FILE_SEQUENTIAL_ONLY)?"SEQUENTIAL":"",
(params.CreateOptions & FILE_RANDOM_ACCESS)?"RANDOM":"",
(params.CreateOptions & FILE_NO_INTERMEDIATE_BUFFERING)?"NO_BUFFERING":"",
(params.CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)?"SYNC_ALERT":"",
(params.CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)?"SYNC_NOALERT":"",
(params.CreateOptions & FILE_CREATE_TREE_CONNECTION)?"CREATE_TREE_CONN":"",
(params.CreateOptions & FILE_COMPLETE_IF_OPLOCKED)?"OPLOCKED":"",
(params.CreateOptions & FILE_NO_EA_KNOWLEDGE)?"NO_EA":"",
(params.CreateOptions & FILE_OPEN_REPARSE_POINT)?"OPEN_REPARSE":"",
(params.CreateOptions & FILE_OPEN_BY_FILE_ID)?"BY_ID":"",
(params.CreateOptions & FILE_OPEN_FOR_BACKUP_INTENT)?"4_BACKUP":"",
(params.CreateOptions & FILE_RESERVE_OPFILTER)?"OPFILTER":"");
DbgP("Share Access: %s %s %s\n",
(params.ShareAccess & FILE_SHARE_READ)?"READ":"",
(params.ShareAccess & FILE_SHARE_WRITE)?"WRITE":"",
(params.ShareAccess & FILE_SHARE_DELETE)?"DELETE":"");
DbgP("Desired Access: 0x%x %s %s %s %s %s %s %s %s %s %s %s\n",
params.DesiredAccess,
(params.DesiredAccess & FILE_READ_DATA)?"READ":"",
(params.DesiredAccess & STANDARD_RIGHTS_READ)?"READ_ACL":"",
(params.DesiredAccess & FILE_READ_ATTRIBUTES)?"GETATTR":"",
(params.DesiredAccess & FILE_READ_EA)?"READ_EA":"",
(params.DesiredAccess & FILE_WRITE_DATA)?"WRITE":"",
(params.DesiredAccess & FILE_WRITE_ATTRIBUTES)?"SETATTR":"",
(params.DesiredAccess & FILE_WRITE_EA)?"WRITE_EA":"",
(params.DesiredAccess & FILE_APPEND_DATA)?"APPEND":"",
(params.DesiredAccess & FILE_EXECUTE)?"EXEC":"",
(params.DesiredAccess & FILE_LIST_DIRECTORY)?"LSDIR":"",
(params.DesiredAccess & FILE_TRAVERSE)?"TRAVERSE":"",
(params.DesiredAccess & FILE_LIST_DIRECTORY)?"LSDIR":"",
(params.DesiredAccess & DELETE)?"DELETE":"",
(params.DesiredAccess & READ_CONTROL)?"READ_CONTROL":"",
(params.DesiredAccess & WRITE_DAC)?"WRITE_DAC":"",
(params.DesiredAccess & WRITE_OWNER)?"WRITE_OWNER":"",
(params.DesiredAccess & SYNCHRONIZE)?"SYNCHRONIZE":"");
}
unsigned char * print_file_information_class(int InfoClass)
{
switch(InfoClass) {
case FileBothDirectoryInformation:
return (unsigned char *)"FileBothDirectoryInformation";
case FileDirectoryInformation:
return (unsigned char *)"FileDirectoryInformation";
case FileFullDirectoryInformation:
return (unsigned char *)"FileFullDirectoryInformation";
case FileIdBothDirectoryInformation:
return (unsigned char *)"FileIdBothDirectoryInformation";
case FileIdFullDirectoryInformation:
return (unsigned char *)"FileIdFullDirectoryInformation";
case FileNamesInformation:
return (unsigned char *)"FileNamesInformation";
case FileObjectIdInformation:
return (unsigned char *)"FileObjectIdInformation";
case FileQuotaInformation:
return (unsigned char *)"FileQuotaInformation";
case FileReparsePointInformation:
return (unsigned char *)"FileReparsePointInformation";
case FileAllInformation:
return (unsigned char *)"FileAllInformation";
case FileAttributeTagInformation:
return (unsigned char *)"FileAttributeTagInformation";
case FileBasicInformation:
return (unsigned char *)"FileBasicInformation";
case FileCompressionInformation:
return (unsigned char *)"FileCompressionInformation";
case FileEaInformation:
return (unsigned char *)"FileEaInformation";
case FileInternalInformation:
return (unsigned char *)"FileInternalInformation";
case FileNameInformation:
return (unsigned char *)"FileNameInformation";
case FileNetworkOpenInformation:
return (unsigned char *)"FileNetworkOpenInformation";
case FilePositionInformation:
return (unsigned char *)"FilePositionInformation";
case FileStandardInformation:
return (unsigned char *)"FileStandardInformation";
case FileStreamInformation:
return (unsigned char *)"FileStreamInformation";
case FileAllocationInformation:
return (unsigned char *)"FileAllocationInformation";
case FileDispositionInformation:
return (unsigned char *)"FileDispositionInformation";
case FileEndOfFileInformation:
return (unsigned char *)"FileEndOfFileInformation";
case FileLinkInformation:
return (unsigned char *)"FileLinkInformation";
case FileRenameInformation:
return (unsigned char *)"FileRenameInformation";
case FileValidDataLengthInformation:
return (unsigned char *)"FileValidDataLengthInformation";
default:
return (unsigned char *)"UNKNOWN";
}
}
unsigned char *print_fs_information_class(int InfoClass)
{
switch (InfoClass) {
case FileFsAttributeInformation:
return (unsigned char *)"FileFsAttributeInformation";
case FileFsControlInformation:
return (unsigned char *)"FileFsControlInformation";
case FileFsDeviceInformation:
return (unsigned char *)"FileFsDeviceInformation";
case FileFsDriverPathInformation:
return (unsigned char *)"FileFsDriverPathInformation";
case FileFsFullSizeInformation:
return (unsigned char *)"FileFsFullSizeInformation";
case FileFsObjectIdInformation:
return (unsigned char *)"FileFsObjectIdInformation";
case FileFsSizeInformation:
return (unsigned char *)"FileFsSizeInformation";
case FileFsVolumeInformation:
return (unsigned char *)"FileFsVolumeInformation";
default:
return (unsigned char *)"UNKNOWN";
}
}
void print_caching_level(int on, ULONG flag, PUNICODE_STRING name)
{
if (!on) return;
switch(flag) {
case 0:
DbgP("enable_caching: DISABLE_CACHING %wZ\n", name);
break;
case 1:
DbgP("enable_caching: ENABLE_READ_CACHING %wZ\n", name);
break;
case 2:
DbgP("enable_caching: ENABLE_WRITE_CACHING %wZ\n", name);
break;
case 3:
DbgP("enable_caching: ENABLE_READWRITE_CACHING %wZ\n", name);
break;
}
}
const char *opcode2string(int opcode)
{
switch(opcode) {
case NFS41_SHUTDOWN: return "NFS41_SHUTDOWN";
case NFS41_MOUNT: return "NFS41_MOUNT";
case NFS41_UNMOUNT: return "NFS41_UNMOUNT";
case NFS41_OPEN: return "NFS41_OPEN";
case NFS41_CLOSE: return "NFS41_CLOSE";
case NFS41_READ: return "NFS41_READ";
case NFS41_WRITE: return "NFS41_WRITE";
case NFS41_LOCK: return "NFS41_LOCK";
case NFS41_UNLOCK: return "NFS41_UNLOCK";
case NFS41_DIR_QUERY: return "NFS41_DIR_QUERY";
case NFS41_FILE_QUERY: return "NFS41_FILE_QUERY";
case NFS41_FILE_SET: return "NFS41_FILE_SET";
case NFS41_EA_SET: return "NFS41_EA_SET";
case NFS41_EA_GET: return "NFS41_EA_GET";
case NFS41_SYMLINK: return "NFS41_SYMLINK";
case NFS41_VOLUME_QUERY: return "NFS41_VOLUME_QUERY";
case NFS41_ACL_QUERY: return "NFS41_ACL_QUERY";
case NFS41_ACL_SET: return "NFS41_ACL_SET";
default: return "UNKNOWN";
}
}
void print_acl_args(
SECURITY_INFORMATION info)
{
DbgP("Security query: %s %s %s\n",
(info & OWNER_SECURITY_INFORMATION)?"OWNER":"",
(info & GROUP_SECURITY_INFORMATION)?"GROUP":"",
(info & DACL_SECURITY_INFORMATION)?"DACL":"",
(info & SACL_SECURITY_INFORMATION)?"SACL":"");
}
void print_open_error(int on, int status)
{
if (!on) return;
switch (status) {
case STATUS_ACCESS_DENIED:
DbgP("[ERROR] nfs41_Create: STATUS_ACCESS_DENIED\n");
break;
case STATUS_NETWORK_ACCESS_DENIED:
DbgP("[ERROR] nfs41_Create: STATUS_NETWORK_ACCESS_DENIED\n");
break;
case STATUS_OBJECT_NAME_INVALID:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_NAME_INVALID\n");
break;
case STATUS_OBJECT_NAME_COLLISION:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_NAME_COLLISION\n");
break;
case STATUS_FILE_INVALID:
DbgP("[ERROR] nfs41_Create: STATUS_FILE_INVALID\n");
break;
case STATUS_OBJECT_NAME_NOT_FOUND:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_NAME_NOT_FOUND\n");
break;
case STATUS_NAME_TOO_LONG:
DbgP("[ERROR] nfs41_Create: STATUS_NAME_TOO_LONG\n");
break;
case STATUS_OBJECT_PATH_NOT_FOUND:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_PATH_NOT_FOUND\n");
break;
case STATUS_BAD_NETWORK_PATH:
DbgP("[ERROR] nfs41_Create: STATUS_BAD_NETWORK_PATH\n");
break;
case STATUS_SHARING_VIOLATION:
DbgP("[ERROR] nfs41_Create: STATUS_SHARING_VIOLATION\n");
break;
case ERROR_REPARSE:
DbgP("[ERROR] nfs41_Create: STATUS_REPARSE\n");
break;
case ERROR_TOO_MANY_LINKS:
DbgP("[ERROR] nfs41_Create: STATUS_TOO_MANY_LINKS\n");
break;
case ERROR_DIRECTORY:
DbgP("[ERROR] nfs41_Create: STATUS_FILE_IS_A_DIRECTORY\n");
break;
case ERROR_BAD_FILE_TYPE:
DbgP("[ERROR] nfs41_Create: STATUS_NOT_A_DIRECTORY\n");
break;
default:
DbgP("[ERROR] nfs41_Create: STATUS_INSUFFICIENT_RESOURCES\n");
break;
}
}
void print_wait_status(int on, const char *prefix, NTSTATUS status,
const char *opcode, PVOID entry, LONGLONG xid)
{
if (!on) return;
switch (status) {
case STATUS_SUCCESS:
if (opcode)
DbgP("%s Got a wakeup call, finishing %s entry=%p xid=%lld\n",
prefix, opcode, entry, xid);
else
DbgP("%s Got a wakeup call\n", prefix);
break;
case STATUS_USER_APC:
DbgP("%s KeWaitForSingleObject returned STATUS_USER_APC\n", prefix);
break;
case STATUS_ALERTED:
DbgP("%s KeWaitForSingleObject returned STATUS_ALERTED\n", prefix);
break;
default:
DbgP("%s KeWaitForSingleObject returned %d\n", prefix, status);
}
}
/* This is taken from toaster/func. Rumor says this should be replaced
* with a WMI interface???
*/
ULONG
dprintk(
IN PCHAR func,
IN ULONG flags,
IN PCHAR format,
...)
{
#define TEMP_BUFFER_SIZE 1024
va_list list;
CHAR debugMessageBuffer[TEMP_BUFFER_SIZE];
NTSTATUS status, rv = STATUS_SUCCESS;
va_start(list, format);
if (format)
{
//
// Use the safe string function, RtlStringCbVPrintfA, instead of _vsnprintf.
// RtlStringCbVPrintfA NULL terminates the output buffer even if the message
// is longer than the buffer. This prevents malicious code from compromising
// the security of the system.
//
status = RtlStringCbVPrintfA(debugMessageBuffer, sizeof(debugMessageBuffer),
format, list);
if (!NT_SUCCESS(status))
rv = DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | flags,
"RtlStringCbVPrintfA failed %x \n", status);
else
rv = DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | flags, "%s %s: %s\n",
PNFS_TRACE_TAG, func, debugMessageBuffer);
}
va_end(list);
return rv;
}

View file

@ -0,0 +1,102 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#ifndef _NFS41_DEBUG_
#define _NFS41_DEBUG_
#define _DRIVER_NAME_ "NFS4.1 Driver"
ULONG __cdecl DbgP(IN PCCH fmt, ...);
ULONG __cdecl print_error(IN PCCH fmt, ...);
VOID print_fo_all(int on, IN PRX_CONTEXT c);
VOID print_srv_call(int on, IN PMRX_SRV_CALL p);
VOID print_net_root(int on, IN PMRX_NET_ROOT p);
VOID print_v_net_root(int on, IN PMRX_V_NET_ROOT p);
VOID print_fcb(int on, IN PMRX_FCB p);
VOID print_srv_open(int on, IN PMRX_SRV_OPEN p);
VOID print_fobx(int on, IN PMRX_FOBX p);
VOID print_irp_flags(int on, PIRP irp);
VOID print_irps_flags(int on, PIO_STACK_LOCATION irps);
void print_nt_create_params(int on, NT_CREATE_PARAMETERS params);
unsigned char *print_file_information_class(int InfoClass);
unsigned char *print_fs_information_class(int InfoClass);
void print_hexbuf(int on, unsigned char *title, unsigned char *buf, int len);
void print_ioctl(int on, int op);
void print_fs_ioctl(int on, int op);
void print_driver_state(int state);
void print_file_object(int on, PFILE_OBJECT file);
void print_basic_info(int on, PFILE_BASIC_INFORMATION info);
void print_std_info(int on, PFILE_STANDARD_INFORMATION info);
void print_ea_info(int on, PFILE_FULL_EA_INFORMATION info);
void print_get_ea(int on, PFILE_GET_EA_INFORMATION info);
void print_caching_level(int on, ULONG flag, PUNICODE_STRING s);
const char *opcode2string(int opcode);
void print_open_error(int on, int status);
void print_wait_status(int on, const char *str, NTSTATUS status,
const char *opcode, PVOID entry, LONGLONG xid);
void print_acl_args(SECURITY_INFORMATION info);
#define DbgEn() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"--> [%s] [%04x] %s\n", _DRIVER_NAME_, PsGetCurrentProcessId(), \
__FUNCTION__); _SEH2_TRY {
#define DbgEx() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"<-- [%s] [%04x] %s status = %08lx\n", _DRIVER_NAME_, PsGetCurrentProcessId(), \
__FUNCTION__, status); \
} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
status = _SEH2_GetExceptionCode() ; \
DbgP("Exception encountered with value = Ox%x\n", status); \
} _SEH2_END;
#define DbgR() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"<-- [%s] [%04x] %s\n", _DRIVER_NAME_, PsGetCurrentProcessId(), __FUNCTION__); \
} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { \
NTSTATUS status; \
status = _SEH2_GetExceptionCode() ; \
DbgP("Exception encountered with value = Ox%x\n", status); \
} _SEH2_END;
/* These are for ToasterDebugPrint */
#define DBG_ERROR 0x00000001
#define DBG_WARN 0x00000002
#define DBG_TRACE 0x00000004
#define DBG_INFO 0x00000008
#define DBG_DISP_IN 0x00000010 /* Marks entry into dispatch functions */
#define DBG_DISP_OUT 0x00000020 /* Marks exit from dispatch functions */
/* I want to do:
* #define dprintk(flags, args...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_MASK | flags, ## args)
* but the ... is gcc specific, can't seem to do it here.
*/
#define PNFS_TRACE_TAG "PNFSMRX: "
#define PNFS_FLTR_ID DPFLTR_IHVDRIVER_ID
#define DbgEnter() DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_IN, "%s*** %s ***\n", \
PNFS_TRACE_TAG, __FUNCTION__);
#define DbgExit(status) DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_OUT, "%s<-- %s <-- 0x%08lx\n", \
PNFS_TRACE_TAG, __FUNCTION__, status);
ULONG
dprintk(
IN PCHAR func,
IN ULONG flags,
IN PCHAR format,
...);
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,93 @@
/* NFSv4.1 client for Windows
* Copyright © 2012 The Regents of the University of Michigan
*
* Olga Kornievskaia <aglo@umich.edu>
* Casey Bodley <cbodley@umich.edu>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* without any warranty; without even the implied warranty of merchantability
* or fitness for a particular purpose. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
#ifndef _NFS41_DRIVER_
#define _NFS41_DRIVER_
#define NFS41_DEVICE_NAME L"\\Device\\nfs41_driver"
#define NFS41_SHADOW_DEVICE_NAME L"\\??\\nfs41_driver"
#define NFS41_USER_DEVICE_NAME L"\\\\.\\nfs41_driver"
#define NFS41_USER_DEVICE_NAME_A "\\\\.\\nfs41_driver"
#define NFS41_PROVIDER_NAME_A "NFS41 Network"
#define NFS41_PROVIDER_NAME_U L"NFS41 Network"
#define NFS41_PIPE_NAME L"\\Device\\nfs41_pipe"
#define NFS41_SHADOW_PIPE_NAME L"\\??\\nfs41_pipe"
#define NFS41_USER_PIPE_NAME L"\\\\.\\nfs41_pipe"
#define NFS41_SHARED_MEMORY_NAME L"\\BaseNamedObjects\\nfs41_shared_memory"
#define NFS41_USER_SHARED_MEMORY_NAME "Global\\nfs41_shared_memory"
// See "Defining I/O Control Codes" in WDK docs
#define _RDR_CTL_CODE(code, method) \
CTL_CODE(FILE_DEVICE_NETWORK_REDIRECTOR, 0x800 | (code), method, FILE_ANY_ACCESS)
#define IOCTL_NFS41_START _RDR_CTL_CODE(0, METHOD_BUFFERED)
#define IOCTL_NFS41_STOP _RDR_CTL_CODE(1, METHOD_NEITHER)
#define IOCTL_NFS41_GETSTATE _RDR_CTL_CODE(3, METHOD_NEITHER)
#define IOCTL_NFS41_ADDCONN _RDR_CTL_CODE(4, METHOD_BUFFERED)
#define IOCTL_NFS41_DELCONN _RDR_CTL_CODE(5, METHOD_BUFFERED)
#define IOCTL_NFS41_READ _RDR_CTL_CODE(6, METHOD_BUFFERED)
#define IOCTL_NFS41_WRITE _RDR_CTL_CODE(7, METHOD_BUFFERED)
#define IOCTL_NFS41_INVALCACHE _RDR_CTL_CODE(8, METHOD_BUFFERED)
typedef enum _nfs41_opcodes {
NFS41_MOUNT,
NFS41_UNMOUNT,
NFS41_OPEN,
NFS41_CLOSE,
NFS41_READ,
NFS41_WRITE,
NFS41_LOCK,
NFS41_UNLOCK,
NFS41_DIR_QUERY,
NFS41_FILE_QUERY,
NFS41_FILE_SET,
NFS41_EA_GET,
NFS41_EA_SET,
NFS41_SYMLINK,
NFS41_VOLUME_QUERY,
NFS41_ACL_QUERY,
NFS41_ACL_SET,
NFS41_SHUTDOWN,
INVALID_OPCODE
} nfs41_opcodes;
enum rpcsec_flavors {
RPCSEC_AUTH_SYS,
RPCSEC_AUTHGSS_KRB5,
RPCSEC_AUTHGSS_KRB5I,
RPCSEC_AUTHGSS_KRB5P
};
typedef enum _nfs41_init_driver_state {
NFS41_INIT_DRIVER_STARTABLE,
NFS41_INIT_DRIVER_START_IN_PROGRESS,
NFS41_INIT_DRIVER_STARTED
} nfs41_init_driver_state;
typedef enum _nfs41_start_driver_state {
NFS41_START_DRIVER_STARTABLE,
NFS41_START_DRIVER_START_IN_PROGRESS,
NFS41_START_DRIVER_STARTED,
NFS41_START_DRIVER_STOPPED
} nfs41_start_driver_state;
#endif