2006-06-30 18:14:54 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2015-10-04 11:54:25 +00:00
|
|
|
* FILE: ntoskrnl/io/iomgr/symlink.c
|
2006-06-30 18:14:54 +00:00
|
|
|
* PURPOSE: I/O Wrappers for Symbolic Links
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
* Eric Kohl
|
1998-08-25 04:27:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
1998-09-13 15:55:55 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
1998-08-25 04:27:26 +00:00
|
|
|
|
2003-02-25 16:50:46 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2006-06-30 18:14:54 +00:00
|
|
|
/*
|
2003-07-10 15:47:00 +00:00
|
|
|
* @implemented
|
1999-08-29 06:59:11 +00:00
|
|
|
*/
|
2006-06-30 18:14:54 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
|
|
|
|
IN PUNICODE_STRING DeviceName)
|
1999-02-01 20:58:37 +00:00
|
|
|
{
|
2006-06-30 18:14:54 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE Handle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
/* Initialize the object attributes and create the link */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
SymbolicLinkName,
|
2015-12-16 18:08:38 +00:00
|
|
|
OBJ_KERNEL_HANDLE | OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
|
2006-06-30 18:14:54 +00:00
|
|
|
NULL,
|
|
|
|
SePublicDefaultSd);
|
|
|
|
Status = ZwCreateSymbolicLinkObject(&Handle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
DeviceName);
|
|
|
|
if (NT_SUCCESS(Status)) ZwClose(Handle);
|
|
|
|
|
|
|
|
/* Return status */
|
|
|
|
return Status;
|
1998-10-05 04:01:30 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 18:14:54 +00:00
|
|
|
/*
|
2003-07-10 15:47:00 +00:00
|
|
|
* @implemented
|
1999-08-29 06:59:11 +00:00
|
|
|
*/
|
2006-06-30 18:14:54 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IoCreateUnprotectedSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
|
|
|
|
IN PUNICODE_STRING DeviceName)
|
1998-09-13 15:55:55 +00:00
|
|
|
{
|
2006-06-30 18:14:54 +00:00
|
|
|
SECURITY_DESCRIPTOR SecurityDescriptor;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE Handle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
/* Create an SD */
|
|
|
|
Status = RtlCreateSecurityDescriptor(&SecurityDescriptor,
|
|
|
|
SECURITY_DESCRIPTOR_REVISION);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
/* Set the DACL */
|
|
|
|
Status = RtlSetDaclSecurityDescriptor(&SecurityDescriptor,
|
|
|
|
TRUE,
|
|
|
|
NULL,
|
|
|
|
TRUE);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
/* Initialize the object attributes and create the link */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
SymbolicLinkName,
|
2015-12-16 18:08:38 +00:00
|
|
|
OBJ_KERNEL_HANDLE | OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
|
2006-06-30 18:14:54 +00:00
|
|
|
NULL,
|
|
|
|
&SecurityDescriptor);
|
|
|
|
Status = ZwCreateSymbolicLinkObject(&Handle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
DeviceName);
|
|
|
|
if (NT_SUCCESS(Status)) ZwClose(Handle);
|
|
|
|
|
|
|
|
/* Return status */
|
|
|
|
return Status;
|
1998-08-25 04:27:26 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 18:14:54 +00:00
|
|
|
/*
|
2003-07-10 15:47:00 +00:00
|
|
|
* @implemented
|
1999-08-29 06:59:11 +00:00
|
|
|
*/
|
2006-06-30 18:14:54 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
|
1998-10-05 04:01:30 +00:00
|
|
|
{
|
2006-06-30 18:14:54 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE Handle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
/* Initialize the object attributes and open the link */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
SymbolicLinkName,
|
2015-12-16 18:08:38 +00:00
|
|
|
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
|
2006-06-30 18:14:54 +00:00
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = ZwOpenSymbolicLinkObject(&Handle, DELETE, &ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
/* Make the link temporary and close its handle */
|
|
|
|
Status = ZwMakeTemporaryObject(Handle);
|
|
|
|
if (NT_SUCCESS(Status)) ZwClose(Handle);
|
|
|
|
|
|
|
|
/* Return status */
|
|
|
|
return Status;
|
1998-10-05 04:01:30 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
/* EOF */
|