1 /* $Id: symlink.c,v 1.33 2003/07/10 15:47:00 royce Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/symlink.c
6 * PURPOSE: Implements symbolic links
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/se.h>
18 #include <internal/debug.h>
21 /* FUNCTIONS ****************************************************************/
23 /**********************************************************************
25 * IoCreateSymbolicLink
38 IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName
,
39 PUNICODE_STRING DeviceName
)
41 OBJECT_ATTRIBUTES ObjectAttributes
;
45 assert_irql(PASSIVE_LEVEL
);
47 DPRINT("IoCreateSymbolicLink(SymbolicLinkName %wZ, DeviceName %wZ)\n",
51 InitializeObjectAttributes(&ObjectAttributes
,
57 Status
= NtCreateSymbolicLinkObject(&Handle
,
58 SYMBOLIC_LINK_ALL_ACCESS
,
61 if (!NT_SUCCESS(Status
))
63 DPRINT1("NtCreateSymbolicLinkObject() failed (Status %lx)\n", Status
);
69 return(STATUS_SUCCESS
);
73 /**********************************************************************
75 * IoCreateUnprotectedSymbolicLink
88 IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName
,
89 PUNICODE_STRING DeviceName
)
91 SECURITY_DESCRIPTOR SecurityDescriptor
;
92 OBJECT_ATTRIBUTES ObjectAttributes
;
96 assert_irql(PASSIVE_LEVEL
);
98 DPRINT("IoCreateUnprotectedSymbolicLink(SymbolicLinkName %wZ, DeviceName %wZ)\n",
102 Status
= RtlCreateSecurityDescriptor(&SecurityDescriptor
,
103 SECURITY_DESCRIPTOR_REVISION
);
104 if (!NT_SUCCESS(Status
))
106 DPRINT1("RtlCreateSecurityDescriptor() failed (Status %lx)\n", Status
);
110 Status
= RtlSetDaclSecurityDescriptor(&SecurityDescriptor
,
114 if (!NT_SUCCESS(Status
))
116 DPRINT1("RtlSetDaclSecurityDescriptor() failed (Status %lx)\n", Status
);
120 InitializeObjectAttributes(&ObjectAttributes
,
124 &SecurityDescriptor
);
126 Status
= NtCreateSymbolicLinkObject(&Handle
,
127 SYMBOLIC_LINK_ALL_ACCESS
,
130 if (!NT_SUCCESS(Status
))
132 DPRINT1("NtCreateSymbolicLinkObject() failed (Status %lx)\n", Status
);
138 return(STATUS_SUCCESS
);
142 /**********************************************************************
144 * IoDeleteSymbolicLink
157 IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName
)
159 OBJECT_ATTRIBUTES ObjectAttributes
;
163 assert_irql(PASSIVE_LEVEL
);
165 DPRINT("IoDeleteSymbolicLink (SymbolicLinkName %S)\n",
166 SymbolicLinkName
->Buffer
);
168 InitializeObjectAttributes(&ObjectAttributes
,
174 Status
= NtOpenSymbolicLinkObject(&Handle
,
175 SYMBOLIC_LINK_ALL_ACCESS
,
177 if (!NT_SUCCESS(Status
))
180 Status
= NtMakeTemporaryObject(Handle
);