- Io*SymbolicLink should use OBJ_CASE_INSENSITIVE

- Use DELETE instead of SYMBOLIC_LINK_ALL_ACCESS when deleting.
- Fix formatting in timer.c
- Clear the IO_TIMER structure when creating it.

svn path=/trunk/; revision=22722
This commit is contained in:
Alex Ionescu 2006-06-30 18:14:54 +00:00
parent b42accc93a
commit d1ebf29520
3 changed files with 210 additions and 293 deletions

View file

@ -1,8 +1,8 @@
/* /*
* PROJECT: ReactOS Kernel * PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory * LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/io/event.c * FILE: ntoskrnl/io/iocomp.c
* PURPOSE: I/O Wrappers for the Executive Event Functions * PURPOSE: I/O Wrappers (called Completion Ports) for Kernel Queues
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Thomas Weidenmueller (w3seek@reactos.org) * Thomas Weidenmueller (w3seek@reactos.org)
*/ */

View file

@ -1,11 +1,10 @@
/* $Id$ /*
* * PROJECT: ReactOS Kernel
* COPYRIGHT: See COPYING in the top level directory * LICENSE: GPL - See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/symlink.c * FILE: ntoskrnl/io/symlink.c
* PURPOSE: Implements symbolic links * PURPOSE: I/O Wrappers for Symbolic Links
* * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* PROGRAMMERS: David Welch (welch@mcmail.com) * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -14,170 +13,106 @@
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
/********************************************************************** /*
* NAME EXPORTED
* IoCreateSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* @implemented * @implemented
*/ */
NTSTATUS STDCALL NTSTATUS
IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName, NTAPI
PUNICODE_STRING DeviceName) IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
IN PUNICODE_STRING DeviceName)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle; HANDLE Handle;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Initialize the object attributes and create the link */
DPRINT("IoCreateSymbolicLink(SymbolicLinkName %wZ, DeviceName %wZ)\n",
SymbolicLinkName,
DeviceName);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
SymbolicLinkName, SymbolicLinkName,
OBJ_PERMANENT, OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
NULL, NULL,
SePublicDefaultSd); SePublicDefaultSd);
Status = ZwCreateSymbolicLinkObject(&Handle, Status = ZwCreateSymbolicLinkObject(&Handle,
SYMBOLIC_LINK_ALL_ACCESS, SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
DeviceName); DeviceName);
if (!NT_SUCCESS(Status)) if (NT_SUCCESS(Status)) ZwClose(Handle);
{
DPRINT1("ZwCreateSymbolicLinkObject() failed (Status %lx)\n", Status);
return(Status);
}
ZwClose(Handle); /* Return status */
return Status;
return(STATUS_SUCCESS);
} }
/*
/**********************************************************************
* NAME EXPORTED
* IoCreateUnprotectedSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* @implemented * @implemented
*/ */
NTSTATUS STDCALL NTSTATUS
IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName, NTAPI
PUNICODE_STRING DeviceName) IoCreateUnprotectedSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
IN PUNICODE_STRING DeviceName)
{ {
SECURITY_DESCRIPTOR SecurityDescriptor; SECURITY_DESCRIPTOR SecurityDescriptor;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle; HANDLE Handle;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Create an SD */
DPRINT("IoCreateUnprotectedSymbolicLink(SymbolicLinkName %wZ, DeviceName %wZ)\n",
SymbolicLinkName,
DeviceName);
Status = RtlCreateSecurityDescriptor(&SecurityDescriptor, Status = RtlCreateSecurityDescriptor(&SecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION); SECURITY_DESCRIPTOR_REVISION);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return Status;
{
DPRINT1("RtlCreateSecurityDescriptor() failed (Status %lx)\n", Status);
return(Status);
}
/* Set the DACL */
Status = RtlSetDaclSecurityDescriptor(&SecurityDescriptor, Status = RtlSetDaclSecurityDescriptor(&SecurityDescriptor,
TRUE, TRUE,
NULL, NULL,
TRUE); TRUE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return Status;
{
DPRINT1("RtlSetDaclSecurityDescriptor() failed (Status %lx)\n", Status);
return(Status);
}
/* Initialize the object attributes and create the link */
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
SymbolicLinkName, SymbolicLinkName,
OBJ_PERMANENT, OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
NULL, NULL,
&SecurityDescriptor); &SecurityDescriptor);
Status = ZwCreateSymbolicLinkObject(&Handle, Status = ZwCreateSymbolicLinkObject(&Handle,
SYMBOLIC_LINK_ALL_ACCESS, SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
DeviceName); DeviceName);
if (!NT_SUCCESS(Status)) if (NT_SUCCESS(Status)) ZwClose(Handle);
{
DPRINT1("ZwCreateSymbolicLinkObject() failed (Status %lx)\n", Status);
return(Status);
}
ZwClose(Handle); /* Return status */
return Status;
return(STATUS_SUCCESS);
} }
/*
/**********************************************************************
* NAME EXPORTED
* IoDeleteSymbolicLink
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* REVISIONS
*
* @implemented * @implemented
*/ */
NTSTATUS STDCALL NTSTATUS
IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName) NTAPI
IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle; HANDLE Handle;
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Initialize the object attributes and open the link */
DPRINT("IoDeleteSymbolicLink (SymbolicLinkName %S)\n",
SymbolicLinkName->Buffer);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
SymbolicLinkName, SymbolicLinkName,
OBJ_OPENLINK, OBJ_CASE_INSENSITIVE,
NULL, NULL,
NULL); NULL);
Status = ZwOpenSymbolicLinkObject(&Handle, DELETE, &ObjectAttributes);
if (!NT_SUCCESS(Status)) return Status;
Status = ZwOpenSymbolicLinkObject(&Handle, /* Make the link temporary and close its handle */
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
return(Status);
Status = ZwMakeTemporaryObject(Handle); Status = ZwMakeTemporaryObject(Handle);
ZwClose(Handle); if (NT_SUCCESS(Status)) ZwClose(Handle);
return(Status); /* Return status */
return Status;
} }
/* EOF */ /* EOF */

View file

@ -1,12 +1,9 @@
/* $Id$ /*
* * PROJECT: ReactOS Kernel
* COPYRIGHT: See COPYING in the top level directory * LICENSE: GPL - See COPYING in the top level directory
* PROJECT: ReactOS kernel * FILE: ntoskrnl/io/iocomp.c
* FILE: ntoskrnl/io/timer.c * PURPOSE: I/O Wrappers for Executive Timers
* PURPOSE: IO timers * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*
* PROGRAMMERS: David Welch (welch@mcmail.com)
* Alex Ionescu (alex@relsoft.net)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -28,9 +25,10 @@ KTIMER IopTimer;
/* Keep count of how many timers we have */ /* Keep count of how many timers we have */
ULONG IopTimerCount = 0; ULONG IopTimerCount = 0;
/* FUNCTIONS *****************************************************************/ /* PRIVATE FUNCTIONS *********************************************************/
static VOID STDCALL VOID
NTAPI
IopTimerDispatch(IN PKDPC Dpc, IopTimerDispatch(IN PKDPC Dpc,
IN PVOID DeferredContext, IN PVOID DeferredContext,
IN PVOID SystemArgument1, IN PVOID SystemArgument1,
@ -41,24 +39,22 @@ IopTimerDispatch(IN PKDPC Dpc,
PIO_TIMER Timer; PIO_TIMER Timer;
ULONG i; ULONG i;
DPRINT("Dispatching IO Timers. There are: %x \n", IopTimerCount);
/* Check if any Timers are actualyl enabled as of now */ /* Check if any Timers are actualyl enabled as of now */
if (IopTimerCount) { if (IopTimerCount)
{
/* Lock the Timers */ /* Lock the Timers */
KeAcquireSpinLock(&IopTimerLock, &OldIrql); KeAcquireSpinLock(&IopTimerLock, &OldIrql);
/* Call the Timer Routine of each enabled Timer */ /* Call the Timer Routine of each enabled Timer */
for(TimerEntry = IopTimerQueueHead.Flink, i = IopTimerCount; for (TimerEntry = IopTimerQueueHead.Flink, i = IopTimerCount;
(TimerEntry != &IopTimerQueueHead) && i; (TimerEntry != &IopTimerQueueHead) && i;
TimerEntry = TimerEntry->Flink) { TimerEntry = TimerEntry->Flink)
{
/* Get the timer and check if it's enabled */
Timer = CONTAINING_RECORD(TimerEntry, IO_TIMER, IoTimerList); Timer = CONTAINING_RECORD(TimerEntry, IO_TIMER, IoTimerList);
if (Timer->TimerEnabled) { if (Timer->TimerEnabled)
DPRINT("Dispatching a Timer Routine: 0x%p for Device Object: 0x%p \n", {
Timer->TimerRoutine, /* Call the timer routine */
Timer->DeviceObject);
Timer->TimerRoutine(Timer->DeviceObject, Timer->Context); Timer->TimerRoutine(Timer->DeviceObject, Timer->Context);
i--; i--;
} }
@ -70,10 +66,8 @@ IopTimerDispatch(IN PKDPC Dpc,
} }
VOID VOID
STDCALL NTAPI
IopRemoveTimerFromTimerList( IopRemoveTimerFromTimerList(IN PIO_TIMER Timer)
IN PIO_TIMER Timer
)
{ {
KIRQL OldIrql; KIRQL OldIrql;
@ -91,9 +85,6 @@ IopRemoveTimerFromTimerList(
VOID VOID
FASTCALL FASTCALL
IopInitTimerImplementation(VOID) IopInitTimerImplementation(VOID)
/* FUNCTION: Initializes the IO Timer Object Implementation
* RETURNS: NOTHING
*/
{ {
LARGE_INTEGER ExpireTime; LARGE_INTEGER ExpireTime;
@ -110,114 +101,105 @@ IopInitTimerImplementation(VOID)
KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc); KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc);
} }
/* PUBLIC FUNCTIONS **********************************************************/
/* /*
* @implemented * @implemented
*/ */
NTSTATUS NTSTATUS
STDCALL NTAPI
IoInitializeTimer(PDEVICE_OBJECT DeviceObject, IoInitializeTimer(IN PDEVICE_OBJECT DeviceObject,
PIO_TIMER_ROUTINE TimerRoutine, IN PIO_TIMER_ROUTINE TimerRoutine,
PVOID Context) IN PVOID Context)
/*
* FUNCTION: Sets up a driver-supplied IoTimer routine associated with a given
* device object
* ARGUMENTS:
* DeviceObject = Device object whose timer is be initialized
* TimerRoutine = Driver supplied routine which will be called once per
* second if the timer is active
* Context = Driver supplied context to be passed to the TimerRoutine
* RETURNS: Status
*/
{ {
DPRINT("IoInitializeTimer() called for Device Object: 0x%p with Routine: 0x%p \n", DeviceObject, TimerRoutine); PIO_TIMER IoTimer = DeviceObject->Timer;
PAGED_CODE();
/* Check if we don't have a timer yet */
if (!IoTimer)
{
/* Allocate Timer */ /* Allocate Timer */
if (!DeviceObject->Timer) { IoTimer = ExAllocatePoolWithTag(NonPagedPool,
DeviceObject->Timer = ExAllocatePoolWithTag(NonPagedPool,
sizeof(IO_TIMER), sizeof(IO_TIMER),
TAG_IO_TIMER); TAG_IO_TIMER);
if (!DeviceObject->Timer) return STATUS_INSUFFICIENT_RESOURCES; if (!IoTimer) return STATUS_INSUFFICIENT_RESOURCES;
/* Set up the Timer Structure */ /* Set up the Timer Structure */
DeviceObject->Timer->Type = IO_TYPE_TIMER; RtlZeroMemory(IoTimer, sizeof(IO_TIMER));
DeviceObject->Timer->DeviceObject = DeviceObject; IoTimer->Type = IO_TYPE_TIMER;
IoTimer->DeviceObject = DeviceObject;
DeviceObject->Timer = IoTimer;
} }
DeviceObject->Timer->TimerRoutine = TimerRoutine; /* Setup the timer routine and context */
DeviceObject->Timer->Context = Context; IoTimer->TimerRoutine = TimerRoutine;
DeviceObject->Timer->TimerEnabled = FALSE; IoTimer->Context = Context;
/* Add it to the Timer List */ /* Add it to the Timer List */
ExInterlockedInsertTailList(&IopTimerQueueHead, ExInterlockedInsertTailList(&IopTimerQueueHead,
&DeviceObject->Timer->IoTimerList, &IoTimer->IoTimerList,
&IopTimerLock); &IopTimerLock);
/* Return Success */ /* Return Success */
DPRINT("IoInitializeTimer() Completed\n"); return STATUS_SUCCESS;
return(STATUS_SUCCESS);
} }
/* /*
* @implemented * @implemented
*/ */
VOID VOID
STDCALL NTAPI
IoStartTimer(PDEVICE_OBJECT DeviceObject) IoStartTimer(IN PDEVICE_OBJECT DeviceObject)
/*
* FUNCTION: Starts a timer so the driver-supplied IoTimer routine will be
* called once per second
* ARGUMENTS:
* DeviceObject = Device whose timer is to be started
*/
{ {
KIRQL OldIrql; KIRQL OldIrql;
PIO_TIMER IoTimer = DeviceObject->Timer;
DPRINT("IoStartTimer for Device Object: 0x%p\n", DeviceObject); /* Make sure the device isn't unloading */
if (!(((PEXTENDED_DEVOBJ_EXTENSION)(DeviceObject->DeviceObjectExtension))->
ExtensionFlags & (DOE_UNLOAD_PENDING |
DOE_DELETE_PENDING |
DOE_REMOVE_PENDING |
DOE_REMOVE_PROCESSED)))
{
/* Lock Timers */ /* Lock Timers */
KeAcquireSpinLock(&IopTimerLock, &OldIrql); KeAcquireSpinLock(&IopTimerLock, &OldIrql);
/* If the timer isn't already enabled, enable it and increase IO Timer Count*/ /* Check if the timer isn't already enabled */
if (!DeviceObject->Timer->TimerEnabled) { if (!IoTimer->TimerEnabled)
DeviceObject->Timer->TimerEnabled = TRUE; {
/* Enable it and increase the timer count */
IoTimer->TimerEnabled = TRUE;
IopTimerCount++; IopTimerCount++;
} }
/* Unlock Timers */ /* Unlock Timers */
KeReleaseSpinLock(&IopTimerLock, OldIrql); KeReleaseSpinLock(&IopTimerLock, OldIrql);
DPRINT("IoStartTimer Completed for Device Object: 0x%p New Count: %x \n", DeviceObject, IopTimerCount); }
} }
/* /*
* @implemented * @implemented
*/ */
VOID VOID
STDCALL NTAPI
IoStopTimer(PDEVICE_OBJECT DeviceObject) IoStopTimer(PDEVICE_OBJECT DeviceObject)
/*
* FUNCTION: Disables for a specified device object so the driver-supplied
* IoTimer is not called
* ARGUMENTS:
* DeviceObject = Device whose timer is to be stopped
*/
{ {
KIRQL OldIrql; KIRQL OldIrql;
PIO_TIMER IoTimer = DeviceObject->Timer;
DPRINT("IoStopTimer for Device Object: 0x%p\n", DeviceObject);
/* Lock Timers */ /* Lock Timers */
KeAcquireSpinLock(&IopTimerLock, &OldIrql); KeAcquireSpinLock(&IopTimerLock, &OldIrql);
/* If the timer is enabled, disable it and decrease IO Timer Count*/ /* Check if the timer is enabled */
if (DeviceObject->Timer->TimerEnabled) { if (IoTimer->TimerEnabled)
DeviceObject->Timer->TimerEnabled = FALSE; {
/* Disable it and decrease the timer count */
IoTimer->TimerEnabled = FALSE;
IopTimerCount--; IopTimerCount--;
} }
/* Unlock Timers */ /* Unlock Timers */
KeReleaseSpinLock(&IopTimerLock, OldIrql); KeReleaseSpinLock(&IopTimerLock, OldIrql);
DPRINT("IoStopTimer Completed for Device Object: 0x%p New Count: %x \n", DeviceObject, IopTimerCount);
} }
/* EOF */ /* EOF */