mirror of
https://github.com/reactos/reactos.git
synced 2024-11-10 00:34:39 +00:00
6afbc8f483
svn path=/branches/reactos-yarotows/; revision=45219
118 lines
3.5 KiB
C
118 lines
3.5 KiB
C
/*
|
|
* PROJECT: ReactOS Kernel
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
* FILE: ntoskrnl/io/symlink.c
|
|
* PURPOSE: I/O Wrappers for Symbolic Links
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
* Eric Kohl
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include <ntoskrnl.h>
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
NTSTATUS
|
|
NTAPI
|
|
IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
|
|
IN PUNICODE_STRING DeviceName)
|
|
{
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
HANDLE Handle;
|
|
NTSTATUS Status;
|
|
PAGED_CODE();
|
|
|
|
/* Initialize the object attributes and create the link */
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
SymbolicLinkName,
|
|
OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
|
|
NULL,
|
|
SePublicDefaultSd);
|
|
Status = ZwCreateSymbolicLinkObject(&Handle,
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
&ObjectAttributes,
|
|
DeviceName);
|
|
if (NT_SUCCESS(Status)) ZwClose(Handle);
|
|
|
|
/* Return status */
|
|
return Status;
|
|
}
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
NTSTATUS
|
|
NTAPI
|
|
IoCreateUnprotectedSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
|
|
IN PUNICODE_STRING DeviceName)
|
|
{
|
|
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,
|
|
OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
|
|
NULL,
|
|
&SecurityDescriptor);
|
|
Status = ZwCreateSymbolicLinkObject(&Handle,
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
&ObjectAttributes,
|
|
DeviceName);
|
|
if (NT_SUCCESS(Status)) ZwClose(Handle);
|
|
|
|
/* Return status */
|
|
return Status;
|
|
}
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
NTSTATUS
|
|
NTAPI
|
|
IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
|
|
{
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
HANDLE Handle;
|
|
NTSTATUS Status;
|
|
PAGED_CODE();
|
|
|
|
/* Initialize the object attributes and open the link */
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
SymbolicLinkName,
|
|
OBJ_CASE_INSENSITIVE,
|
|
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;
|
|
}
|
|
|
|
/* EOF */
|