22#define MINIRDR__NAME "Value is ignored, only fact of definition"
37#if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7)
39 ULONG *utf8_bytes_written,
42 ULONG *uni_bytes_written,
46#define USE_MOUNT_SEC_CONTEXT
50#define DEBUG_MARSHAL_HEADER
51#define DEBUG_MARSHAL_DETAIL
55#define DEBUG_INVALIDATE_CACHE
67#define DEBUG_TIME_BASED_COHERENCY
74typedef struct __nfs41_timings {
89#define DISABLE_CACHING 0
90#define ENABLE_READ_CACHING 1
91#define ENABLE_WRITE_CACHING 2
92#define ENABLE_READWRITE_CACHING 3
94#define NFS41_MM_POOLTAG ('nfs4')
95#define NFS41_MM_POOLTAG_ACL ('acls')
96#define NFS41_MM_POOLTAG_MOUNT ('mnts')
97#define NFS41_MM_POOLTAG_OPEN ('open')
98#define NFS41_MM_POOLTAG_UP ('upca')
99#define NFS41_MM_POOLTAG_DOWN ('down')
109#define DECLARE_CONST_ANSI_STRING(_var, _string) \
110 const CHAR _var ## _buffer[] = _string; \
111 const ANSI_STRING _var = { sizeof(_string) - sizeof(CHAR), \
112 sizeof(_string), (PCH) _var ## _buffer }
113#define RELATIVE(wait) (-(wait))
114#define NANOSECONDS(nanos) (((signed __int64)(nanos)) / 100L)
115#define MICROSECONDS(micros) (((signed __int64)(micros)) * NANOSECONDS(1000L))
116#define MILLISECONDS(milli) (((signed __int64)(milli)) * MICROSECONDS(1000L))
117#define SECONDS(seconds) (((signed __int64)(seconds)) * MILLISECONDS(1000L))
128 return lhs->Length == rhs_len &&
288#define nfs41_AddEntry(lock,list,pEntry) \
289 ExAcquireFastMutex(&lock); \
290 InsertTailList(&(list).head, &(pEntry)->next); \
291 ExReleaseFastMutex(&lock);
292#define nfs41_RemoveFirst(lock,list,pEntry) \
293 ExAcquireFastMutex(&lock); \
294 pEntry = (IsListEmpty(&(list).head) \
296 : RemoveHeadList(&(list).head)); \
297 ExReleaseFastMutex(&lock);
298#define nfs41_RemoveEntry(lock,pEntry) \
299 ExAcquireFastMutex(&lock); \
300 RemoveEntryList(&pEntry->next); \
301 ExReleaseFastMutex(&lock);
302#define nfs41_IsListEmpty(lock,list,flag) \
303 ExAcquireFastMutex(&lock); \
304 flag = IsListEmpty(&(list).head); \
305 ExReleaseFastMutex(&lock);
306#define nfs41_GetFirstEntry(lock,list,pEntry) \
307 ExAcquireFastMutex(&lock); \
308 pEntry = (IsListEmpty(&(list).head) \
310 : (nfs41_updowncall_entry *) \
311 (CONTAINING_RECORD((list).head.Flink, \
312 nfs41_updowncall_entry, \
314 ExReleaseFastMutex(&lock);
315#define nfs41_GetFirstMountEntry(lock,list,pEntry) \
316 ExAcquireFastMutex(&lock); \
317 pEntry = (IsListEmpty(&(list).head) \
319 : (nfs41_mount_entry *) \
320 (CONTAINING_RECORD((list).head.Flink, \
323 ExReleaseFastMutex(&lock);
335#define SERVER_NAME_BUFFER_SIZE 1024
336#define MOUNT_CONFIG_RW_SIZE_MIN 1024
337#define MOUNT_CONFIG_RW_SIZE_DEFAULT 1048576
338#define MOUNT_CONFIG_RW_SIZE_MAX 1048576
339#define MAX_SEC_FLAVOR_LEN 12
340#define UPCALL_TIMEOUT_DEFAULT 50
365#define NFS41GetNetRootExtension(pNetRoot) \
366 (((pNetRoot) == NULL) ? NULL : \
367 (PNFS41_NETROOT_EXTENSION)((pNetRoot)->Context))
370#define FS_NAME L"NFS"
371#define FS_NAME_LEN (sizeof(FS_NAME) - sizeof(WCHAR))
372#define FS_ATTR_LEN (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + FS_NAME_LEN)
375#define VOL_NAME L"PnfsVolume"
376#define VOL_NAME_LEN (sizeof(VOL_NAME) - sizeof(WCHAR))
377#define VOL_ATTR_LEN (sizeof(FILE_FS_VOLUME_INFORMATION) + VOL_NAME_LEN)
390#define STORE_MOUNT_SEC_CONTEXT
391#ifdef STORE_MOUNT_SEC_CONTEXT
395#define NFS41GetVNetRootExtension(pVNetRoot) \
396 (((pVNetRoot) == NULL) ? NULL : \
397 (PNFS41_V_NET_ROOT_EXTENSION)((pVNetRoot)->Context))
409#define NFS41GetFcbExtension(pFcb) \
410 (((pFcb) == NULL) ? NULL : (PNFS41_FCB)((pFcb)->Context))
425#define NFS41GetFobxExtension(pFobx) \
426 (((pFobx) == NULL) ? NULL : (PNFS41_FOBX)((pFobx)->Context))
446#define NFS41GetDeviceExtension(RxContext,pExt) \
447 PNFS41_DEVICE_EXTENSION pExt = (PNFS41_DEVICE_EXTENSION) \
448 ((PBYTE)(RxContext->RxDeviceObject) + sizeof(RDBSS_DEVICE_OBJECT))
467#define RxDefineNode( node, type ) \
468 node->NodeTypeCode = NTC_##type; \
469 node->NodeByteSize = sizeof(type);
471#define RDR_NULL_STATE 0
472#define RDR_UNLOADED 1
473#define RDR_UNLOADING 2
477#define RDR_STOPPING 6
478#define RDR_STARTING 7
493 DbgP(
"FileOject %p name %wZ access r=%d,w=%d,d=%d share r=%d,w=%d,d=%d\n",
501 DbgP(
"Couldn't print FileObject IrpSp is NULL\n");
513 ULONG ActualCount = 0;
515 return sizeof(
str->MaximumLength) + ActualCount +
sizeof(
UNICODE_NULL);
526 if (
str->Length == 0) {
535 &ActualCount,
str->Buffer,
str->Length);
537 print_error(
"RtlUnicodeToUTF8N('%wZ') failed with 0x%08X\n",
546 &ActualCount,
str->Buffer,
str->Length);
548 print_error(
"RtlUnicodeToUTF8N(%hu, '%wZ', %hu) failed with 0x%08X\n",
556 (*pos)[ActualCount] =
'\0';
569 ULONG header_len = 0;
570 unsigned char *tmp =
buf;
572 header_len =
sizeof(
entry->version) +
sizeof(
entry->xid) +
574 if (header_len > buf_len) {
581 tmp +=
sizeof(
entry->version);
583 tmp +=
sizeof(
entry->xid);
585 tmp +=
sizeof(
entry->opcode);
591#ifdef DEBUG_MARSHAL_HEADER
593 DbgP(
"[upcall header] xid=%lld opcode=%s filename=%wZ version=%d "
594 "session=0x%x open_state=0x%x\n",
entry->xid,
614 return "UNKNOWN FLAVOR";
623 ULONG header_len = 0;
624 unsigned char *tmp =
buf;
638 if (header_len > buf_len) {
647 tmp +=
sizeof(
DWORD);
649 tmp +=
sizeof(
DWORD);
654#ifdef DEBUG_MARSHAL_DETAIL
655 DbgP(
"marshal_nfs41_mount: server name=%wZ mount point=%wZ sec_flavor=%s "
656 "rsize=%d wsize=%d\n",
entry->u.Mount.srv_name,
entry->u.Mount.root,
658 entry->u.Mount.wsize);
680 ULONG header_len = 0;
681 unsigned char *tmp =
buf;
690 if (header_len > buf_len) {
697 sizeof(
entry->u.Open.access_mask));
698 tmp +=
sizeof(
entry->u.Open.access_mask);
700 sizeof(
entry->u.Open.access_mode));
701 tmp +=
sizeof(
entry->u.Open.access_mode);
703 tmp +=
sizeof(
entry->u.Open.attrs);
705 tmp +=
sizeof(
entry->u.Open.copts);
707 tmp +=
sizeof(
entry->u.Open.disp);
709 sizeof(
entry->u.Open.open_owner_id));
710 tmp +=
sizeof(
entry->u.Open.open_owner_id);
712 tmp +=
sizeof(
DWORD);
719 if (
entry->u.Open.EaMdl) {
720 entry->u.Open.EaBuffer =
728 print_error(
"MmMapLockedPagesSpecifyCache failed to map pages\n");
741#ifdef DEBUG_MARSHAL_DETAIL
742 DbgP(
"marshal_nfs41_open: name=%wZ mask=0x%x access=0x%x attrs=0x%x "
743 "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o srv_open=%p ea=%p\n",
747 entry->u.Open.srv_open,
entry->u.Open.EaBuffer);
760 ULONG header_len = 0;
761 unsigned char *tmp =
buf;
767 header_len = *
len +
sizeof(
entry->buf_len) +
768 sizeof(
entry->u.ReadWrite.offset) +
sizeof(
HANDLE);
769 if (header_len > buf_len) {
775 tmp +=
sizeof(
entry->buf_len);
777 sizeof(
entry->u.ReadWrite.offset));
778 tmp +=
sizeof(
entry->u.ReadWrite.offset);
789 print_error(
"MmMapLockedPagesSpecifyCache failed to map pages\n");
796 print_error(
"Call to MmMapLocked failed due to exception 0x%x\n",
code);
803#ifdef DEBUG_MARSHAL_DETAIL
804 DbgP(
"marshal_nfs41_rw: len=%lu offset=%llu MdlAddress=%p Userspace=%p\n",
819 ULONG header_len = 0;
820 unsigned char *tmp =
buf;
827 if (header_len > buf_len) {
840#ifdef DEBUG_MARSHAL_DETAIL
841 DbgP(
"marshal_nfs41_lock: offset=%llx length=%llx exclusive=%u "
842 "blocking=%u\n",
entry->u.Lock.offset,
entry->u.Lock.length,
843 entry->u.Lock.exclusive,
entry->u.Lock.blocking);
856 ULONG header_len = 0;
857 unsigned char *tmp =
buf;
866 if (header_len > buf_len) {
871 tmp +=
sizeof(
ULONG);
883#ifdef DEBUG_MARSHAL_DETAIL
884 DbgP(
"marshal_nfs41_unlock: count=%u\n",
entry->u.Unlock.count);
897 ULONG header_len = 0;
898 unsigned char *tmp =
buf;
905 if (
entry->u.Close.remove)
909 if (header_len > buf_len) {
916 if (
entry->u.Close.remove) {
924#ifdef DEBUG_MARSHAL_DETAIL
925 DbgP(
"marshal_nfs41_close: name=%wZ remove=%d srv_open=%p renamed=%d\n",
927 entry->u.Close.remove,
entry->u.Close.srv_open,
entry->u.Close.renamed);
940 ULONG header_len = 0;
941 unsigned char *tmp =
buf;
949 if (header_len > buf_len) {
955 tmp +=
sizeof(
ULONG);
957 tmp +=
sizeof(
ULONG);
967 entry->u.QueryFile.mdl_buf =
974 if (
entry->u.QueryFile.mdl_buf ==
NULL) {
975 print_error(
"MmMapLockedPagesSpecifyCache failed to map pages\n");
982 print_error(
"Call to MmMapLocked failed due to exception 0x%x\n",
code);
989#ifdef DEBUG_MARSHAL_DETAIL
990 DbgP(
"marshal_nfs41_dirquery: filter='%wZ'class=%d len=%d "
991 "1st\\restart\\single=%d\\%d\\%d\n",
entry->u.QueryFile.filter,
993 entry->u.QueryFile.initial_query,
entry->u.QueryFile.restart_scan,
994 entry->u.QueryFile.return_single);
1007 ULONG header_len = 0;
1008 unsigned char *tmp =
buf;
1014 header_len = *
len + 2 *
sizeof(
ULONG);
1015 if (header_len > buf_len) {
1020 tmp +=
sizeof(
ULONG);
1022 tmp +=
sizeof(
ULONG);
1028#ifdef DEBUG_MARSHAL_DETAIL
1029 DbgP(
"marshal_nfs41_filequery: class=%d\n",
entry->u.QueryFile.InfoClass);
1042 ULONG header_len = 0;
1043 unsigned char *tmp =
buf;
1051 if (header_len > buf_len) {
1058 tmp +=
sizeof(
ULONG);
1060 tmp +=
sizeof(
ULONG);
1064#ifdef DEBUG_MARSHAL_DETAIL
1065 DbgP(
"marshal_nfs41_fileset: filename='%wZ' class=%d\n",
1066 entry->filename,
entry->u.SetFile.InfoClass);
1079 ULONG header_len = 0;
1080 unsigned char *tmp =
buf;
1088 if (header_len > buf_len) {
1096 tmp +=
sizeof(
DWORD);
1098 tmp +=
sizeof(
ULONG);
1102#ifdef DEBUG_MARSHAL_DETAIL
1103 DbgP(
"marshal_nfs41_easet: filename=%wZ, buflen=%d mode=0x%x\n",
1117 ULONG header_len = 0;
1118 unsigned char *tmp =
buf;
1127 if (header_len > buf_len) {
1135 tmp +=
sizeof(
ULONG);
1141 tmp +=
sizeof(
ULONG);
1143 tmp +=
sizeof(
ULONG);
1144 if (
entry->u.QueryEa.EaList &&
entry->u.QueryEa.EaListLength)
1146 entry->u.QueryEa.EaListLength);
1149#ifdef DEBUG_MARSHAL_DETAIL
1150 DbgP(
"marshal_nfs41_eaget: filename=%wZ, index=%d list_len=%d "
1151 "rescan=%d single=%d\n",
entry->filename,
1152 entry->u.QueryEa.EaIndex,
entry->u.QueryEa.EaListLength,
1153 entry->u.QueryEa.RestartScan,
entry->u.QueryEa.ReturnSingleEntry);
1166 ULONG header_len = 0;
1167 unsigned char *tmp =
buf;
1174 if (
entry->u.Symlink.set)
1176 if (header_len > buf_len) {
1185 if (
entry->u.Symlink.set) {
1191#ifdef DEBUG_MARSHAL_DETAIL
1192 DbgP(
"marshal_nfs41_symlink: name %wZ symlink target %wZ\n",
1207 ULONG header_len = 0;
1208 unsigned char *tmp =
buf;
1215 if (header_len > buf_len) {
1223#ifdef DEBUG_MARSHAL_DETAIL
1224 DbgP(
"marshal_nfs41_volume: class=%d\n",
entry->u.Volume.query);
1237 ULONG header_len = 0;
1238 unsigned char *tmp =
buf;
1245 if (header_len > buf_len) {
1253#ifdef DEBUG_MARSHAL_DETAIL
1254 DbgP(
"marshal_nfs41_getacl: class=0x%x\n",
entry->u.Acl.query);
1267 ULONG header_len = 0;
1268 unsigned char *tmp =
buf;
1276 if (header_len > buf_len) {
1284 tmp +=
sizeof(
ULONG);
1288#ifdef DEBUG_MARSHAL_DETAIL
1289 DbgP(
"marshal_nfs41_setacl: class=0x%x sec_desc_len=%lu\n",
1314#ifdef DEBUG_INVALIDATE_CACHE
1315 DbgP(
"nfs41_invalidate_cache: received srv_open=%p %wZ\n",
1340 switch(
entry->opcode) {
1431 entry->opcode = opcode;
1434 entry->open_state = open_state;
1444 if (clnt_sec_ctx ==
NULL) {
1451 1, &
entry->sec_ctx);
1454 "SeCreateClientSecurityFromSubjectContext failed with %x\n",
1461 entry->psec_ctx = clnt_sec_ctx;
1476 if (!
entry->async_op) {
1490#define MAKE_WAITONCLOSE_NONITERRUPTABLE
1491#ifdef MAKE_WAITONCLOSE_NONITERRUPTABLE
1524 DbgP(
"[upcall] abandoning %s entry=%p xid=%lld\n",
1558 RxContext->InformationToReturn = 0;
1560 RxContext->InformationToReturn =
len;
1579 unsigned char **
buf)
1584 *
buf +=
sizeof(tmp->
xid);
1591#ifdef DEBUG_MARSHAL_HEADER
1592 DbgP(
"[downcall header] xid=%lld opcode=%s status=%d errno=%d\n", tmp->
xid,
1599 unsigned char **
buf)
1608#ifdef DEBUG_MARSHAL_DETAIL
1609 DbgP(
"unmarshal_nfs41_mount: session pointer 0x%x version %d lease_time "
1610 "%d\n",
cur->session,
cur->version,
cur->u.Mount.lease_time);
1617 unsigned char **
buf)
1620#ifdef DEBUG_MARSHAL_DETAIL
1621 DbgP(
"unmarshal_nfs41_setattr: returned ChangeTime %llu\n", *dest_buf);
1627 unsigned char **
buf)
1632 *
buf +=
sizeof(
cur->buf_len);
1634#ifdef DEBUG_MARSHAL_DETAIL
1635 DbgP(
"unmarshal_nfs41_rw: returned len %lu ChangeTime %llu\n",
1636 cur->buf_len,
cur->ChangeTime);
1649 print_error(
"Call to MmUnmapLockedPages failed due to"
1650 " exception 0x%0x\n",
code);
1659 unsigned char **
buf)
1664 if (
cur->u.Open.EaBuffer)
1690 cur->u.Open.symlink.Length =
cur->u.Open.symlink.MaximumLength -
1694 if (
cur->u.Open.symlink.Buffer ==
NULL) {
1700 cur->u.Open.symlink.MaximumLength);
1701#ifdef DEBUG_MARSHAL_DETAIL
1702 DbgP(
"unmarshal_nfs41_open: ERROR_REPARSE -> '%wZ'\n", &
cur->u.Open.symlink);
1705#ifdef DEBUG_MARSHAL_DETAIL
1706 DbgP(
"unmarshal_nfs41_open: open_state 0x%x mode %o changeattr %llu "
1707 "deleg_type %d\n",
cur->open_state,
cur->u.Open.mode,
1708 cur->ChangeTime,
cur->u.Open.deleg_type);
1716 unsigned char **
buf)
1722#ifdef DEBUG_MARSHAL_DETAIL
1723 DbgP(
"unmarshal_nfs41_dirquery: reply size %d\n", buf_len);
1734 if (buf_len >
cur->buf_len)
1736 cur->buf_len = buf_len;
1745 unsigned char **
buf)
1749 if (buf_len > *attr_len) {
1754 *attr_len = buf_len;
1761 unsigned char **
buf)
1775 unsigned char **
buf)
1779#ifdef DEBUG_MARSHAL_DETAIL
1781 DbgP(
"[unmarshal_nfs41_getattr] ChangeTime %llu\n",
cur->ChangeTime);
1787 unsigned char **
buf)
1801 if (buf_len >
cur->buf_len)
1803 cur->buf_len = buf_len;
1811 unsigned char **
buf)
1813 if (
cur->u.Symlink.set)
return;
1817 if (
cur->u.Symlink.target->Length >
1818 cur->u.Symlink.target->MaximumLength) {
1823 cur->u.Symlink.target->Length);
1852 if (
cur->xid == tmp->
xid) {
1869 DbgP(
"[downcall] Nobody is waiting for this request!!!\n");
1870 switch(
cur->opcode) {
1877 cur->u.QueryFile.mdl);
1881 if (
cur->u.Open.EaMdl) {
1941 if (
cur->async_op) {
1944 cur->u.ReadWrite.rxcontext->InformationToReturn =
1947 cur->u.ReadWrite.rxcontext->StoredStatus =
1949 cur->u.ReadWrite.rxcontext->InformationToReturn = 0;
2012 0,
NULL, &SecurityDesc);
2022 DbgP(
"section already created; returning success\n");
2026 DbgP(
"ZwCreateSection failed with %08X\n",
status);
2127 USHORT NameLength, EaPadding;
2135 pConnectionName->Length = pConnectionName->MaximumLength = 0;
2152 if (BufferLen != BufferLenExpected) {
2154 print_error(
"Received buffer of length %lu, but expected %lu bytes.\n",
2155 BufferLen, BufferLenExpected);
2156 pConnectionName->Length = pConnectionName->MaximumLength = 0;
2162 pConnectionName->Buffer = (
PWCH)
ptr;
2163 pConnectionName->Length = NameLength -
sizeof(
WCHAR);
2164 pConnectionName->MaximumLength = NameLength;
2167 *ppEaBuffer =
ptr + NameLength + EaPadding;
2194 DbgP(
"returning STATUS_PENDING\n");
2215#ifdef ENABLE_TIMINGS
2220 DbgP(
"%-9s: num_ops=%-10d delta_ticks=%-10d size=%-10d\n",
op_str,
2250#ifdef ENABLE_TIMINGS
2251 print_op_stat(
"lookup", &
lookup, 1);
2252 print_op_stat(
"open", &
open, 1);
2253 print_op_stat(
"close", &
close, 1);
2254 print_op_stat(
"volume", &
volume, 1);
2255 print_op_stat(
"getattr", &getattr, 1);
2256 print_op_stat(
"setattr", &setattr, 1);
2257 print_op_stat(
"getexattr", &getexattr, 1);
2258 print_op_stat(
"setexattr", &setexattr, 1);
2259 print_op_stat(
"readdir", &
readdir, 1);
2260 print_op_stat(
"getacl", &getacl, 1);
2261 print_op_stat(
"setacl", &setacl, 1);
2262 print_op_stat(
"read", &
read, 1);
2263 print_op_stat(
"write", &
write, 1);
2264 print_op_stat(
"lock", &
lock, 1);
2265 print_op_stat(
"unlock", &unlock, 1);
2293 DbgP(
"returning STATUS_PENDING\n");
2317 DbgP(
"Calling RxFinalizeConnection for NetRoot %p from VNetRoot %p\n",
2343 UCHAR op = RxContext->MajorFunction;
2349 DWORD nfs41d_version = 0;
2376 if (RxContext->RxDeviceObject->NumberOfActiveFcbs > 0) {
2377 DbgP(
"device has open handles %d\n",
2378 RxContext->RxDeviceObject->NumberOfActiveFcbs);
2380 if (RxContext->RxDeviceObject->pRxNetNameTable !=
NULL)
2382#define DUMP_FCB_TABLE_FROM_NETROOT(N) \
2385 BOOLEAN Release2 = FALSE; \
2386 if (!RxIsFcbTableLockAcquired(&(N)->FcbTable)) \
2388 RxAcquireFcbTableLockExclusive(&(N)->FcbTable, TRUE); \
2391 for (Bucket2 = 0; Bucket2 < (N)->FcbTable.NumberOfBuckets; ++Bucket2) \
2393 PLIST_ENTRY Entry2; \
2394 for (Entry2 = (N)->FcbTable.HashBuckets[Bucket2].Flink; \
2395 Entry2 != &(N)->FcbTable.HashBuckets[Bucket2]; \
2396 Entry2 = Entry2->Flink) \
2399 Fcb = CONTAINING_RECORD(Entry2, FCB, FcbTableEntry.HashLinks); \
2400 DbgP("Fcb: %p still has %d references\n", Fcb, Fcb->NodeReferenceCount); \
2401 DbgP("It is for: %wZ\n", &Fcb->FcbTableEntry.Path); \
2406 RxReleaseFcbTableLock(&(N)->FcbTable); \
2418 for (Bucket = 0; Bucket < RxContext->RxDeviceObject->pRxNetNameTable->TableSize; ++Bucket)
2422 for (
Entry = RxContext->RxDeviceObject->pRxNetNameTable->HashBuckets[Bucket].Flink;
2423 Entry != &RxContext->RxDeviceObject->pRxNetNameTable->HashBuckets[Bucket];
2435 NetRoot = Container;
2436 DUMP_FCB_TABLE_FROM_NETROOT(NetRoot);
2444 VNetRoot = Container;
2450 DUMP_FCB_TABLE_FROM_NETROOT(NetRoot);
2468#undef DUMP_FCB_TABLE_FROM_NETROOT
2472 DbgP(
"RxNetNameTable is NULL for: %p\n", RxContext->RxDeviceObject);
2499 RxContext->InformationToReturn =
sizeof(
ULONG);
2506 if (in_len >=
sizeof(
DWORD)) {
2508 DbgP(
"NFS41 Daemon sent start request with version %d\n",
2510 DbgP(
"Currently used NFS41 Daemon version is %d\n",
2511 DevExt->nfs41d_version);
2512 DevExt->nfs41d_version = nfs41d_version;
2524 DbgP(
"redirector started\n");
2527 RxContext->PostRequest ==
TRUE) {
2528 DbgP(
"RxStartMinirdr pending %08lx\n",
status);
2542 if (RxContext->RxDeviceObject->NumberOfActiveFcbs > 0) {
2543 DbgP(
"device has open handles %d\n",
2544 RxContext->RxDeviceObject->NumberOfActiveFcbs);
2555 DbgP(
"RxStopMinirdr status %08lx\n",
status);
2592 pSrvCall = SrvCalldownStructure->
SrvCall;
2600 DbgP(
"SrvCall: Connection Name Length: %d %wZ\n",
2605 print_error(
"Server name '%wZ' too long for server entry (max %u)\n",
2614 if (pServerEntry ==
NULL) {
2635 SrvCalldownStructure->
CallBack(SCCBC);
2645 PVOID pCallbackContext)
2665 DbgP(
"executing with RDBSS context\n");
2670 _nfs41_CreateSrvCall_v, pCallbackContext);
2675 print_error(
"RxDispatchToWorkerThread returned status %08lx\n",
2703 if (!ThisMinirdrIsTheWinner) {
2708 pSrvCall->Context = pServerEntry;
2723 print_error(
"failed to map windows error %d to NTSTATUS; "
2724 "defaulting to STATUS_INSUFFICIENT_RESOURCES\n",
status);
2741 DbgP(
"Server Name %wZ Mount Point %wZ SecFlavor %d\n",
2753 entry->u.Mount.FsAttrs = FsAttrs;
2786 Config->SrvName.Length = 0;
2789 Config->MntPt.Length = 0;
2792 Config->SecFlavor.Length = 0;
2808 if (Option->EaValueLength == 0 || *usValue->Buffer ==
L'1')
2813 DbgP(
" '%ls' -> '%wZ' -> %u\n",
2828 if (Option->EaValueLength) {
2831#ifdef IMPOSE_MINMAX_RWSIZES
2832 if (*
Value < Minimum)
2834 if (*
Value > Maximum)
2840 print_error(
"Failed to convert %s='%wZ' to unsigned long.\n",
2913 print_error(
"Unrecognized option '%ls' -> '%wZ'\n",
2933 if (NetRootName->Length == SrvCallName->Length + NfsPrefix.Length) {
2936 NetRootName->MaximumLength - SrvCallName->Length,
2937 &NetRootName->Buffer[SrvCallName->Length/2]
2977 print_error(
"nfs41_GetLUID: SeCreateClientSecurityFromSubjectContext "
2979 goto release_sec_ctx;
2984 goto release_clnt_sec_ctx;
2986release_clnt_sec_ctx:
3009 print_error(
"SeCreateClientSecurityFromSubjectContext "
3010 "failed with %x\n",
status);
3013 DbgP(
"Created client security token %p\n", out_ctx->ClientToken);
3030 pCreateNetRootContext->pVNetRoot;
3038 DWORD nfs41d_version = DevExt->nfs41d_version;
3052 DbgP(
"pVNetRoot=%p pNetRoot=%p pSrvCall=%p\n", pVNetRoot, pNetRoot, pSrvCall);
3053 DbgP(
"pNetRoot=%wZ Type=%d pSrvCallName=%wZ VirtualNetRootStatus=0x%x "
3054 "NetRootStatus=0x%x\n", pNetRoot->pNetRootName,
3055 pNetRoot->Type, pSrvCall->pSrvCallName,
3056 pCreateNetRootContext->VirtualNetRootStatus,
3057 pCreateNetRootContext->NetRootStatus);
3061 print_error(
"nfs41_CreateVNetRoot: Unsupported NetRoot Type %u\n",
3073 print_error(
"nfs41_CreateVNetRoot: NetRootName %wZ doesn't match "
3074 "'\\nfs4'!\n", pNetRoot->pNetRootName);
3088 if (pCreateNetRootContext->RxContext->Create.EaLength) {
3091 pCreateNetRootContext->RxContext->Create.EaBuffer,
3092 pCreateNetRootContext->RxContext->Create.EaLength,
3096 pVNetRootContext->read_only =
Config->ReadOnly;
3097 pVNetRootContext->write_thru =
Config->write_thru;
3098 pVNetRootContext->nocache =
Config->nocache;
3101 Config->SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1;
3103 pSrvCall->pSrvCallName->Length -
sizeof(
WCHAR);
3104 Config->SrvName.MaximumLength =
3105 pSrvCall->pSrvCallName->MaximumLength -
sizeof(
WCHAR);
3107 pVNetRootContext->MountPathLen =
Config->MntPt.Length;
3108 pVNetRootContext->timeout =
Config->timeout;
3112 DbgP(
"Invalid rpcsec security flavor %wZ\n", &
Config->SecFlavor);
3120 if (!pNetRootContext->mounts_init) {
3122 DbgP(
"Initializing mount array\n");
3126 pNetRootContext->mounts_init =
TRUE;
3131 pEntry = &pNetRootContext->mounts.head;
3142 DbgP(
"Found a matching LUID entry\n");
3144 found_existing_mount =
TRUE;
3145 switch(pVNetRootContext->sec_flavor) {
3148 pVNetRootContext->session =
3153 pVNetRootContext->session = existing_mount->
gss_session;
3157 pVNetRootContext->session = existing_mount->
gssi_session;
3161 pVNetRootContext->session = existing_mount->
gssp_session;
3164 if (pVNetRootContext->session &&
3166 found_matching_flavor = 1;
3169 if (
pEntry->
Flink == &pNetRootContext->mounts.head)
3175 if (!found_matching_flavor)
3176 DbgP(
"Didn't find matching security flavor\n");
3182 &pVNetRootContext->session, &nfs41d_version,
3183 &pVNetRootContext->FsAttrs);
3187 pNetRootContext->mounts, MountsEmpty);
3188 if (!found_existing_mount && MountsEmpty)
3189 pNetRootContext->mounts_init =
FALSE;
3193 pVNetRootContext->timeout =
Config->timeout;
3195 if (!found_existing_mount) {
3204 entry->authsys_session =
entry->gss_session =
3206 switch (pVNetRootContext->sec_flavor) {
3208 entry->authsys_session = pVNetRootContext->session;
break;
3210 entry->gss_session = pVNetRootContext->session;
break;
3212 entry->gssi_session = pVNetRootContext->session;
break;
3214 entry->gssp_session = pVNetRootContext->session;
break;
3218 pNetRootContext->mounts,
entry);
3219 }
else if (!found_matching_flavor) {
3223 DbgP(
"Using existing %d flavor session 0x%x\n",
3224 pVNetRootContext->sec_flavor);
3226 switch (pVNetRootContext->sec_flavor) {
3230 existing_mount->
gss_session = pVNetRootContext->session;
break;
3232 existing_mount->
gssi_session = pVNetRootContext->session;
break;
3234 existing_mount->
gssp_session = pVNetRootContext->session;
break;
3237 pNetRootContext->nfs41d_version = nfs41d_version;
3239 DbgP(
"Saving new session 0x%x\n", pVNetRootContext->session);
3241#ifdef STORE_MOUNT_SEC_CONTEXT
3243 &pVNetRootContext->mount_sec_ctx);
3249 pCreateNetRootContext->VirtualNetRootStatus =
status;
3250 if (pNetRoot->Context ==
NULL)
3251 pCreateNetRootContext->NetRootStatus =
status;
3252 pCreateNetRootContext->Callback(pCreateNetRootContext);
3274 PWCH w = FilePathName->Buffer;
3278 w += (SrvCall->pSrvCallName->Length/
sizeof(
WCHAR));
3279 NetRootName->Buffer = wlow =
w;
3292 NetRootName->Length = NetRootName->MaximumLength
3295 DbgP(
"In: pSrvCall %p PathName=%wZ SrvCallName=%wZ Out: NetRootName=%wZ\n",
3296 SrvCall, FilePathName, SrvCall->pSrvCallName, NetRootName);
3318 if (pSrvCall->Context ==
NULL)
3330 pSrvCall->Context =
NULL;
3363 print_error(
"nfs41_FinalizeNetRoot: No valid session established\n");
3375 pNetRootContext->
mounts, mount_tmp);
3376 if (mount_tmp ==
NULL)
3379 DbgP(
"Removing entry luid %x.%x from mount list\n",
3392 print_error(
"nfs41_unmount RPCSEC_GSS_KRB5 failed with %d\n",
3399 print_error(
"nfs41_unmount RPCSEC_GSS_KRB5I failed with %d\n",
3406 print_error(
"nfs41_unmount RPCSEC_GSS_KRB5P failed with %d\n",
3419 DbgP(
"Removing entry from upcall list\n");
3430 DbgP(
"Removing entry from downcall list\n");
3462#ifdef STORE_MOUNT_SEC_CONTEXT
3465 DbgP(
"nfs41_FinalizeVNetRoot: deleting security context: %p\n",
3501 for (
i = 0;
i <
name->Length / 2;
i++) {
3504 if (
p[0] ==
L'\0')
return FALSE;
3518 for (
i = 0;
i <
name->Length / 2;
i++) {
3519 if (
p[0] ==
L':')
return TRUE;
3520 else if (
p[0] ==
L'\0')
return FALSE;
3572 print_error(
"[ERROR] nfs41_Create: upcall returned %d returning "
3573 "STATUS_INSUFFICIENT_RESOURCES\n",
status);
3582 switch(disposition) {
3596 print_error(
"unknown disposition %d\n", disposition);
3606 if (
AnsiStrEq(&NfsV3Attributes, ea->EaName, ea->EaNameLength)
3607 ||
AnsiStrEq(&NfsActOnLink, ea->EaName, ea->EaNameLength)
3608 ||
AnsiStrEq(&NfsSymlinkTargetName, ea->EaName, ea->EaNameLength))
3625 &pVNetRootContext->FsAttrs;
3631 RxContext->CurrentIrp->AssociatedIrp.SystemBuffer;
3635 print_error(
"nfs41_Create: Unsupported NetRoot Type %u\n",
3636 Fcb->pNetRoot->Type);
3642 print_error(
"FCB_STATE_PAGING_FILE not implemented\n");
3647 if (!pNetRootContext->mounts_init) {
3648 print_error(
"nfs41_Create: No valid session established\n");
3653 if (
isStream(SrvOpen->pAlreadyPrefixedName)) {
3658 if (pVNetRootContext->read_only &&
3674 if (
Fcb->
OpenCount && nfs41_fcb->StandardInfo.DeletePending &&
3685 if ((!RxContext->CurrentIrpSp->FileObject->SharedRead &&
3687 ((!RxContext->CurrentIrpSp->FileObject->SharedWrite &&
3690 (!RxContext->CurrentIrpSp->FileObject->SharedDelete &&
3693 if ((!RxContext->CurrentIrpSp->FileObject->SharedRead &&
3695 (!RxContext->CurrentIrpSp->FileObject->SharedWrite &&
3698 (!RxContext->CurrentIrpSp->FileObject->SharedDelete &&
3724 if (!
AnsiStrEq(&NfsV3Attributes, ea->EaName, ea->EaNameLength) &&
3725 !
AnsiStrEq(&NfsActOnLink, ea->EaName, ea->EaNameLength) &&
3726 !
AnsiStrEq(&NfsSymlinkTargetName, ea->EaName, ea->EaNameLength)) {
3732 }
else if (RxContext->CurrentIrpSp->Parameters.Create.EaLength) {
3752 RxContext->CurrentIrp->AssociatedIrp.SystemBuffer;
3761 BOOLEAN oldDeletePending = nfs41_fcb->StandardInfo.DeletePending;
3762#ifdef ENABLE_TIMINGS
3779#if defined(STORE_MOUNT_SEC_CONTEXT) && defined (USE_MOUNT_SEC_CONTEXT)
3785 pNetRootContext->nfs41d_version,
3786 SrvOpen->pAlreadyPrefixedName, &
entry);
3789 entry->u.Open.access_mask =
params->DesiredAccess;
3796 entry->u.Open.srv_open = SrvOpen;
3805 entry->u.Open.mode = 0777;
3806 if (ea && AnsiStrEq(&NfsV3Attributes, ea->EaName, ea->EaNameLength)) {
3807 nfs3_attrs *attrs = (nfs3_attrs *)(ea->EaName + ea->EaNameLength + 1);
3809 DbgP(
"creating file with mode %o\n", attrs->mode);
3811 entry->u.Open.mode = attrs->mode;
3814 entry->u.Open.mode = 0444;