* Sync with trunk r64401.
[reactos.git] / ntoskrnl / fsrtl / unc.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fsrtl/unc.c
5 * PURPOSE: Manages UNC support routines for file system drivers.
6 * PROGRAMMERS: None.
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 /* PUBLIC FUNCTIONS **********************************************************/
16
17 /*++
18 * @name FsRtlDeregisterUncProvider
19 * @unimplemented
20 *
21 * FILLME
22 *
23 * @param Handle
24 * FILLME
25 *
26 * @return None
27 *
28 * @remarks None
29 *
30 *--*/
31 VOID
32 NTAPI
33 FsRtlDeregisterUncProvider(IN HANDLE Handle)
34 {
35 UNICODE_STRING DosDevicesUNC = RTL_CONSTANT_STRING(L"\\DosDevices\\UNC");
36
37 DPRINT("FsRtlDeregisterUncProvider: Handle=%p\n", Handle);
38 //
39 // Normal implementation should look like:
40 // - notify mup.sys?
41 // - at last deregistration, destroy \DosDevices\UNC symbolic link
42 //
43
44 ZwClose(Handle);
45
46 IoDeleteSymbolicLink(&DosDevicesUNC);
47 }
48
49 /*++
50 * @name FsRtlRegisterUncProvider
51 * @unimplemented
52 *
53 * FILLME
54 *
55 * @param Handle
56 * FILLME
57 *
58 * @param RedirectorDeviceName
59 * FILLME
60 *
61 * @param MailslotsSupported
62 *
63 * @return None
64 *
65 * @remarks None
66 *
67 *--*/
68 NTSTATUS
69 NTAPI
70 FsRtlRegisterUncProvider(IN OUT PHANDLE Handle,
71 IN PUNICODE_STRING RedirectorDeviceName,
72 IN BOOLEAN MailslotsSupported)
73 {
74 UNICODE_STRING DevNull = RTL_CONSTANT_STRING(L"\\Device\\Null");
75 UNICODE_STRING DosDevicesUNC = RTL_CONSTANT_STRING(L"\\DosDevices\\UNC");
76 OBJECT_ATTRIBUTES ObjectAttributes;
77 IO_STATUS_BLOCK Iosb;
78 HANDLE FileHandle;
79 NTSTATUS Status;
80
81 DPRINT("FsRtlRegisterUncProvider: Redirector=%wZ MailslotsSupported=%d\n",
82 RedirectorDeviceName, MailslotsSupported);
83
84 //
85 // Current implementation is a hack, as it only supports one UNC provider.
86 // However, it doesn't require to have a functional mup.sys driver.
87 //
88
89 //
90 // Normal implementation should look like:
91 // - at registration 1, creates symlink \DosDevices\UNC to new provider;
92 // returns handle to \Device\Null
93 // - at registration 2, load mup.sys, register both providers to mup.sys
94 // and change \DosDevices\UNC to DD_MUP_DEVICE_NAME;
95 // returns handle to new provider
96 // - at next registrations, register provider to mup.sys;
97 // returns handle to new provider
98 //
99
100 *Handle = (HANDLE)-1;
101 InitializeObjectAttributes(&ObjectAttributes,
102 &DevNull,
103 OBJ_KERNEL_HANDLE,
104 NULL,
105 NULL);
106 Status = ZwCreateFile(&FileHandle,
107 GENERIC_WRITE,
108 &ObjectAttributes,
109 &Iosb,
110 NULL,
111 FILE_ATTRIBUTE_NORMAL,
112 FILE_SHARE_READ | FILE_SHARE_WRITE,
113 FILE_OPEN,
114 0,
115 NULL,
116 0);
117 if (!NT_SUCCESS(Status))
118 {
119 DPRINT("Failed to open %wZ\n", &DevNull);
120 return Status;
121 }
122
123 Status = IoCreateSymbolicLink(&DosDevicesUNC, RedirectorDeviceName);
124 if (!NT_SUCCESS(Status))
125 {
126 DPRINT("Failed to create symbolic link %wZ -> %wZ\n", &DosDevicesUNC, RedirectorDeviceName);
127 DPRINT1("FIXME: multiple unc provider registered?\n");
128 ZwClose(FileHandle);
129 return Status;
130 }
131
132 *Handle = FileHandle;
133 return STATUS_SUCCESS;
134 }