Amd64/misc 64bit fixes (#236)
[reactos.git] / drivers / serial / serial / create.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Serial port driver
4 * FILE: drivers/dd/serial/create.c
5 * PURPOSE: Serial IRP_MJ_CREATE operations
6 *
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 */
9
10 #include "serial.h"
11
12 #include <debug.h>
13
14 NTSTATUS NTAPI
15 SerialCreate(
16 IN PDEVICE_OBJECT DeviceObject,
17 IN PIRP Irp)
18 {
19 PIO_STACK_LOCATION Stack;
20 PSERIAL_DEVICE_EXTENSION DeviceExtension;
21 NTSTATUS Status;
22
23 TRACE_(SERIAL, "IRP_MJ_CREATE\n");
24 Stack = IoGetCurrentIrpStackLocation(Irp);
25 DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
26
27 if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
28 {
29 INFO_(SERIAL, "Not a directory\n");
30 Status = STATUS_NOT_A_DIRECTORY;
31 goto ByeBye;
32 }
33
34 if(DeviceExtension->IsOpened)
35 {
36 WARN_(SERIAL, "COM%lu is already opened\n", DeviceExtension->ComPort);
37 Status = STATUS_ACCESS_DENIED;
38 goto ByeBye;
39 }
40
41 INFO_(SERIAL, "Open COM%lu: successfull\n", DeviceExtension->ComPort);
42 DeviceExtension->IsOpened = TRUE;
43 Status = STATUS_SUCCESS;
44
45 ByeBye:
46 Irp->IoStatus.Status = Status;
47 Irp->IoStatus.Information = 0;
48 IoCompleteRequest(Irp, IO_NO_INCREMENT);
49 return Status;
50 }